Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

invalid amount #211

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
149 changes: 77 additions & 72 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"@stripe/react-stripe-js": "^1.4.0",
"@stripe/stripe-js": "^1.13.2",
"axios": "^0.21.1",
"currency.js": "^2.0.4",
"dom-to-image": "^2.6.0",
"geocoder-arcgis": "^2.0.5",
"next": "^12.0.5",
Expand Down
51 changes: 35 additions & 16 deletions src/Donations/Components/DonationsForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,15 @@ function DonationsForm() {
profile,
frequency,
tenant,
setTransferDetails
setTransferDetails,
} = React.useContext(QueryParamContext);
const { t, i18n } = useTranslation(["common", "country", "donate"]);

const [minAmt, setMinAmt] = React.useState(0);
const [showFrequencyOptions, setShowFrequencyOptions] = React.useState(false);
const [invalidAmount, setInvalidAmount] = React.useState(false);
const { isLoading, isAuthenticated, getAccessTokenSilently } = useAuth0();

const router = useRouter();

React.useEffect(() => {
Expand Down Expand Up @@ -127,7 +129,7 @@ function DonationsForm() {
payDonationFunction({
gateway: "stripe",
method: "card", // Hard coding card here since we only have card enabled in gpay and apple pay
providerObject: paymentMethod,// payment method
providerObject: paymentMethod, // payment method
setIsPaymentProcessing,
setPaymentError,
t,
Expand All @@ -140,7 +142,7 @@ function DonationsForm() {
setshowErrorCard,
router,
tenant,
setTransferDetails
setTransferDetails,
});
});
};
Expand All @@ -150,9 +152,19 @@ function DonationsForm() {
const donationSelection = () => {
switch (projectDetails.purpose) {
case "funds":
return <FundingDonations setopenCurrencyModal={setopenCurrencyModal} />;
return (
<FundingDonations
setopenCurrencyModal={setopenCurrencyModal}
setInvalidAmount={setInvalidAmount}
/>
);
case "bouquet":
return <BouquetDonations setopenCurrencyModal={setopenCurrencyModal} />;
return (
<BouquetDonations
setopenCurrencyModal={setopenCurrencyModal}
setInvalidAmount={setInvalidAmount}
/>
);
case "trees":
default:
return <TreeDonation setopenCurrencyModal={setopenCurrencyModal} />;
Expand Down Expand Up @@ -215,13 +227,14 @@ function DonationsForm() {
)}

{process.env.RECURRENCY &&
showFrequencyOptions &&
!(isGift && giftDetails.recipientName === "") ? (
showFrequencyOptions &&
!(isGift && giftDetails.recipientName === "") ? (
<div
className={`donations-gift-container mt-10 ${paymentSetup.frequencies.length == 2
className={`donations-gift-container mt-10 ${
paymentSetup.frequencies.length == 2
? "funds-frequency-container"
: ""
}`}
}`}
>
<FrequencyOptions />
</div>
Expand All @@ -232,8 +245,9 @@ function DonationsForm() {
{donationSelection()}

<div
className={`${isGift && giftDetails.recipientName === "" ? "display-none" : ""
}`}
className={`${
isGift && giftDetails.recipientName === "" ? "display-none" : ""
}`}
>
<TaxDeductionOption />

Expand All @@ -243,12 +257,13 @@ function DonationsForm() {

{paymentSetup && projectDetails ? (
minAmt &&
(paymentSetup.unitBased
? paymentSetup?.unitCost * quantity
: quantity) >= minAmt ? (
!invalidAmount &&
(paymentSetup.unitBased
? paymentSetup?.unitCost * quantity
: quantity) >= minAmt ? (
!isPaymentOptionsLoading &&
paymentSetup?.gateways?.stripe?.account &&
currency ? (
paymentSetup?.gateways?.stripe?.account &&
currency ? (
<NativePay
country={country}
currency={currency}
Expand All @@ -275,6 +290,10 @@ function DonationsForm() {
<ButtonLoader />
</div>
)
) : invalidAmount ? (
<p className={"text-danger mt-20 text-center"}>
Invalid amount entered
</p>
) : minAmt > 0 ? (
<p className={"text-danger mt-20 text-center"}>
{t("minDonate")}{" "}
Expand Down
9 changes: 3 additions & 6 deletions src/Donations/Micros/DonationTypes/BouquetDonations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ function FundingDonations({ setopenCurrencyModal }: Props): ReactElement {
setisCustomDonation(true);
} else if (newQuantity == 0) {
setisCustomDonation(true);
} else if (newQuantity == 0) {
setisCustomDonation(true);
customInputRef.current.focus();
} else {
setCustomInputValue("");
setisCustomDonation(false);
Expand All @@ -118,12 +121,6 @@ function FundingDonations({ setopenCurrencyModal }: Props): ReactElement {
>
{paymentSetup.options &&
paymentSetup.options.slice(0, 6).map((option, index) => {
console.log(
`option.quantity, quantity`,
option.quantity,
quantity,
option.quantity === quantity
);
return (
<div
key={index}
Expand Down
Loading