|
| 1 | +import { Box } from "@mui/material"; |
| 2 | +import { useTranslation } from "react-i18next"; |
| 3 | + |
| 4 | +import I18n from "@/i18n"; |
| 5 | +import { BUDGET_DISCUSSION_PATHS, PATHS, PDF_PATHS } from "@/consts"; |
| 6 | + |
| 7 | +import { Typography } from "../../atoms"; |
| 8 | +import { HomeCard } from "../../molecules/HomeCard"; |
| 9 | +import { useModal } from "@/context"; |
| 10 | + |
| 11 | +const CONNECT_WALLET_TO_CARDS = [ |
| 12 | + { |
| 13 | + title: I18n.t("home.connectWalletTo.cards.discussBudgetProposals.title"), |
| 14 | + description: I18n.t( |
| 15 | + "home.connectWalletTo.cards.discussBudgetProposals.description", |
| 16 | + ), |
| 17 | + path: BUDGET_DISCUSSION_PATHS.budgetDiscussion, |
| 18 | + }, |
| 19 | + { |
| 20 | + title: I18n.t("home.connectWalletTo.cards.createBudgetProposal.title"), |
| 21 | + description: I18n.t( |
| 22 | + "home.connectWalletTo.cards.createBudgetProposal.description", |
| 23 | + ), |
| 24 | + path: BUDGET_DISCUSSION_PATHS.budgetDiscussion, |
| 25 | + }, |
| 26 | + { |
| 27 | + title: I18n.t("home.connectWalletTo.cards.discussGovernanceActions.title"), |
| 28 | + description: I18n.t( |
| 29 | + "home.connectWalletTo.cards.discussGovernanceActions.description", |
| 30 | + ), |
| 31 | + path: PDF_PATHS.proposalDiscussion, |
| 32 | + }, |
| 33 | + { |
| 34 | + title: I18n.t("home.connectWalletTo.cards.proposeGovernanceAction.title"), |
| 35 | + description: I18n.t( |
| 36 | + "home.connectWalletTo.cards.proposeGovernanceAction.description", |
| 37 | + ), |
| 38 | + path: PDF_PATHS.proposalDiscussionPropose, |
| 39 | + }, |
| 40 | + { |
| 41 | + title: I18n.t("home.connectWalletTo.cards.registerToVote.title"), |
| 42 | + description: I18n.t( |
| 43 | + "home.connectWalletTo.cards.registerToVote.description", |
| 44 | + ), |
| 45 | + path: PATHS.registerAsDirectVoter, |
| 46 | + }, |
| 47 | + { |
| 48 | + title: I18n.t("home.connectWalletTo.cards.delegateVote.title"), |
| 49 | + description: I18n.t("home.connectWalletTo.cards.delegateVote.description"), |
| 50 | + path: PATHS.dRepDirectory, |
| 51 | + }, |
| 52 | + { |
| 53 | + title: I18n.t("home.connectWalletTo.cards.becomeDRep.title"), |
| 54 | + description: I18n.t("home.connectWalletTo.cards.becomeDRep.description"), |
| 55 | + path: PATHS.registerAsdRep, |
| 56 | + }, |
| 57 | + { |
| 58 | + title: I18n.t("home.connectWalletTo.cards.voteOnGovernanceActions.title"), |
| 59 | + description: I18n.t( |
| 60 | + "home.connectWalletTo.cards.voteOnGovernanceActions.description", |
| 61 | + ), |
| 62 | + path: PATHS.dashboardGovernanceActions, |
| 63 | + }, |
| 64 | +]; |
| 65 | + |
| 66 | +export const ConnectWalletTo = () => { |
| 67 | + const { t } = useTranslation(); |
| 68 | + const { openModal } = useModal(); |
| 69 | + |
| 70 | + const handleCardClick = ({ path }: { path?: string }) => { |
| 71 | + if (!path) return; |
| 72 | + openModal({ |
| 73 | + type: "chooseWallet", |
| 74 | + state: { |
| 75 | + pathToNavigate: path, |
| 76 | + }, |
| 77 | + }); |
| 78 | + }; |
| 79 | + |
| 80 | + return ( |
| 81 | + <Box my={4} component="section" data-testid="connect-wallet-to-section"> |
| 82 | + <Typography variant="title2"> |
| 83 | + {t("home.connectWalletTo.section.title")} |
| 84 | + </Typography> |
| 85 | + <Box |
| 86 | + display="grid" |
| 87 | + gridTemplateColumns={{ |
| 88 | + xxs: "repeat(1, 1fr)", |
| 89 | + sm: "repeat(2, 1fr)", |
| 90 | + lg: "repeat(3, 1fr)", |
| 91 | + }} |
| 92 | + gap={4} |
| 93 | + mt={4} |
| 94 | + > |
| 95 | + {CONNECT_WALLET_TO_CARDS.map(({ title, description, path }) => ( |
| 96 | + <HomeCard |
| 97 | + key={title} |
| 98 | + title={title} |
| 99 | + description={description} |
| 100 | + onCardClick={() => handleCardClick({ path })} |
| 101 | + /> |
| 102 | + ))} |
| 103 | + </Box> |
| 104 | + </Box> |
| 105 | + ); |
| 106 | +}; |
0 commit comments