-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
189 additions
and
47 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 0 additions & 26 deletions
26
govtool/frontend/src/components/molecules/BackToButton.tsx
This file was deleted.
Oops, something went wrong.
36 changes: 36 additions & 0 deletions
36
govtool/frontend/src/components/molecules/LinkWithIcon.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 { Box } from "@mui/material"; | ||
import ArrowBackIosIcon from "@mui/icons-material/ArrowBackIos"; | ||
|
||
import { Typography } from "@atoms"; | ||
|
||
import { LinkWithIconProps } from "./types"; | ||
|
||
export const LinkWithIcon = ({ | ||
label, | ||
onClick, | ||
icon, | ||
sx, | ||
}: LinkWithIconProps) => { | ||
return ( | ||
<Box | ||
data-testid={`${label.split(" ").join("-")}-link`} | ||
sx={{ | ||
alignItems: "center", | ||
cursor: "pointer", | ||
display: "flex", | ||
...sx, | ||
}} | ||
onClick={onClick} | ||
> | ||
{icon ? icon : <ArrowBackIosIcon color="primary" sx={{ fontSize: 14 }} />} | ||
<Typography | ||
color="primary" | ||
fontWeight={400} | ||
sx={{ ml: 0.5 }} | ||
variant="body2" | ||
> | ||
{label} | ||
</Typography> | ||
</Box> | ||
); | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
import { SxProps } from "@mui/material"; | ||
|
||
export type BackToLinkProps = { | ||
export type LinkWithIconProps = { | ||
label: string; | ||
onClick: () => void; | ||
icon?: JSX.Element; | ||
sx?: SxProps; | ||
}; |
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
112 changes: 112 additions & 0 deletions
112
govtool/frontend/src/components/organisms/ReviewCreatedGovernanceAction.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,112 @@ | ||
import { Dispatch, SetStateAction } from "react"; | ||
import { Box } from "@mui/material"; | ||
import DriveFileRenameOutlineOutlinedIcon from "@mui/icons-material/DriveFileRenameOutlineOutlined"; | ||
|
||
import { Button, Spacer, Typography } from "@atoms"; | ||
import { ICONS } from "@consts"; | ||
import { useCreateGovernanceActionForm, useTranslation } from "@hooks"; | ||
import { LinkWithIcon } from "@molecules"; | ||
import { openInNewTab } from "@utils"; | ||
|
||
import { BgCard } from "./BgCard"; | ||
|
||
type ReviewCreatedGovernanceActionProps = { | ||
setStep: Dispatch<SetStateAction<number>>; | ||
}; | ||
|
||
export const ReviewCreatedGovernanceAction = ({ | ||
setStep, | ||
}: ReviewCreatedGovernanceActionProps) => { | ||
const { t } = useTranslation(); | ||
const { getValues } = useCreateGovernanceActionForm(); | ||
const values = getValues(); | ||
|
||
const onClickContinue = () => { | ||
setStep(5); | ||
}; | ||
|
||
const onClickBackButton = () => { | ||
setStep(3); | ||
}; | ||
|
||
const onClickEditSubmission = () => { | ||
setStep(3); | ||
}; | ||
|
||
const onClickLink = (link: string) => { | ||
openInNewTab(link); | ||
}; | ||
|
||
const renderReviewFields = () => { | ||
return Object.entries(values) | ||
.filter(([key]) => key !== "links") | ||
.map(([key, value]) => { | ||
const label = | ||
key.charAt(0).toUpperCase() + key.slice(1).replace(/_/g, " "); | ||
|
||
return ( | ||
<Box sx={{ mb: 5 }}> | ||
<Typography color="neutralGray" fontWeight={400} variant="body2"> | ||
{label} | ||
</Typography> | ||
<Typography sx={{ mt: 0.5 }} variant="body2"> | ||
{value as string} | ||
</Typography> | ||
</Box> | ||
); | ||
}); | ||
}; | ||
|
||
const renderLinks = () => { | ||
const links = values["links"]?.map((item) => item.link) ?? []; | ||
|
||
return links.map((link: string) => { | ||
return ( | ||
<LinkWithIcon | ||
icon={<img src={ICONS.link} />} | ||
label={link} | ||
onClick={() => onClickLink(link)} | ||
sx={{ mb: 1.75 }} | ||
/> | ||
); | ||
}); | ||
}; | ||
|
||
return ( | ||
<BgCard | ||
actionButtonLabel={t("continue")} | ||
onClickActionButton={onClickContinue} | ||
onClickBackButton={onClickBackButton} | ||
> | ||
<Typography sx={{ textAlign: "center" }} variant="headline4"> | ||
{t("createGovernanceAction.reviewSubmission")} | ||
</Typography> | ||
<Spacer y={4.25} /> | ||
<Button | ||
startIcon={ | ||
<DriveFileRenameOutlineOutlinedIcon | ||
color="primary" | ||
fontSize="large" | ||
/> | ||
} | ||
onClick={onClickEditSubmission} | ||
sx={{ alignSelf: "center", width: "180px" }} | ||
variant="outlined" | ||
> | ||
{t("createGovernanceAction.editSubmission")} | ||
</Button> | ||
<Spacer y={6} /> | ||
{renderReviewFields()} | ||
<Typography | ||
color="neutralGray" | ||
fontWeight={400} | ||
sx={{ mb: 0.5 }} | ||
variant="body2" | ||
> | ||
{t("createGovernanceAction.supportingLinks")} | ||
</Typography> | ||
{renderLinks()} | ||
<Spacer y={6} /> | ||
</BgCard> | ||
); | ||
}; |
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
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
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