-
Notifications
You must be signed in to change notification settings - Fork 15
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 #899 from alleslabs/feature/cfe-309-module-details
[CFE-309]: Refactor(pages): refactor module details service files
- Loading branch information
Showing
23 changed files
with
597 additions
and
876 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
84 changes: 84 additions & 0 deletions
84
src/lib/pages/module-details/components/ModuleInfoBody.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,84 @@ | ||
import { Grid } from "@chakra-ui/react"; | ||
|
||
import { ExplorerLink } from "lib/components/ExplorerLink"; | ||
import { LabelText } from "lib/components/LabelText"; | ||
import { dateFromNow, formatUTC } from "lib/utils"; | ||
|
||
import type { ModuleInfoProps } from "./ModuleInfo"; | ||
|
||
const ModuleInfoBodyPublishedAndRepublished = ({ | ||
transaction, | ||
proposal, | ||
isRepublished, | ||
}: Pick<ModuleInfoProps, "transaction" | "proposal" | "isRepublished">) => { | ||
const labelPrefix = isRepublished ? "Latest Republished" : "Published"; | ||
|
||
if (transaction) { | ||
return ( | ||
<LabelText label={`${labelPrefix} Transaction`}> | ||
<ExplorerLink type="tx_hash" value={transaction} showCopyOnHover /> | ||
</LabelText> | ||
); | ||
} | ||
|
||
if (proposal && proposal.id) { | ||
return ( | ||
<LabelText | ||
label={`${labelPrefix} Proposal ID`} | ||
helperText1={proposal.title} | ||
> | ||
<ExplorerLink | ||
type="proposal_id" | ||
value={proposal.id.toString()} | ||
showCopyOnHover | ||
/> | ||
</LabelText> | ||
); | ||
} | ||
|
||
return <LabelText label="Created by">Genesis</LabelText>; | ||
}; | ||
|
||
export const ModuleInfoBody = ({ | ||
vmAddress, | ||
upgradePolicy, | ||
transaction, | ||
proposal, | ||
isRepublished, | ||
blockHeight, | ||
blockTimestamp, | ||
}: Omit<ModuleInfoProps, "verificationData">) => ( | ||
<Grid | ||
gridTemplateColumns={{ base: "repeat(1, 1fr)", md: "repeat(4, 1fr)" }} | ||
padding={4} | ||
border="1px solid" | ||
borderColor="gray.700" | ||
borderRadius={8} | ||
gap={6} | ||
> | ||
<LabelText label="Upgrade Policy">{upgradePolicy}</LabelText> | ||
<LabelText label="Published by" helperText1="(Wallet Address)"> | ||
<ExplorerLink type="user_address" value={vmAddress} showCopyOnHover /> | ||
</LabelText> | ||
<LabelText | ||
label="Published Block Height" | ||
helperText1={formatUTC(blockTimestamp)} | ||
helperText2={dateFromNow(blockTimestamp)} | ||
> | ||
{blockHeight ? ( | ||
<ExplorerLink | ||
type="block_height" | ||
value={blockHeight.toString()} | ||
showCopyOnHover | ||
/> | ||
) : ( | ||
"N/A" | ||
)} | ||
</LabelText> | ||
<ModuleInfoBodyPublishedAndRepublished | ||
transaction={transaction} | ||
proposal={proposal} | ||
isRepublished={isRepublished} | ||
/> | ||
</Grid> | ||
); |
Oops, something went wrong.