diff --git a/src/constants/common.ts b/src/constants/common.ts index 29e3e02ed1..345dba0f27 100644 --- a/src/constants/common.ts +++ b/src/constants/common.ts @@ -1,4 +1,4 @@ -import { EMAIL_SUPPORT } from "./env"; +import { EMAIL_SUPPORT, IS_TEST } from "./env"; export const GENERIC_ERROR_MESSAGE = `An unexpected error occurred and has been reported. Please get in touch with ${EMAIL_SUPPORT} if the problem persists.`; @@ -11,5 +11,6 @@ export const PROCESSING_RATES = { }; export const DONATION_INCREMENTS = [40, 100, 200]; +export const BG_ID = IS_TEST ? 8 : 1; export const logoUrl = (path: string) => `https://nowpayments.io${path}`; diff --git a/src/pages/Admin/Charity/Settings/Form.tsx b/src/pages/Admin/Charity/Settings/Form.tsx index 242dc04aa8..90ccab4917 100644 --- a/src/pages/Admin/Charity/Settings/Form.tsx +++ b/src/pages/Admin/Charity/Settings/Form.tsx @@ -3,6 +3,8 @@ import { yupResolver } from "@hookform/resolvers/yup"; import { DonateMethods, fill } from "components/DonateMethods"; import { LockedSplitSlider } from "components/donation"; import { CheckField, Field, RhfForm } from "components/form"; +import { BG_ID } from "constants/common"; +import { useErrorContext } from "contexts/ErrorContext"; import { useController, useForm } from "react-hook-form"; import { schema, stringNumber } from "schemas/shape"; import type { Endowment, EndowmentSettingsAttributes } from "types/aws"; @@ -19,6 +21,7 @@ const PAYOUT_MIN_USD = 50; export default function Form(props: Props) { const updateEndow = useUpdateEndowment(); + const { displayError } = useErrorContext(); const methods = useForm({ resolver: yupResolver( @@ -82,6 +85,12 @@ export default function Form(props: Props) { donateMethods, ...fv }) => { + if (props.id === BG_ID && fv.hide_bg_tip === false) { + return displayError( + "BG donation flow should not show BG tip screen" + ); + } + await updateEndow({ ...fv, progDonationsAllowed: !programDonateDisabled,