diff --git a/pdf-ui/CHANGELOG.md b/pdf-ui/CHANGELOG.md index f4ef6ea..d5eaba9 100644 --- a/pdf-ui/CHANGELOG.md +++ b/pdf-ui/CHANGELOG.md @@ -8,6 +8,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 As a minor extension, we also keep a semantic version for the `UNRELEASED` changes. +## [v1.0.12-beta](https://www.npmjs.com/package/@intersect.mbo/pdf-ui/v/1.0.12-beta) 2025-08-08 +- feat: Update Treasury Proposal Amount Field to Accept ADA Instead of Lovelace #4000 + ## [v1.0.11-beta](https://www.npmjs.com/package/@intersect.mbo/pdf-ui/v/1.0.11-beta) 2025-07-31 - feat: Implement proxy data fetching and enhance error handling in InformationStorageStep - feat: Add getViaProxy function to facilitate API requests through the proxy diff --git a/pdf-ui/package-lock.json b/pdf-ui/package-lock.json index 60cabe9..926d1f6 100644 --- a/pdf-ui/package-lock.json +++ b/pdf-ui/package-lock.json @@ -1,6 +1,6 @@ { "name": "@intersect.mbo/pdf-ui", - "version": "1.0.3-beta", + "version": "1.0.12-beta", "lockfileVersion": 3, "requires": true, "packages": { diff --git a/pdf-ui/package.json b/pdf-ui/package.json index 46176b7..64ae969 100644 --- a/pdf-ui/package.json +++ b/pdf-ui/package.json @@ -1,6 +1,6 @@ { "name": "@intersect.mbo/pdf-ui", - "version": "1.0.11-beta", + "version": "1.0.12-beta", "description": "Proposal discussion ui", "main": "./src/index.js", "exports": { diff --git a/pdf-ui/src/components/CreationGoveranceAction/Step3.jsx b/pdf-ui/src/components/CreationGoveranceAction/Step3.jsx index 5fe1924..8b8eccf 100644 --- a/pdf-ui/src/components/CreationGoveranceAction/Step3.jsx +++ b/pdf-ui/src/components/CreationGoveranceAction/Step3.jsx @@ -244,7 +244,7 @@ const Step3 = ({ gutterBottom data-testid={`amount-${index}-content`} > - {withdrawal.prop_amount} + ₳ {withdrawal.prop_amount} diff --git a/pdf-ui/src/components/CreationGoveranceAction/WithdrawalsManager.jsx b/pdf-ui/src/components/CreationGoveranceAction/WithdrawalsManager.jsx index 96c2eb1..4f7f642 100644 --- a/pdf-ui/src/components/CreationGoveranceAction/WithdrawalsManager.jsx +++ b/pdf-ui/src/components/CreationGoveranceAction/WithdrawalsManager.jsx @@ -1,6 +1,6 @@ import { useTheme } from '@emotion/react'; import { IconPlus, IconX } from '@intersect.mbo/intersectmbo.org-icons-set'; -import { Box, Button, TextField,IconButton } from '@mui/material'; +import { Box, Button, TextField, IconButton } from '@mui/material'; import { isRewardAddress, numberValidation } from '../../lib/utils'; const WithdrawalsManager = ({ @@ -8,64 +8,66 @@ const WithdrawalsManager = ({ proposalData, setProposalData, withdrawalsErrors, - setWithdrawalsErrors - + setWithdrawalsErrors, }) => { const theme = useTheme(); const handleWithdrawalChange = async (index, field, value) => { - const newWithdrawal = proposalData?.proposal_withdrawals?.map((proposal_withdrawal, i) => { + const newWithdrawal = proposalData?.proposal_withdrawals?.map( + (proposal_withdrawal, i) => { if (i === index) { return { ...proposal_withdrawal, [field]: value }; } return proposal_withdrawal; - }); - setProposalData({ - ...proposalData, - proposal_withdrawals: newWithdrawal, - }); - // If the prop_receiving_address is empty, remove the error - if (field === 'prop_' && value === '') { - return setWithdrawalsErrors((prev) => { - const { [index]: removed, ...rest } = prev; - return rest; - }); } - // Validate prop_receiving_address - - if (field === 'prop_receiving_address') { + ); + setProposalData({ + ...proposalData, + proposal_withdrawals: newWithdrawal, + }); + // If the prop_receiving_address is empty, remove the error + if (field === 'prop_' && value === '') { + return setWithdrawalsErrors((prev) => { + const { [index]: removed, ...rest } = prev; + return rest; + }); + } + // Validate prop_receiving_address + + if (field === 'prop_receiving_address') { const validationResult = await isRewardAddress(value); setWithdrawalsErrors((prev) => ({ ...prev, [index]: { ...prev[index], - prop_receiving_address: validationResult===true ? '' : validationResult, + prop_receiving_address: + validationResult === true ? '' : validationResult, }, })); - } - // To DO add validation for registered stake address - - if (field === 'prop_amount') { - const validationResult = numberValidation(value); - setWithdrawalsErrors((prev) => ({ - ...prev, - [index]: { - ...prev[index], - prop_amount: validationResult===true ? '' : validationResult, - }, - })); - } - - }; + } + // To DO add validation for registered stake address + if (field === 'prop_amount') { + const validationResult = numberValidation(value); + setWithdrawalsErrors((prev) => ({ + ...prev, + [index]: { + ...prev[index], + prop_amount: + validationResult === true ? '' : validationResult, + }, + })); + } + }; const handleAddWithdrawal = () => { if (proposalData?.proposal_withdrawals?.length < maxWithdrawals) { setProposalData({ ...proposalData, proposal_withdrawals: [ - ...proposalData?.proposal_withdrawals, { prop_receiving_address: null, prop_amount: null }, - ], + ...proposalData?.proposal_withdrawals, + { prop_receiving_address: null, prop_amount: null }, + ], }); } }; @@ -87,79 +89,92 @@ const WithdrawalsManager = ({ }; return ( - {proposalData?.proposal_withdrawals?.map((withdrawal, index) => ( + {proposalData?.proposal_withdrawals?.map((withdrawal, index) => ( 0?(theme) => theme.palette.primary.lightGray:""} + backgroundColor={ + index > 0 + ? (theme) => theme.palette.primary.lightGray + : '' + } position='relative' > - {index === 0 ? null : ( - - handleRemoveWithdrawal(index)} - data-testid='withdrawal-wrapper-remove-address-button' - > - - - + {index === 0 ? null : ( + + + handleRemoveWithdrawal(index) + } + data-testid='withdrawal-wrapper-remove-address-button' + > + + + )} { - handleWithdrawalChange( - index, - 'prop_receiving_address', - e.target.value - )}} - required - inputProps={{ - 'data-testid': `receiving-address-${index}-text-input`, - }} - error={!!withdrawalsErrors[index]?.prop_receiving_address} - helperText={withdrawalsErrors[index]?.prop_receiving_address} - FormHelperTextProps={{ - sx: { - backgroundColor: 'transparent', - }, - 'data-testid': `receiving-address-${index}-text-error`, - }} - /> + margin='normal' + label={`Receiving stake address ${index + 1}`} + variant='outlined' + placeholder='e.g. stake1...' + value={withdrawal.prop_receiving_address || ''} + fullWidth + onChange={(e) => { + handleWithdrawalChange( + index, + 'prop_receiving_address', + e.target.value + ); + }} + required + inputProps={{ + 'data-testid': `receiving-address-${index}-text-input`, + }} + error={ + !!withdrawalsErrors[index] + ?.prop_receiving_address + } + helperText={ + withdrawalsErrors[index]?.prop_receiving_address + } + FormHelperTextProps={{ + sx: { + backgroundColor: 'transparent', + }, + 'data-testid': `receiving-address-${index}-text-error`, + }} + /> - handleWithdrawalChange( - index, - 'prop_amount', - e.target.value - )} - required - inputProps={{ - 'data-testid': `amount-${index}-text-input`, - }} - error={!!withdrawalsErrors[index]?.prop_amount} - helperText={withdrawalsErrors[index]?.prop_amount} - FormHelperTextProps={{ - sx: { - backgroundColor: 'transparent', - }, - 'data-testid': `amount-${index}-text-error`, - }} + margin='normal' + label={`Amount (in ada) - ${index + 1}`} + type='tel' + variant='outlined' + placeholder='e.g. 2000 ada' + value={withdrawal?.prop_amount || ''} + fullWidth + onChange={(e) => + handleWithdrawalChange( + index, + 'prop_amount', + e.target.value + ) + } + required + inputProps={{ + 'data-testid': `amount-${index}-text-input`, + }} + error={!!withdrawalsErrors[index]?.prop_amount} + helperText={withdrawalsErrors[index]?.prop_amount} + FormHelperTextProps={{ + sx: { + backgroundColor: 'transparent', + }, + 'data-testid': `amount-${index}-text-error`, + }} /> diff --git a/pdf-ui/src/components/SubmissionGovernanceAction/Steps/InformationStorageStep.jsx b/pdf-ui/src/components/SubmissionGovernanceAction/Steps/InformationStorageStep.jsx index 173b4f4..4ee8528 100644 --- a/pdf-ui/src/components/SubmissionGovernanceAction/Steps/InformationStorageStep.jsx +++ b/pdf-ui/src/components/SubmissionGovernanceAction/Steps/InformationStorageStep.jsx @@ -141,6 +141,10 @@ const InformationStorageStep = ({ proposal, handleCloseSubmissionDialog }) => { url: fileURL, withdrawals: getWithdrawalsArray(), }); + console.log( + '🚀 ~ handleGASubmission ~ govActionBuilder:', + govActionBuilder + ); } else if (parseInt(proposalGATypeId) === 3) { const constitUrl = proposal?.attributes?.content?.attributes @@ -230,7 +234,7 @@ const InformationStorageStep = ({ proposal, handleCloseSubmissionDialog }) => { (withdrawal) => { withdrawalsArray.push({ receivingAddress: withdrawal.prop_receiving_address, - amount: withdrawal.prop_amount.toString(), + amount: (withdrawal.prop_amount * 1000000).toString(), }); } ); diff --git a/pdf-ui/src/pages/ProposedGovernanceActions/SingleGovernanceAction/index.jsx b/pdf-ui/src/pages/ProposedGovernanceActions/SingleGovernanceAction/index.jsx index fc359fa..694ed10 100644 --- a/pdf-ui/src/pages/ProposedGovernanceActions/SingleGovernanceAction/index.jsx +++ b/pdf-ui/src/pages/ProposedGovernanceActions/SingleGovernanceAction/index.jsx @@ -1436,6 +1436,7 @@ const SingleGovernanceAction = ({ id }) => { gutterBottom data-testid={`amount-${index}-content`} > + ₳{' '} { withdrawal.prop_amount }