Skip to content

Commit

Permalink
fix: update desmos proposals type display [web-desmos] (#1310)
Browse files Browse the repository at this point in the history
## Description

Closes: #XXXX



---

### Author Checklist

_All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues._

I have...

- [x] ran linting via `yarn lint`
- [x] wrote tests where necessary
- [x] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title
- [x] targeted the correct branch
- [x] provided a link to the relevant issue or specification
- [x] reviewed "Files changed" and left comments if necessary
- [x] confirmed all CI checks have passed
- [x] added a changeset via [`yarn && yarn changeset`](https://github.com/changesets/changesets/blob/main/docs/adding-a-changeset.md)
  • Loading branch information
MonikaCat authored Nov 1, 2023
1 parent 4037aca commit 3b7f63b
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 43 deletions.
5 changes: 5 additions & 0 deletions .changeset/cuddly-turtles-search.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'web-desmos': major
---

update desmos proposals type display
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,14 @@ const Overview: FC<{ className?: string; overview: OverviewType }> = ({ classNam
const { classes, cx } = useStyles();
const { t } = useAppTranslation('proposals');

const type =
R.pathOr('', [0, '@type'], overview.content) === ''
? getProposalType(R.pathOr('', ['@type'], overview.content))
: getProposalType(R.pathOr('', [0, '@type'], overview.content));
const types: string[] = [];
if (Array.isArray(overview.content)) {
overview.content.forEach((type: string) => {
types.push(getProposalType(R.pathOr('', ['@type'], type)));
});
} else {
types.push(getProposalType(R.pathOr('', ['@type'], overview.content)));
}

const { address: proposerAddress, name: proposerName } = useProfileRecoil(overview.proposer);
const { name: recipientName } = useProfileRecoil(overview?.content?.recipient);
Expand All @@ -47,45 +51,49 @@ const Overview: FC<{ className?: string; overview: OverviewType }> = ({ classNam

const getExtraDetails = useCallback(() => {
let extraDetails = null;
if (type === 'parameterChangeProposal') {
extraDetails = (
<>
<Typography variant="body1" className="label">
{t('changes')}
</Typography>
<ParamsChange changes={R.pathOr([], ['changes'], overview.content)} />
</>
);
} else if (type === 'softwareUpgradeProposal') {
extraDetails = (
<>
<Typography variant="body1" className="label">
{t('plan')}
</Typography>
<SoftwareUpgrade
height={R.pathOr('0', ['plan', 'height'], overview.content)}
info={R.pathOr('', ['plan', 'info'], overview.content)}
name={R.pathOr('', ['plan', 'name'], overview.content)}
/>
</>
);
} else if (type === 'communityPoolSpendProposal') {
extraDetails = (
<>
<Typography variant="body1" className="label">
{t('content')}
</Typography>
<CommunityPoolSpend
recipient={overview?.content?.recipient}
recipientMoniker={recipientMoniker}
amountRequested={parsedAmountRequested}
/>
</>
);
}
types.forEach((type: string) => {
if (type === 'parameterChangeProposal') {
extraDetails = (
<>
<Typography variant="body1" className="label">
{t('changes')}
</Typography>
<ParamsChange changes={R.pathOr([], ['changes'], overview.content)} />
</>
);
}
if (type === 'softwareUpgradeProposal') {
extraDetails = (
<>
<Typography variant="body1" className="label">
{t('plan')}
</Typography>
<SoftwareUpgrade
height={R.pathOr('0', ['plan', 'height'], overview.content)}
info={R.pathOr('', ['plan', 'info'], overview.content)}
name={R.pathOr('', ['plan', 'name'], overview.content)}
/>
</>
);
}
if (type === 'communityPoolSpendProposal') {
extraDetails = (
<>
<Typography variant="body1" className="label">
{t('content')}
</Typography>
<CommunityPoolSpend
recipient={overview?.content?.recipient}
recipientMoniker={recipientMoniker}
amountRequested={parsedAmountRequested}
/>
</>
);
}
});

return extraDetails;
}, [overview.content, parsedAmountRequested, recipientMoniker, t, type]);
}, [overview.content, parsedAmountRequested, recipientMoniker, t, types]);

const extra = getExtraDetails();

Expand All @@ -101,8 +109,12 @@ const Overview: FC<{ className?: string; overview: OverviewType }> = ({ classNam
<Typography variant="body1" className="label">
{t('type')}
</Typography>
<Typography variant="body1" className="value">
{t(type)}
<Typography variant="body1">
{types.map((type) => (
<Typography variant="body1" className="value">
{t(type)}
</Typography>
))}
</Typography>
<Typography variant="body1" className="label">
{t('proposer')}
Expand Down

1 comment on commit 3b7f63b

@vercel
Copy link

@vercel vercel bot commented on 3b7f63b Nov 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

cosmos – ./

cosmos-git-main-bigdipper.vercel.app
cosmos-bigdipper.vercel.app
bigdipper.vercel.app

Please sign in to comment.