From c0fe720e4ce3f8b553b1929a0adeda88cf03fd10 Mon Sep 17 00:00:00 2001 From: kemuru <102478601+kemuru@users.noreply.github.com> Date: Thu, 10 Oct 2024 15:30:50 +0200 Subject: [PATCH] feat: restrict file sizes and notify --- src/components/evidence-form.js | 6 +++--- src/components/input-selector.tsx | 6 +++--- src/pages/factory-classic/rel-tcr-params.js | 6 +++--- src/pages/factory-classic/tcr-params.js | 8 ++++---- src/pages/factory/rel-tcr-params.js | 6 +++--- src/pages/factory/tcr-params.js | 8 ++++---- 6 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/components/evidence-form.js b/src/components/evidence-form.js index d11e1a0..7f30796 100644 --- a/src/components/evidence-form.js +++ b/src/components/evidence-form.js @@ -81,9 +81,9 @@ const EvidenceForm = ({ } const beforeFileUpload = useCallback(file => { - const isLt10M = file.size / 1024 / 1024 < 15 - if (!isLt10M) message.error('File must smaller than 15MB.') - return isLt10M + const isLt4M = file.size / 1024 / 1024 < 4 + if (!isLt4M) message.error('File must be smaller than 4MB.') + return isLt4M }, []) return ( diff --git a/src/components/input-selector.tsx b/src/components/input-selector.tsx index 072673c..ff95853 100644 --- a/src/components/input-selector.tsx +++ b/src/components/input-selector.tsx @@ -91,7 +91,7 @@ const InputSelector: React.FC = p => { } if (file.size / 1024 / 1024 > (p.maxFileSizeMb || 2)) { - message.error(`Image must smaller than ${p.maxFileSizeMb || 2}MB.`) + message.error(`Image must be smaller than ${p.maxFileSizeMb || 2}MB.`) return false } @@ -112,8 +112,8 @@ const InputSelector: React.FC = p => { return false } - if (file.size / 1024 / 1024 > (p.maxFileSizeMb || 10)) { - message.error(`File must smaller than ${p.maxFileSizeMb || 10}MB.`) + if (file.size / 1024 / 1024 > (p.maxFileSizeMb || 4)) { + message.error(`File must be smaller than ${p.maxFileSizeMb || 4}MB.`) return false } diff --git a/src/pages/factory-classic/rel-tcr-params.js b/src/pages/factory-classic/rel-tcr-params.js index fd5675d..97c20ca 100644 --- a/src/pages/factory-classic/rel-tcr-params.js +++ b/src/pages/factory-classic/rel-tcr-params.js @@ -126,10 +126,10 @@ const RelTCRParams = ({ const isPDF = file.type === 'application/pdf' if (!isPDF) message.error('Please upload file as PDF.') - const isLt10M = file.size / 1024 / 1024 < 10 - if (!isLt10M) message.error('File must smaller than 10MB.') + const isLt4M = file.size / 1024 / 1024 < 4 + if (!isLt4M) message.error('File must be smaller than 4MB.') - return isPDF && isLt10M + return isPDF && isLt4M }, []) const onChangeDepositVal = useCallback( diff --git a/src/pages/factory-classic/tcr-params.js b/src/pages/factory-classic/tcr-params.js index 615b958..93b13b8 100644 --- a/src/pages/factory-classic/tcr-params.js +++ b/src/pages/factory-classic/tcr-params.js @@ -135,7 +135,7 @@ const TCRParams = ({ if (!isSupportedImage) message.error('Please use PNG, jpeg, webp or SVG.') const isLt2M = file.size / 1024 / 1024 < 2 - if (!isLt2M) message.error('Image must smaller than 2MB.') + if (!isLt2M) message.error('Image must be smaller than 2MB.') return isSupportedImage && isLt2M }, []) @@ -144,10 +144,10 @@ const TCRParams = ({ const isPDF = file.type === 'application/pdf' if (!isPDF) message.error('Please upload file as PDF.') - const isLt10M = file.size / 1024 / 1024 < 10 - if (!isLt10M) message.error('File must smaller than 10MB.') + const isLt4M = file.size / 1024 / 1024 < 4 + if (!isLt4M) message.error('File must be smaller than 4MB.') - return isPDF && isLt10M + return isPDF && isLt4M }, []) const customRequest = useCallback( diff --git a/src/pages/factory/rel-tcr-params.js b/src/pages/factory/rel-tcr-params.js index be16f3f..62338d8 100644 --- a/src/pages/factory/rel-tcr-params.js +++ b/src/pages/factory/rel-tcr-params.js @@ -126,10 +126,10 @@ const RelTCRParams = ({ const isPDF = file.type === 'application/pdf' if (!isPDF) message.error('Please upload file as PDF.') - const isLt10M = file.size / 1024 / 1024 < 10 - if (!isLt10M) message.error('File must smaller than 10MB.') + const isLt4M = file.size / 1024 / 1024 < 4 + if (!isLt4M) message.error('File must be smaller than 4MB.') - return isPDF && isLt10M + return isPDF && isLt4M }, []) const onChangeDepositVal = useCallback( diff --git a/src/pages/factory/tcr-params.js b/src/pages/factory/tcr-params.js index dc5bf54..4102957 100644 --- a/src/pages/factory/tcr-params.js +++ b/src/pages/factory/tcr-params.js @@ -192,7 +192,7 @@ const TCRParams = ({ if (!isSupportedImage) message.error('Please use PNG, webp, jpeg or SVG.') const isLt2M = file.size / 1024 / 1024 < 2 - if (!isLt2M) message.error('Image must smaller than 2MB.') + if (!isLt2M) message.error('Image must be smaller than 2MB.') return isSupportedImage && isLt2M }, []) @@ -201,10 +201,10 @@ const TCRParams = ({ const isPDF = file.type === 'application/pdf' if (!isPDF) message.error('Please upload file as PDF.') - const isLt10M = file.size / 1024 / 1024 < 10 - if (!isLt10M) message.error('File must smaller than 10MB.') + const isLt4M = file.size / 1024 / 1024 < 4 + if (!isLt4M) message.error('File must be smaller than 4MB.') - return isPDF && isLt10M + return isPDF && isLt4M }, []) const customRequest = useCallback(