Skip to content

Commit

Permalink
feat: add "charge submitter" checkbox.
Browse files Browse the repository at this point in the history
  • Loading branch information
gdethier committed May 30, 2024
1 parent 40626fa commit 9527bd9
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 22 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
"license": "Apache-2.0",
"dependencies": {
"@creativecommons/cc-assets": "^0.1.0",
"@logion/client": "^0.45.0-11",
"@logion/client": "^0.45.0-12",
"@logion/client-browser": "^0.3.5",
"@logion/crossmint": "^0.1.32",
"@logion/extension": "^0.8.1-1",
"@logion/extension": "^0.8.1",
"@logion/multiversx": "^0.1.13",
"@multiversx/sdk-extension-provider": "^2.0.7",
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.3",
Expand Down
38 changes: 33 additions & 5 deletions src/loc/record/AddTokensRecordDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ interface FormValues {
fileName: string;
contentType: string;
description: string;
chargeSubmitter: boolean;
}

type Status = 'Idle' | 'Hashing' | 'Confirming' | 'Uploading' | 'Error';
Expand All @@ -33,7 +34,11 @@ export default function AddTokensRecordDialog(props: Props) {
const { colorTheme } = useCommonContext();
const { mutateLocState, locState } = useLocContext();
const { signer, submitCall, clearSubmissionState } = useLogionChain();
const { control, handleSubmit, formState: { errors }, reset, setValue, getValues } = useForm<FormValues>();
const { control, handleSubmit, formState: { errors }, reset, setValue, getValues, clearErrors } = useForm<FormValues>({
defaultValues: {
chargeSubmitter: false,
}
});
const [ file, setFile ] = useState<File>();
const [ uploadError, setUploadError ] = useState<string>();
const [ status, setStatus ] = useState<Status>('Idle');
Expand All @@ -44,7 +49,8 @@ export default function AddTokensRecordDialog(props: Props) {
setFile(file);
setValue("fileName", file.name);
setValue("contentType", file.type);
}, [ setValue ]);
clearErrors();
}, [ setValue, clearErrors ]);

