From 5541e553c58a951497be1ca76f1f8e518325668c Mon Sep 17 00:00:00 2001 From: Ani Date: Wed, 24 Jul 2024 13:39:29 +0300 Subject: [PATCH] Update positive amount error message on Admin panel forms (#1889) Co-authored-by: ani-kalpachka --- src/components/admin/campaigns/grid/CreateForm.tsx | 2 +- src/components/admin/campaigns/grid/EditForm.tsx | 2 +- src/components/admin/expenses/Form.tsx | 4 ++-- src/components/admin/recurring-donation/Form.tsx | 2 +- src/components/admin/transfers/CreateForm.tsx | 2 +- src/components/admin/withdrawals/CreateForm.tsx | 4 ++-- src/components/admin/withdrawals/EditForm.tsx | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/components/admin/campaigns/grid/CreateForm.tsx b/src/components/admin/campaigns/grid/CreateForm.tsx index f4251a089..5432a7ae0 100644 --- a/src/components/admin/campaigns/grid/CreateForm.tsx +++ b/src/components/admin/campaigns/grid/CreateForm.tsx @@ -66,7 +66,7 @@ const validationSchema: yup.SchemaOf = yup title: yup.string().trim().min(10).max(200).required(), slug: yup.string().trim().min(10).max(200).optional(), description: yup.string().trim().min(50).max(60000).required(), - targetAmount: yup.number().integer().positive().required(), + targetAmount: yup.number().integer().positive('validation:positive-amount').required(), allowDonationOnComplete: yup.bool().optional(), campaignTypeId: yup.string().uuid().required(), beneficiaryId: yup.string().uuid().required(), diff --git a/src/components/admin/campaigns/grid/EditForm.tsx b/src/components/admin/campaigns/grid/EditForm.tsx index 82f56f33a..431325513 100644 --- a/src/components/admin/campaigns/grid/EditForm.tsx +++ b/src/components/admin/campaigns/grid/EditForm.tsx @@ -69,7 +69,7 @@ const validationSchema: yup.SchemaOf title: yup.string().trim().min(10).max(200).required(), slug: yup.string().trim().min(10).max(200).required(), description: yup.string().trim().min(50).required(), - targetAmount: yup.number().integer().positive().required(), + targetAmount: yup.number().integer().positive('validation:positive-amount').required(), allowDonationOnComplete: yup.bool().optional(), campaignTypeId: yup.string().uuid().required(), beneficiaryId: yup.string().required(), diff --git a/src/components/admin/expenses/Form.tsx b/src/components/admin/expenses/Form.tsx index 939ba0849..41ba887c8 100644 --- a/src/components/admin/expenses/Form.tsx +++ b/src/components/admin/expenses/Form.tsx @@ -51,7 +51,7 @@ export default function Form() { is: (value: string) => value !== undefined, then: yup .number() - .positive() + .positive('validation:positive-amount') .required() .test({ name: 'max', @@ -66,7 +66,7 @@ export default function Form() { return value < Number(currentAmount) }, }), - otherwise: yup.number().positive().integer().required(), + otherwise: yup.number().positive('validation:positive-amount').integer().required(), }), vaultId: yup.string().trim().uuid().required(), deleted: yup.boolean().required(), diff --git a/src/components/admin/recurring-donation/Form.tsx b/src/components/admin/recurring-donation/Form.tsx index 30d5df074..2c1cf4264 100644 --- a/src/components/admin/recurring-donation/Form.tsx +++ b/src/components/admin/recurring-donation/Form.tsx @@ -38,7 +38,7 @@ const validationSchema = yup personId: yup.string().trim().uuid().required(), extSubscriptionId: yup.string().trim().required(), extCustomerId: yup.string().trim().required(), - money: yup.number().min(0).positive().required(), + money: yup.number().min(0).positive('validation:positive-amount').required(), currency: yup.string().oneOf(validCurrencies).required(), sourceVault: yup.string().trim().uuid().required(), }) diff --git a/src/components/admin/transfers/CreateForm.tsx b/src/components/admin/transfers/CreateForm.tsx index e72aac80a..763b5e79a 100644 --- a/src/components/admin/transfers/CreateForm.tsx +++ b/src/components/admin/transfers/CreateForm.tsx @@ -57,7 +57,7 @@ export default function CreateForm({ campaigns }: Props) { is: (value: string) => value !== undefined, then: yup .number() - .positive() + .positive('validation:positive-amount') .required() .test({ name: 'max', diff --git a/src/components/admin/withdrawals/CreateForm.tsx b/src/components/admin/withdrawals/CreateForm.tsx index da0af9a8c..9e980042d 100644 --- a/src/components/admin/withdrawals/CreateForm.tsx +++ b/src/components/admin/withdrawals/CreateForm.tsx @@ -41,7 +41,7 @@ export default function CreateForm() { is: (value: string) => value !== undefined, then: yup .number() - .positive() + .positive('validation:positive-amount') .required() .test({ name: 'max', @@ -55,7 +55,7 @@ export default function CreateForm() { return Number(value) < Number(fromMoney(currentAmount)) }, }), - otherwise: yup.number().positive().integer().required(), + otherwise: yup.number().positive('validation:positive-amount').integer().required(), }), reason: yup.string().trim().min(1).max(300).required(), targetDate: yup.date().required(), diff --git a/src/components/admin/withdrawals/EditForm.tsx b/src/components/admin/withdrawals/EditForm.tsx index 2c1e4e06f..61e80104b 100644 --- a/src/components/admin/withdrawals/EditForm.tsx +++ b/src/components/admin/withdrawals/EditForm.tsx @@ -47,7 +47,7 @@ const validationSchema: yup.SchemaOf = yup .defined() .shape({ status: yup.string().trim().min(1).max(10).required(), - amount: yup.number().positive().required(), + amount: yup.number().positive('validation:positive-amount').required(), reason: yup.string().trim().min(1).max(300).required(), currency: yup.string().oneOf(Object.values(Currency)).required(), sourceVaultId: yup.string().uuid().required(),