Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions pdf-ui/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pdf-ui/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pdf-ui/package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
2 changes: 1 addition & 1 deletion pdf-ui/src/components/CreationGoveranceAction/Step3.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ const Step3 = ({
gutterBottom
data-testid={`amount-${index}-content`}
>
{withdrawal.prop_amount}
{withdrawal.prop_amount}
</Typography>
</Box>
</Box>
Expand Down
209 changes: 112 additions & 97 deletions pdf-ui/src/components/CreationGoveranceAction/WithdrawalsManager.jsx
Original file line number Diff line number Diff line change
@@ -1,71 +1,73 @@
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 = ({
maxWithdrawals = 10,
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 },
],
});
}
};
Expand All @@ -87,79 +89,92 @@ const WithdrawalsManager = ({
};
return (
<Box>
{proposalData?.proposal_withdrawals?.map((withdrawal, index) => (
{proposalData?.proposal_withdrawals?.map((withdrawal, index) => (
<Box
key={index}
display='flex'
flexDirection='row'
mb={2}
backgroundColor={index>0?(theme) => theme.palette.primary.lightGray:""}
backgroundColor={
index > 0
? (theme) => theme.palette.primary.lightGray
: ''
}
position='relative'
>
<Box display='flex' flexDirection='column' flexGrow={1}>
{index === 0 ? null : (
<Box display={'flex'} justifyContent={'flex-end'}>
<IconButton
onClick={() => handleRemoveWithdrawal(index)}
data-testid='withdrawal-wrapper-remove-address-button'
>
<IconX width='16px' height='16px' />
</IconButton>
</Box>
{index === 0 ? null : (
<Box display={'flex'} justifyContent={'flex-end'}>
<IconButton
onClick={() =>
handleRemoveWithdrawal(index)
}
data-testid='withdrawal-wrapper-remove-address-button'
>
<IconX width='16px' height='16px' />
</IconButton>
</Box>
)}

<TextField
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`,
}}
/>
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`,
}}
/>
<TextField
margin='normal'
label={`Amount ${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`,
}}
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`,
}}
/>
</Box>
</Box>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(),
});
}
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1436,6 +1436,7 @@ const SingleGovernanceAction = ({ id }) => {
gutterBottom
data-testid={`amount-${index}-content`}
>
₳{' '}
{
withdrawal.prop_amount
}
Expand Down