@churchapps/apphelper-donations
Version:
Donation components for ChurchApps AppHelper
37 lines • 1.72 kB
JavaScript
"use client";
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
import { FundDonation } from ".";
import { Locale } from "../helpers";
export const FundDonations = (props) => {
const handleUpdated = (fundDonation, index) => {
const fundDonations = [...props.fundDonations];
fundDonations[index] = fundDonation;
props.updatedFunction(fundDonations);
};
const addRow = (e) => {
e.preventDefault();
const fundDonations = [...props.fundDonations];
const fd = { fundId: props.funds[0].id };
fundDonations.push(fd);
props.updatedFunction(fundDonations);
};
const getRows = () => {
const result = [];
for (let i = 0; i < props.fundDonations.length; i++) {
const fd = props.fundDonations[i];
result.push(_jsx(FundDonation, { fundDonation: fd, funds: props.funds, updatedFunction: handleUpdated, params: props?.params, index: i }, i));
}
return result;
};
return (_jsxs(_Fragment, { children: [getRows(), (!props?.params?.fundId || props?.params?.fundId === "") &&
_jsx("button", { type: "button", "aria-label": "add-fund-donation", className: "text-decoration", style: {
display: "block",
marginBottom: "15px",
background: "none",
border: "none",
color: "#3b82f6",
cursor: "pointer",
textDecoration: "underline"
}, onClick: addRow, children: Locale.label("donation.fundDonations.addMore") })] }));
};
//# sourceMappingURL=FundDonations.js.map