Skip to content

Commit

Permalink
remove payout min settings
Browse files Browse the repository at this point in the history
  • Loading branch information
ap-justin committed Sep 3, 2024
1 parent df489dc commit 12e7771
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 39 deletions.
36 changes: 3 additions & 33 deletions src/pages/Admin/Charity/Settings/Form.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { ErrorMessage } from "@hookform/error-message";
import { yupResolver } from "@hookform/resolvers/yup";
import { DonateMethods, fill, order } from "components/DonateMethods";
import { CheckField, Field, Form as _Form } from "components/form";
import { CheckField, Form as _Form } from "components/form";
import { useController, useForm } from "react-hook-form";
import { schema, stringNumber } from "schemas/shape";
import { schema } from "schemas/shape";
import type { Endowment, EndowmentSettingsAttributes } from "types/aws";
import type { TDonateMethod } from "types/components";
import { array, string } from "yup";
Expand All @@ -14,7 +14,6 @@ import { MAX_RECEIPT_MSG_CHAR } from "./constants";
import type { FV } from "./types";

type Props = Pick<Endowment, "id" | EndowmentSettingsAttributes>;
const PAYOUT_MIN_USD = 50;

export default function Form(props: Props) {
const updateEndow = useUpdateEndowment();
Expand All @@ -23,10 +22,6 @@ export default function Form(props: Props) {
resolver: yupResolver(
schema<FV>({
receiptMsg: string().max(MAX_RECEIPT_MSG_CHAR, "exceeds max"),
payout_minimum: stringNumber(
(s) => s.required("required"),
(n) => n.min(PAYOUT_MIN_USD, `must be greater than ${PAYOUT_MIN_USD}`)
),
donateMethods: array().test(
"",
"at least one payment option should be active",
Expand All @@ -41,7 +36,6 @@ export default function Form(props: Props) {
sfCompounded: props.sfCompounded ?? false,
hide_bg_tip: props.hide_bg_tip ?? false,
programDonateDisabled: !(props.progDonationsAllowed ?? true),
payout_minimum: `${props.payout_minimum ?? 50}`,
donateMethods: fill(props.donateMethods),
},
});
Expand All @@ -68,20 +62,14 @@ export default function Form(props: Props) {
reset();
}}
onSubmit={handleSubmit(
async ({
programDonateDisabled,
payout_minimum,
donateMethods: dms,
...fv
}) => {
async ({ programDonateDisabled, donateMethods: dms, ...fv }) => {
const ordered = order(dms);
const ids = ordered.filter((m) => !m.disabled).map((m) => m.id);

await updateEndow({
...fv,
progDonationsAllowed: !programDonateDisabled,
id: props.id,
payout_minimum: +payout_minimum,
donateMethods: order(ids),
});

Expand Down Expand Up @@ -126,24 +114,6 @@ export default function Form(props: Props) {

<HideBGTipCheckbox />

<Field
placeholder={`$${PAYOUT_MIN_USD}`}
required
name="payout_minimum"
label="Payout Minimum"
classes={{
label: "font-medium text-base",
}}
tooltip={
<span className="text-navy-l1 text-sm italic">
Minimum amount of funds your current account must reach before
triggering a Payout to your Nonprofit's connected Bank Account. For
example, it can be useful to reduce the total number of payments
made if the receiving bank charges a fee per deposit transaction.
</span>
}
/>

<h5 className="mt-12 text-2xl">Marketplace settings</h5>

<DonateMethods
Expand Down
1 change: 0 additions & 1 deletion src/pages/Admin/Charity/Settings/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ export default function Settings() {
"sfCompounded",
"hide_bg_tip",
"progDonationsAllowed",
"payout_minimum",
"donateMethods",
]);

Expand Down
3 changes: 0 additions & 3 deletions src/pages/Admin/Charity/Settings/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,5 @@ export type FV = {
hide_bg_tip: boolean;
sfCompounded: boolean;
programDonateDisabled: boolean;

/** in USD */
payout_minimum: string;
donateMethods: TDonateMethod[];
};
2 changes: 0 additions & 2 deletions src/types/aws/ap/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ export type Endowment = {
published?: boolean;
/** allowed by default */
progDonationsAllowed?: boolean;
payout_minimum?: number;
donateMethods?: DonateMethodId[];
};

Expand Down Expand Up @@ -160,7 +159,6 @@ export type EndowmentSettingsAttributes = Extract<
| "sfCompounded"
| "hide_bg_tip"
| "progDonationsAllowed"
| "payout_minimum"
| "donateMethods"
>;
//most are optional except id, but typed as required to force setting of default values - "", [], etc ..
Expand Down

0 comments on commit 12e7771

Please sign in to comment.