Skip to content

Commit

Permalink
disable submit on invalid file size
Browse files Browse the repository at this point in the history
  • Loading branch information
NickJ202 committed Jul 10, 2024
1 parent 209036b commit ace34fb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/views/Upload/UploadSteps/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const MWrapper = styled.div`
font-size: ${(props) => props.theme.typography.size.xxSmall};
font-weight: ${(props) => props.theme.typography.weight.bold};
border-radius: ${STYLING.dimensions.radius.alt2};
text-align: right;
text-align: center;
display: block;
padding: 2.5px 12.5px;
margin: 0 0 7.5px 0;
Expand Down
11 changes: 11 additions & 0 deletions src/views/Upload/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
DEFAULT_UCM_BANNER,
DEFAULT_UCM_THUMBNAIL,
GATEWAYS,
MAX_UPLOAD_SIZE,
REDIRECTS,
TAGS,
} from 'helpers/config';
Expand Down Expand Up @@ -75,6 +76,16 @@ export default function Upload() {
if (arProvider.walletType) dispatch(uploadActions.setUploadDisabled(arProvider.walletType === 'arweave.app'));
}, [arProvider]);

React.useEffect(() => {
if (uploadReducer.data.contentList.length > 0) {
let disableSubmit = false;
for (const element of uploadReducer.data.contentList) {
if (element.file.size > MAX_UPLOAD_SIZE) disableSubmit = true;
}
dispatch(uploadActions.setUploadDisabled(disableSubmit));
}
}, [uploadReducer.data.contentList]);

React.useEffect(() => {
if (uploadReducer.uploadActive) hideDocumentBody();
else showDocumentBody();
Expand Down

0 comments on commit ace34fb

Please sign in to comment.