-
Notifications
You must be signed in to change notification settings - Fork 11
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
1 parent
2512248
commit 1af4abd
Showing
14 changed files
with
388 additions
and
12 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
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
71 changes: 71 additions & 0 deletions
71
govtool/frontend/src/components/organisms/VoteContext/VoteContextModal.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,71 @@ | ||
import { useState } from "react"; | ||
|
||
import { ModalWrapper } from "@atoms"; | ||
// import { useModal } from "@context"; | ||
import { useForm, FormProvider } from "react-hook-form"; | ||
import { VoteContextTerms, VoteContextText } from "@organisms"; | ||
// import { useScreenDimension, useTranslation } from "@hooks"; | ||
import { VoteContextFormValues } from "@/hooks/forms/useVoteContextForm"; | ||
|
||
// type VoteContextModalState = { | ||
// onContinue?: () => void; | ||
// onCancel?: () => void; | ||
// }; | ||
|
||
export const VoteContextModal = () => { | ||
const [step, setStep] = useState(1); | ||
|
||
// const { state, closeModal } = useModal<VoteContextModalState>(); | ||
|
||
const methods = useForm<VoteContextFormValues>({ mode: "onChange" }); | ||
|
||
// console.log(errors, isValid); | ||
// console.log("dupa", isValid); | ||
|
||
return ( | ||
<ModalWrapper | ||
dataTestId="vote-context-modal" | ||
sx={{ | ||
maxWidth: "700px", | ||
p: "60px 32px 32px", | ||
}} | ||
> | ||
<FormProvider {...methods}> | ||
{step === 1 && <VoteContextText setStep={setStep} />} | ||
{step === 2 && <VoteContextTerms setStep={setStep} />} | ||
</FormProvider> | ||
{/* <Box | ||
sx={{ | ||
display: "flex", | ||
justifyContent: "space-between", | ||
marginTop: "40px", | ||
...(isMobile && { flexDirection: "column", gap: 3 }), | ||
}} | ||
> | ||
<Button | ||
data-testid="cancel-modal-button" | ||
onClick={state?.onCancel ? state?.onCancel : closeModal} | ||
size="large" | ||
sx={{ | ||
width: isMobile ? "100%" : "154px", | ||
}} | ||
variant="outlined" | ||
> | ||
Cancel | ||
</Button> | ||
<Button | ||
data-testid="confirm-modal-button" | ||
disabled={!isValid} | ||
onClick={() => {}} | ||
size="large" | ||
sx={{ | ||
width: isMobile ? "100%" : "154px", | ||
}} | ||
variant="contained" | ||
> | ||
Continue | ||
</Button> | ||
</Box> */} | ||
</ModalWrapper> | ||
); | ||
}; |
73 changes: 73 additions & 0 deletions
73
govtool/frontend/src/components/organisms/VoteContext/VoteContextTerms.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,73 @@ | ||
import { Dispatch, SetStateAction } from "react"; | ||
import { Box, Link } from "@mui/material"; | ||
|
||
import { Spacer, Typography } from "@atoms"; | ||
import { | ||
useCreateGovernanceActionForm, | ||
useScreenDimension, | ||
useTranslation, | ||
useVoteContextForm, | ||
} from "@hooks"; | ||
import { BgCard, ControlledField, VoteContextWrapper } from "@organisms"; | ||
import { openInNewTab } from "@utils"; | ||
|
||
type StoreDataInfoProps = { | ||
setStep: Dispatch<SetStateAction<number>>; | ||
}; | ||
|
||
export const VoteContextTerms = ({ setStep }: StoreDataInfoProps) => { | ||
const { t } = useTranslation(); | ||
const { control, errors, watch } = useVoteContextForm(); | ||
const { isMobile } = useScreenDimension(); | ||
|
||
// TODO: change link when available | ||
const openLink = () => openInNewTab("https://docs.sanchogov.tools"); | ||
|
||
const isContinueDisabled = !watch("terms"); | ||
|
||
const onClickContinue = () => setStep(6); | ||
|
||
const onClickBack = () => setStep(4); | ||
|
||
return ( | ||
// <BgCard | ||
// actionButtonLabel={t("continue")} | ||
// isActionButtonDisabled={isContinueDisabled} | ||
// onClickActionButton={onClickContinue} | ||
// onClickBackButton={onClickBack} | ||
// > | ||
<VoteContextWrapper | ||
onContinue={() => setStep(1)} | ||
isContinueDisabled={isContinueDisabled} | ||
> | ||
<Typography sx={{ textAlign: "center" }} variant="headline4"> | ||
{t("createGovernanceAction.storeDataTitle")} | ||
</Typography> | ||
<Link | ||
onClick={openLink} | ||
sx={{ | ||
cursor: "pointer", | ||
fontSize: 16, | ||
fontWeight: 500, | ||
fontFamily: "Poppins", | ||
my: 4, | ||
textAlign: "center", | ||
textDecoration: "none", | ||
}} | ||
> | ||
{t("createGovernanceAction.storeDataLink")} | ||
</Link> | ||
<ControlledField.Checkbox | ||
{...{ control, errors }} | ||
name="terms" | ||
label={t("createGovernanceAction.storeDataCheckboxLabel")} | ||
layoutStyles={{ | ||
display: "flex", | ||
justifyContent: "center", | ||
}} | ||
/> | ||
<Spacer y={isMobile ? 4 : 12.5} /> | ||
<Box display="flex" flex={1} /> | ||
</VoteContextWrapper> | ||
); | ||
}; |
72 changes: 72 additions & 0 deletions
72
govtool/frontend/src/components/organisms/VoteContext/VoteContextText.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,72 @@ | ||
import { Dispatch, SetStateAction } from "react"; | ||
|
||
import { orange } from "@consts"; | ||
import { Typography } from "@atoms"; | ||
import { VoteContextWrapper } from "@organisms"; | ||
import { useTranslation, useVoteContextForm } from "@/hooks"; | ||
import { ControlledField } from ".."; | ||
|
||
type VoteContextTextProps = { | ||
setStep: Dispatch<SetStateAction<number>>; | ||
}; | ||
|
||
export const VoteContextText = ({ setStep }: VoteContextTextProps) => { | ||
const { t } = useTranslation(); | ||
|
||
const { control, errors, watch } = useVoteContextForm(); | ||
|
||
const isContinueDisabled = !watch("text"); | ||
|
||
const fieldProps = { | ||
key: "text", | ||
layoutStyles: { mb: 3 }, | ||
name: "text", | ||
placeholder: "Provide context", | ||
rules: { | ||
required: { | ||
value: true, | ||
message: t("createGovernanceAction.fields.validations.required"), | ||
}, | ||
maxLength: { | ||
value: 500, | ||
message: t("createGovernanceAction.fields.validations.maxLength", { | ||
maxLength: 500, | ||
}), | ||
}, | ||
}, | ||
}; | ||
|
||
return ( | ||
<VoteContextWrapper | ||
onContinue={() => setStep(2)} | ||
isContinueDisabled={isContinueDisabled} | ||
> | ||
<Typography | ||
variant="body1" | ||
sx={{ | ||
textTransform: "uppercase", | ||
color: orange.c400, | ||
}} | ||
> | ||
optional | ||
</Typography> | ||
<Typography | ||
variant="title2" | ||
sx={{ | ||
lineHeight: "34px", | ||
mb: 1, | ||
}} | ||
> | ||
Provide context about your vote | ||
</Typography> | ||
<Typography variant="body1" sx={{ fontWeight: 400, mb: 2 }}> | ||
Info about how you voting and whats to do now (?) | ||
</Typography> | ||
<ControlledField.TextArea | ||
{...{ control, errors }} | ||
{...fieldProps} | ||
isModifiedLayout | ||
/> | ||
</VoteContextWrapper> | ||
); | ||
}; |
Oops, something went wrong.