-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #782 from alleslabs/feat/cfe-214-period-detail
feat: proposal details on vote tabs
- Loading branch information
Showing
10 changed files
with
154 additions
and
192 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
src/lib/pages/proposal-details/components/proposal-stepper/StepHelperText.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* eslint-disable sonarjs/cognitive-complexity */ | ||
import { Text } from "@chakra-ui/react"; | ||
|
||
import { Countdown } from "../proposal-overview/status-summary/Countdown"; | ||
import type { ProposalData } from "lib/types"; | ||
import { ProposalStatus } from "lib/types"; | ||
import { formatUTC } from "lib/utils"; | ||
|
||
interface StepperHelperTextProps { | ||
step: number; | ||
proposalData: ProposalData; | ||
} | ||
|
||
const StepperHelperTextBody = ({ | ||
step, | ||
proposalData, | ||
}: StepperHelperTextProps) => { | ||
// Deposit Period | ||
if (step === 1) { | ||
if (proposalData.status === ProposalStatus.DEPOSIT_FAILED) | ||
return "The proposal is rejected as it did not meet the required deposit"; | ||
|
||
if ( | ||
proposalData.status === ProposalStatus.CANCELLED && | ||
proposalData.votingTime === null | ||
) | ||
return `The proposal is cancelled at ${proposalData.resolvedTimestamp ? formatUTC(proposalData.resolvedTimestamp) : "N/A"}`; | ||
|
||
if (proposalData.status === ProposalStatus.DEPOSIT_PERIOD) | ||
return ( | ||
<> | ||
Deposit ends in{" "} | ||
<Countdown endTime={proposalData.depositEndTime} isString /> | ||
</> | ||
); | ||
|
||
return `The proposal passed the deposit period at ${proposalData.votingTime ? formatUTC(proposalData.votingTime) : "N/A"}`; | ||
} | ||
|
||
// Voting Period | ||
if (proposalData.status === ProposalStatus.DEPOSIT_FAILED) | ||
return "The proposal is rejected as it did not meet the required deposit"; | ||
|
||
if (proposalData.status === ProposalStatus.CANCELLED) | ||
return `The proposal is cancelled during the ${proposalData.votingTime === null ? "deposit" : "voting"} period`; | ||
|
||
if (proposalData.status === ProposalStatus.DEPOSIT_PERIOD) | ||
return "Proposal proceeds to voting period after meeting deposit requirement"; | ||
|
||
if (proposalData.status === ProposalStatus.VOTING_PERIOD) | ||
return ( | ||
<> | ||
Voting ends in{" "} | ||
{proposalData.votingEndTime ? ( | ||
<Countdown endTime={proposalData.votingEndTime} isString /> | ||
) : ( | ||
"N/A" | ||
)} | ||
</> | ||
); | ||
|
||
return `The proposal ended with the "${proposalData.status.replace(/([A-Z])/g, " $1").trim()}" result`; | ||
}; | ||
|
||
export const StepperHelperText = (props: StepperHelperTextProps) => ( | ||
<Text variant="body3" color="text.dark" ml={8} textAlign="start"> | ||
<StepperHelperTextBody {...props} /> | ||
</Text> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 0 additions & 86 deletions
86
src/lib/pages/proposal-details/components/vote-details/ProposalStepper.tsx
This file was deleted.
Oops, something went wrong.
36 changes: 36 additions & 0 deletions
36
src/lib/pages/proposal-details/components/vote-details/VoteDetailsAccordionItem.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { | ||
AccordionButton, | ||
AccordionIcon, | ||
AccordionItem, | ||
AccordionPanel, | ||
} from "@chakra-ui/react"; | ||
import type { ReactNode } from "react"; | ||
|
||
import { ProposalStepper } from "../proposal-stepper"; | ||
import type { ProposalData } from "lib/types"; | ||
|
||
export const VoteDetailsAccordionItem = ({ | ||
step, | ||
proposalData, | ||
children, | ||
}: { | ||
step: number; | ||
proposalData: ProposalData; | ||
children: ReactNode; | ||
}) => ( | ||
<AccordionItem borderTop="1px solid" borderColor="gray.700"> | ||
<AccordionButton py={3} px={0}> | ||
<ProposalStepper step={step} proposalData={proposalData} /> | ||
<AccordionIcon color="gray.600" ml="auto" /> | ||
</AccordionButton> | ||
<AccordionPanel | ||
bg="transparent" | ||
py={3} | ||
px={0} | ||
borderTop="1px solid" | ||
borderColor="gray.700" | ||
> | ||
{children} | ||
</AccordionPanel> | ||
</AccordionItem> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.