UNPKG

@churchapps/apphelper-donations

Version:

Donation components for ChurchApps AppHelper

29 lines 2.22 kB
"use client"; import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime"; import { CurrencyHelper } from "@churchapps/helpers"; import { FormControl, Grid, Icon, InputLabel, MenuItem, Select, TextField, Typography } 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 }, props.funds[i].id)); } 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, InputProps: { startAdornment: _jsx(Icon, { children: _jsx(Typography, { children: props.currency ? CurrencyHelper.getCurrencySymbol(props.currency) : "$" }) }) } }) }), _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