From 6a2d7465bf85f889935c34afed43ba4f5207cd1b Mon Sep 17 00:00:00 2001 From: Anna Date: Fri, 5 Jan 2024 12:51:01 +0100 Subject: [PATCH] MGU-8 add dummy 4th step on creating proposal --- app/(routes)/create-proposal/page.tsx | 3 +- app/(routes)/proposals/[id]/page.tsx | 36 +++++------- .../markdown-view/markdown-view.component.tsx | 2 +- .../markdown-view/markdown-view.module.scss | 4 ++ .../wallet-address-with-copy.component.tsx | 21 +++++++ ...create-proposal-preview-step.component.tsx | 55 +++++++++++++++++++ app/components/create-proposal/index.tsx | 3 +- .../wrapper/wrapper.component.tsx | 4 +- app/interfaces/create-proposal.interface.ts | 7 ++- 9 files changed, 107 insertions(+), 28 deletions(-) create mode 100644 app/components/_shared/wallet-address-with-copy/wallet-address-with-copy.component.tsx create mode 100644 app/components/create-proposal/create-proposal-preview-step/create-proposal-preview-step.component.tsx diff --git a/app/(routes)/create-proposal/page.tsx b/app/(routes)/create-proposal/page.tsx index ddde7d02..c5c391fb 100644 --- a/app/(routes)/create-proposal/page.tsx +++ b/app/(routes)/create-proposal/page.tsx @@ -1,6 +1,6 @@ "use client"; import styles from "./page.module.scss"; -import { CreateProposalExecutionStep, CreateProposalContentStep, CreateProposalWalletStep } from "@components/create-proposal"; +import { CreateProposalExecutionStep, CreateProposalContentStep, CreateProposalWalletStep, CreateProposalPreviewStep } from "@components/create-proposal"; import { CreateProposalProvider } from "@/app/providers/create-proposal.provider"; const Page = () => { @@ -11,6 +11,7 @@ const Page = () => { + diff --git a/app/(routes)/proposals/[id]/page.tsx b/app/(routes)/proposals/[id]/page.tsx index 50d04704..c63b7204 100644 --- a/app/(routes)/proposals/[id]/page.tsx +++ b/app/(routes)/proposals/[id]/page.tsx @@ -1,20 +1,19 @@ "use client"; -import {statusToBadgeColorMap} from "@interfaces/proposal"; -import {Avatar, Badge, Button, Card, Input, Tab, TabList} from "@components/_shared"; -import {Countdown} from "@components/countdown/countdown.component"; -import {format} from "date-fns"; -import {singleProposal} from "@/app/helpers/mocks"; -import {useForm} from "react-hook-form"; -import styles from "./page.module.scss"; -import {InferType, number, object, setLocale} from "yup"; -import {yupResolver} from "@hookform/resolvers/yup"; -import {VotesList} from "@components/votes-list/votes-list.component"; -import classNames from "classnames"; -import {useState} from "react"; -import { CopyIcon } from "@/app/components/_icons/copy.icon"; -import { CopyToClipboard } from 'react-copy-to-clipboard'; import { MarkdownView } from "@/app/components/_shared/markdown-view/markdown-view.component"; +import { WalletAddressWithCopy } from "@/app/components/_shared/wallet-address-with-copy/wallet-address-with-copy.component"; +import { singleProposal } from "@/app/helpers/mocks"; import useModal from "@/app/providers/modal.provider"; +import { Avatar, Badge, Button, Card, Input, TabList } from "@components/_shared"; +import { Countdown } from "@components/countdown/countdown.component"; +import { VotesList } from "@components/votes-list/votes-list.component"; +import { yupResolver } from "@hookform/resolvers/yup"; +import { statusToBadgeColorMap } from "@interfaces/proposal"; +import classNames from "classnames"; +import { format } from "date-fns"; +import { useState } from "react"; +import { useForm } from "react-hook-form"; +import { InferType, number, object, setLocale } from "yup"; +import styles from "./page.module.scss"; const validationSchema = object({ votingPower: number().required().typeError('Invalid number').max(400) @@ -80,14 +79,9 @@ const Page = () => {
by {proposal.creator}
-
+
ID -
{`${proposal.id.substring(0, 6)}...${proposal.id.substring(proposal.id.length - 4)}`}
- -
- -
-
+
Proposed on: diff --git a/app/components/_shared/markdown-view/markdown-view.component.tsx b/app/components/_shared/markdown-view/markdown-view.component.tsx index 7dbbfa5d..a2ea5da5 100644 --- a/app/components/_shared/markdown-view/markdown-view.component.tsx +++ b/app/components/_shared/markdown-view/markdown-view.component.tsx @@ -22,7 +22,7 @@ export const MarkdownView = ({ markdown }: MarkdownViewProps) => { })(); }, [markdown]); - return
+ return
{ markdownParsed &&
} diff --git a/app/components/_shared/markdown-view/markdown-view.module.scss b/app/components/_shared/markdown-view/markdown-view.module.scss index f4a23cb3..183edd8b 100644 --- a/app/components/_shared/markdown-view/markdown-view.module.scss +++ b/app/components/_shared/markdown-view/markdown-view.module.scss @@ -5,6 +5,10 @@ font-size: $theme-unit * 4; line-height: $theme-unit * 4; + h3, strong { + color: var(--theme-foreground-color); + } + ul li::marker { color: var(--theme-foreground-color); } diff --git a/app/components/_shared/wallet-address-with-copy/wallet-address-with-copy.component.tsx b/app/components/_shared/wallet-address-with-copy/wallet-address-with-copy.component.tsx new file mode 100644 index 00000000..44fba060 --- /dev/null +++ b/app/components/_shared/wallet-address-with-copy/wallet-address-with-copy.component.tsx @@ -0,0 +1,21 @@ +import BaseComponentProps from "@interfaces/base-component-props.interface"; +import { WalletAddress } from "../../wallet-address/wallet-address.component"; +import CopyToClipboard from "react-copy-to-clipboard"; +import { CopyIcon } from "../../_icons/copy.icon"; +import classNames from "classnames"; + +interface WalletAddressWithCopyProps extends BaseComponentProps { + address: string; +} + +export const WalletAddressWithCopy = ({ className, style, address }: WalletAddressWithCopyProps) => { + return
+ + +
+ +
+
+
+} \ No newline at end of file diff --git a/app/components/create-proposal/create-proposal-preview-step/create-proposal-preview-step.component.tsx b/app/components/create-proposal/create-proposal-preview-step/create-proposal-preview-step.component.tsx new file mode 100644 index 00000000..3d65207b --- /dev/null +++ b/app/components/create-proposal/create-proposal-preview-step/create-proposal-preview-step.component.tsx @@ -0,0 +1,55 @@ +"use client"; +import { singleProposal } from "@/app/helpers/mocks"; +import { useCreateProposalContext } from "@/app/providers/create-proposal.provider"; +import Wrapper from "@components/create-proposal/wrapper/wrapper.component"; +import { CreateProposalFormStepEnum } from "@interfaces/create-proposal.interface"; +import { useForm } from "react-hook-form"; +import { MarkdownView } from "../../_shared/markdown-view/markdown-view.component"; +import { format } from "date-fns"; +import { WalletAddressWithCopy } from "../../_shared/wallet-address-with-copy/wallet-address-with-copy.component"; +import { Avatar } from "../../_shared"; + +const formStep = CreateProposalFormStepEnum.preview + +export const CreateProposalPreviewStep = () => { + + const { form } = useCreateProposalContext(); + + const { + register, + watch, + setValue, + getValues, + handleSubmit, + formState: { errors, isValid } + } = useForm({ + mode: 'onChange' + }); + + const proposal = singleProposal; + + return +
+

You've successfully finished all the steps. Now, take a moment to go over your proposal and then submit it.

+
{proposal.title}
+
+
+ Proposed on: + {format(proposal.createdAt, 'MMMM do, yyyy')} +
+
+ Voting deadline: + {format(proposal.deadlineAt, 'MMMM do, yyyy')} +
+
+
+ + +
+
+

Details

+ +
+
+
+} \ No newline at end of file diff --git a/app/components/create-proposal/index.tsx b/app/components/create-proposal/index.tsx index 23cd0daf..df669945 100644 --- a/app/components/create-proposal/index.tsx +++ b/app/components/create-proposal/index.tsx @@ -1,3 +1,4 @@ export { CreateProposalWalletStep } from './create-proposal-wallet-step/create-proposal-wallet-step.component'; export { CreateProposalContentStep } from './create-proposal-content-step/create-proposal-content-step.component'; -export { CreateProposalExecutionStep } from './create-proposal-execution-step/create-proposal-execution-step.component'; \ No newline at end of file +export { CreateProposalExecutionStep } from './create-proposal-execution-step/create-proposal-execution-step.component'; +export { CreateProposalPreviewStep } from './create-proposal-preview-step/create-proposal-preview-step.component'; \ No newline at end of file diff --git a/app/components/create-proposal/wrapper/wrapper.component.tsx b/app/components/create-proposal/wrapper/wrapper.component.tsx index c2d186f6..e6fffe72 100644 --- a/app/components/create-proposal/wrapper/wrapper.component.tsx +++ b/app/components/create-proposal/wrapper/wrapper.component.tsx @@ -12,7 +12,7 @@ interface WrapperProps extends BaseComponentProps { isOpened: boolean; } -const steps = [CreateProposalFormStepEnum.wallet, CreateProposalFormStepEnum.content, CreateProposalFormStepEnum.execution]; +const steps = [CreateProposalFormStepEnum.wallet, CreateProposalFormStepEnum.content, CreateProposalFormStepEnum.execution, CreateProposalFormStepEnum.preview]; const Wrapper = ({children, className, step, title, style, isOpened}: WrapperProps) => { @@ -24,7 +24,7 @@ const Wrapper = ({children, className, step, title, style, isOpened}: WrapperPro return -
toggleStepOpen(step)}> +
toggleStepOpen(step)}> {stepIndex} {title}
diff --git a/app/interfaces/create-proposal.interface.ts b/app/interfaces/create-proposal.interface.ts index aa416113..39e67ee0 100644 --- a/app/interfaces/create-proposal.interface.ts +++ b/app/interfaces/create-proposal.interface.ts @@ -2,6 +2,7 @@ export interface CreateProposalForm { [CreateProposalFormStepEnum.wallet]: CreateProposalFormStep; [CreateProposalFormStepEnum.content]: CreateProposalFormStep; [CreateProposalFormStepEnum.execution]: CreateProposalFormStep; + [CreateProposalFormStepEnum.preview]: CreateProposalFormStep; } interface CreateProposalFormStep { @@ -14,7 +15,8 @@ interface CreateProposalFormStep { export enum CreateProposalFormStepEnum { wallet = 'wallet', content = 'content', - execution = 'execution' + execution = 'execution', + preview = 'preview' } const nextFormStep = { @@ -32,5 +34,6 @@ export const initialCreateProposalForm: CreateProposalForm = { value: {} }, [CreateProposalFormStepEnum.content]: nextFormStep, - [CreateProposalFormStepEnum.execution]: nextFormStep + [CreateProposalFormStepEnum.execution]: nextFormStep, + [CreateProposalFormStepEnum.preview]: nextFormStep } \ No newline at end of file