Skip to content

Commit

Permalink
Add JsValueWrap component
Browse files Browse the repository at this point in the history
  • Loading branch information
ryutamago committed Sep 13, 2023
1 parent ea39150 commit 7df8d4f
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@ import {
AccordionItem,
AccordionPanel,
Box,
Card,
CardBody,
} from "@chakra-ui/react";
import { parseRawMichelson } from "../../../../multisig/decode/decodeLambda";
import { UnrecognizedMichelsonError } from "../../../../multisig/decode/UnrecognizedMichelsonError";
import { MultisigAccount } from "../../../../types/Account";
import MultisigDecodedOperationItem from "./MultisigDecodedOperationItem";
import JsValueWrap from "../../JsValueWrap";

const MultisigDecodedOperations: React.FC<{
rawActions: string;
Expand Down Expand Up @@ -51,17 +50,7 @@ const UnrecognizedOperationAccordion: React.FC<{ unrecoginizedRawActions: string
</AccordionButton>
</h2>
<AccordionPanel pb={3} h="400px" overflowY="scroll">
<Card bg="umami.gray.700" borderRadius="5px">
<pre
style={{
whiteSpace: "pre-wrap",
fontSize: "12px",
lineHeight: "18px",
}}
>
<CardBody>{JSON.stringify(JSON.parse(unrecoginizedRawActions), null, 1)}</CardBody>
</pre>
</Card>
<JsValueWrap value={JSON.parse(unrecoginizedRawActions)} space={1} />
</AccordionPanel>
</AccordionItem>
</Accordion>
Expand Down
23 changes: 23 additions & 0 deletions src/components/AccountDrawer/JsValueWrap.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { Card, CardBody } from "@chakra-ui/react";
import colors from "../../style/colors";

// Wrapper for any JavaScript value
const JsValueWrap: React.FC<{ value: any; space?: number }> = ({ value, space = 2 }) => {
return (
<Card bg={colors.gray[700]} borderRadius="5px">
<CardBody>
<pre
style={{
whiteSpace: "pre-wrap",
fontSize: "12px",
lineHeight: "18px",
}}
>
{JSON.stringify(value, null, space)}
</pre>
</CardBody>
</Card>
);
};

export default JsValueWrap;
15 changes: 2 additions & 13 deletions src/views/nfts/NFTDrawerCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { useContext } from "react";
import SendNFTForm from "../../components/SendFlow/NFT/FormPage";
import { useGetOwnedAccount } from "../../utils/hooks/accountHooks";
import { artifactUri } from "../../types/Token";
import JsValueWrap from "../../components/AccountDrawer/JsValueWrap";

const NFTDrawerCard = ({ nft, ownerPkh }: { nft: NFTBalance; ownerPkh: RawPkh }) => {
const url = getIPFSurl(artifactUri(nft));
Expand Down Expand Up @@ -97,19 +98,7 @@ const NFTDrawerCard = ({ nft, ownerPkh }: { nft: NFTBalance; ownerPkh: RawPkh })
</AccordionButton>
</h2>
<AccordionPanel>
<Card bg="umami.gray.700" borderRadius="5px">
<CardBody>
<pre
style={{
whiteSpace: "pre-wrap",
fontSize: "12px",
lineHeight: "18px",
}}
>
{JSON.stringify(nft, null, 2)}
</pre>
</CardBody>
</Card>
<JsValueWrap value={nft} />
</AccordionPanel>
</AccordionItem>
</Accordion>
Expand Down

0 comments on commit 7df8d4f

Please sign in to comment.