From ab40a035cde753ee76dacda329f44dd8161d5f53 Mon Sep 17 00:00:00 2001 From: Peter Muriuki Date: Thu, 5 Dec 2024 11:12:28 +0300 Subject: [PATCH] Remove placeholder messages and internationalize --- .../src/components/ProductForm/utils.tsx | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/packages/fhir-group-management/src/components/ProductForm/utils.tsx b/packages/fhir-group-management/src/components/ProductForm/utils.tsx index 33b465726..1d16c83e8 100644 --- a/packages/fhir-group-management/src/components/ProductForm/utils.tsx +++ b/packages/fhir-group-management/src/components/ProductForm/utils.tsx @@ -44,12 +44,12 @@ export const normalizeFileInputEvent = (e: UploadChangeParam) => { return e.fileList; }; -const validateFile = (_: unknown, fileList: UploadFile[] | undefined) => { +const validateFileFactory = (t: TFunction) => (_: unknown, fileList: UploadFile[] | undefined) => { if (fileList && fileList.length > 0) { const file = fileList[0].originFileObj; const MAX_IMAGE_SIZE_MB = 5; if (file && file.size / 1024 / 1024 > MAX_IMAGE_SIZE_MB) { - return Promise.reject(new Error('File must be smaller than 5MB!')); + return Promise.reject(new Error(t('File must be smaller than 5MB!'))); } } @@ -77,10 +77,9 @@ export function defaultValidationRulesFactory(t: TFunction) { [appropriateUsage]: [{ type: 'string' }] as Rule[], [accountabilityPeriod]: [{ type: 'number' }] as Rule[], [productImage]: [ - { type: 'array', max: 1, message: 'Some message about an array' }, + { type: 'array', max: 1 }, { - validator: validateFile, - message: 'Some message about a', + validator: validateFileFactory(t), }, ] as Rule[], };