Skip to content

Commit

Permalink
Merge pull request #342 from kleros/feat/restrict-upload-sizes-and-no…
Browse files Browse the repository at this point in the history
…tify

feat: restrict file sizes and notify
  • Loading branch information
jaybuidl authored Oct 12, 2024
2 parents c394586 + c0fe720 commit 6364e08
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 20 deletions.
6 changes: 3 additions & 3 deletions src/components/evidence-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
6 changes: 3 additions & 3 deletions src/components/input-selector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ const InputSelector: React.FC<InputSelectorProps> = 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
}

Expand All @@ -112,8 +112,8 @@ const InputSelector: React.FC<InputSelectorProps> = 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
}

Expand Down
6 changes: 3 additions & 3 deletions src/pages/factory-classic/rel-tcr-params.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
8 changes: 4 additions & 4 deletions src/pages/factory-classic/tcr-params.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}, [])
Expand All @@ -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(
Expand Down
6 changes: 3 additions & 3 deletions src/pages/factory/rel-tcr-params.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
8 changes: 4 additions & 4 deletions src/pages/factory/tcr-params.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}, [])
Expand All @@ -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(
Expand Down

0 comments on commit 6364e08

Please sign in to comment.