const onError = useCallback((error?: string) => {
setStatus('Error');
Expand Down Expand Up @@ -168,7 +174,7 @@ export default function AddTokensRecordDialog(props: Props) {
name="fileName"
control={ control }
defaultValue=""
rules={ { maxLength: 255, required: true } }
rules={ { maxLength: 255, required: "Missing file name" } }
render={ ({ field }) => (
<Form.Control
isInvalid={ !!errors.fileName?.message }
Expand All @@ -180,6 +186,7 @@ export default function AddTokensRecordDialog(props: Props) {
) } />

}
feedback={ errors.fileName?.message }
colors={ colorTheme.dialog }
/>
<FormGroup
Expand All @@ -190,7 +197,7 @@ export default function AddTokensRecordDialog(props: Props) {
name="contentType"
control={ control }
defaultValue=""
rules={ { maxLength: 255, required: true } }
rules={ { maxLength: 255, required: "Missing content type" } }
render={ ({ field }) => (
<Form.Control
isInvalid={ !!errors.contentType?.message }
Expand All @@ -202,6 +209,7 @@ export default function AddTokensRecordDialog(props: Props) {
) } />

}
feedback={ errors.contentType?.message }
colors={ colorTheme.dialog }
/>
<FormGroup
Expand All @@ -212,7 +220,7 @@ export default function AddTokensRecordDialog(props: Props) {
name="description"
control={ control }
defaultValue=""
rules={ { maxLength: 4096, required: true } }
rules={ { maxLength: 4096, required: "Missing public descripition" } }
render={ ({ field }) => (
<Form.Control
isInvalid={ !!errors.description?.message }
Expand All @@ -223,6 +231,26 @@ export default function AddTokensRecordDialog(props: Props) {
) } />

}
feedback={ errors.description?.message }
colors={ colorTheme.dialog }
/>
<FormGroup
id="chargeSubmitter"
label="All fees charged to the submitter"
control={
<Controller
name="chargeSubmitter"
control={ control }
render={ ({ field }) => (
<Form.Check
isInvalid={ !!errors.chargeSubmitter?.message }
aria-describedby="chargeSubmitter"
{ ...field }
value={ field.value ? "checked" : "" } // Fixes typing issue
/>
) } />
}
feedback={ errors.chargeSubmitter?.message }
colors={ colorTheme.dialog }
/>
{ status === 'Hashing' &&
Expand Down
30 changes: 15 additions & 15 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3216,15 +3216,15 @@ __metadata:
languageName: node
linkType: hard

"@logion/client@npm:^0.45.0-11":
version: 0.45.0-11
resolution: "@logion/client@npm:0.45.0-11"
"@logion/client@npm:^0.45.0-12":
version: 0.45.0-12
resolution: "@logion/client@npm:0.45.0-12"
dependencies:
"@logion/node-api": ^0.30.0
"@logion/node-api": ^0.31.0-1
axios: ^1.6.7
luxon: ^3.4.4
mime-db: ^1.52.0
checksum: de3a57af11603beb5a1384c96cb679b1e0a55023f7908623e433f3da7acd075cd8fe79bd52fa5c22995cb55b2e8f8400e711ada217ed9f8f010172ce12ca5aaf
checksum: df543a9e5494d47a7a539434fb14d9d6e88808ed82d34c559495233581b164a1f13bbcef84289f27f122388bdd968e4db9b8ca8eb734c0bf42883c6ab72c5f89
languageName: node
linkType: hard

Expand All @@ -3239,15 +3239,15 @@ __metadata:
languageName: node
linkType: hard

"@logion/extension@npm:^0.8.1-1":
version: 0.8.1-1
resolution: "@logion/extension@npm:0.8.1-1"
"@logion/extension@npm:^0.8.1":
version: 0.8.1
resolution: "@logion/extension@npm:0.8.1"
dependencies:
"@polkadot/extension-compat-metamask": ^0.47.3
"@polkadot/extension-dapp": ^0.47.3
peerDependencies:
"@logion/client-browser": 0.x
checksum: 4a6bb518cd5cdb6c15862c1df492701e33c4be6bff97131e42efe4a6e4c6912d180c5641f23e7722be5c25dba472d70631fef3e5b17f3d1f63e515b26ff3bf07
checksum: 90fe261872b8c807c70e7f2839139b83d2b44284c44b4b4fbde5d10ac580c2e995bb7674dab015cde6418c39407c02927510dbcc8c86c33de82f38b0581ef437
languageName: node
linkType: hard

Expand All @@ -3263,9 +3263,9 @@ __metadata:
languageName: node
linkType: hard

"@logion/node-api@npm:^0.30.0":
version: 0.30.0
resolution: "@logion/node-api@npm:0.30.0"
"@logion/node-api@npm:^0.31.0-1":
version: 0.31.0-1
resolution: "@logion/node-api@npm:0.31.0-1"
dependencies:
"@polkadot/api": ^11.0.2
"@polkadot/util": ^12.6.2
Expand All @@ -3274,7 +3274,7 @@ __metadata:
bech32: ^2.0.0
fast-sha256: ^1.3.0
uuid: ^9.0.0
checksum: 3499cf24a63d9331be073aa9429c3df9e2109b6ea5d7087f8fc32cca5547c525c07d9eeb78eabe7d1e2df25d9fecd382820af33b7151dc3dde7e77e3344804b6
checksum: 44051de5dbb2ecb1b4e2ea00cee7105c679d460ad25bde65b7b2726379a4fcb7770a52061ee1982530e0690b114016e1a5a9d456627e7f613ab70f23fb233965
languageName: node
linkType: hard

Expand Down Expand Up @@ -12106,10 +12106,10 @@ __metadata:
"@babel/preset-react": ^7.23.3
"@babel/preset-typescript": ^7.23.3
"@creativecommons/cc-assets": ^0.1.0
"@logion/client": ^0.45.0-11
"@logion/client": ^0.45.0-12
"@logion/client-browser": ^0.3.5
"@logion/crossmint": ^0.1.32
"@logion/extension": ^0.8.1-1
"@logion/extension": ^0.8.1
"@logion/multiversx": ^0.1.13
"@multiversx/sdk-extension-provider": ^2.0.7
"@pmmmwh/react-refresh-webpack-plugin": ^0.5.3
Expand Down

0 comments on commit 9527bd9

Please sign in to comment.