@churchapps/apphelper-donations
Version:
Donation components for ChurchApps AppHelper
28 lines • 1.97 kB
JavaScript
"use client";
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
import { FormControl, Grid, InputLabel, MenuItem, Select, TextField } from "@mui/material";
import { Locale } from "../helpers";
export const FundDonation = (props) => {
const getOptions = () => {
const result = [];
for (let i = 0; i < props.funds.length; i++) {
const getDisabled = (props?.params?.fundId && props.params.fundId !== "") ? props.params.fundId !== props.funds[i].id : false;
result.push(_jsx(MenuItem, { value: props.funds[i].id, disabled: getDisabled, children: props.funds[i].name }, i));
}
return result;
};
const handleChange = (e) => {
const fd = { ...props.fundDonation };
switch (e.target.name) {
case "amount":
fd.amount = parseFloat(e.target.value.replace("$", "").replace(",", ""));
break;
case "fund":
fd.fundId = e.target.value;
break;
}
props.updatedFunction(fd, props.index);
};
return (_jsx(_Fragment, { children: _jsxs(Grid, { container: true, spacing: 3, children: [_jsx(Grid, { size: { xs: 12, md: 6 }, children: _jsx(TextField, { fullWidth: true, name: "amount", label: Locale.label("donation.fundDonations.amount"), type: "number", disabled: props.params?.amount && props.params.amount !== "", "aria-label": "amount", lang: "en-150", value: props.fundDonation.amount || "", onChange: handleChange }) }), _jsx(Grid, { size: { xs: 12, md: 6 }, children: _jsxs(FormControl, { fullWidth: true, children: [_jsx(InputLabel, { children: Locale.label("donation.fundDonations.fund") }), _jsx(Select, { fullWidth: true, label: Locale.label("donation.fundDonations.fund"), name: "fund", "aria-label": "fund", value: props.fundDonation.fundId, onChange: handleChange, children: getOptions() })] }) })] }) }));
};
//# sourceMappingURL=FundDonation.js.map