Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/create proposal form store #20

Merged
merged 14 commits into from
Jan 11, 2024
Merged

Conversation

tplocic20
Copy link
Contributor

No description provided.

@tplocic20 tplocic20 requested a review from AnnaJ-P11 January 10, 2024 14:45
Copy link

vercel bot commented Jan 10, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
governance-ui ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 11, 2024 1:53pm


export async function PUT(req: NextRequest, context: PutMethodContext) {
const address = context.params.address;
const id = context.params.id;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tutaj można zrobić destrukturyzację, będzie mniej constów i wg mnie to zawsze to jakoś lepiej wygląda, bez powtórzeń ;)
const { address, id } = context.params

}

export async function GET(req: NextRequest, context: GetMethodContext) {
const address = context.params.address;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

destrukturyzacja ? :)

}

export async function PUT(req: NextRequest, context: PutMethodContext) {
const address = context.params.address;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

destrukturyzacja ? :)

position: absolute;
inset: 0px;
border-radius: 50%;
border: 5px solid $c-primary;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$theme-unit

return <Wrapper isOpened={form[formStep].isOpened} step={formStep} title="Add name and description">
useEffect(() => {
const subscription = watch((value) => {
console.log(value);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

console

createdAt: form[CreateProposalFormStepEnum.content].value.creteDate.value,
creator: form[CreateProposalFormStepEnum.wallet].value.walletAddress.value,
} as IProposal;
}, [form]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Może warto rozważyć tutaj destrukturyzację, myślę, że mogłoby wtedy zrobić się bardziej przejrzyste, ale up to you ;)

 const proposal = useMemo(() => {
        const {title, description, creteDate, deadlineDate} = form[CreateProposalFormStepEnum.content].value
        return {
            title: title.value,
            description: description.value,
            deadlineAt: deadlineDate.value,
            createdAt: creteDate.value,
            creator: form[CreateProposalFormStepEnum.wallet].value.walletAddress.value,
        } as IProposal;
    }, [form]);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a jak tutaj możemy zrobić destukturyzację?
Bo troszkę nie mam pomysłu :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wysłałam przykład rozwiązania ;) nie wiem czy go widzisz, wyślę jeszcze raz ;)

const proposal = useMemo(() => {
        const {title, description, creteDate, deadlineDate} = form[CreateProposalFormStepEnum.content].value
        return {
            title: title.value,
            description: description.value,
            deadlineAt: deadlineDate.value,
            createdAt: creteDate.value,
            creator: form[CreateProposalFormStepEnum.wallet].value.walletAddress.value,
        } as IProposal;
    }, [form]);```

Copy link
Contributor

@AnnaJ-P11 AnnaJ-P11 Jan 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

chodzi o to, że wiele razy powtarza się form[CreateProposalFormStepEnum.content].value a można z niego destrukturyzacją wyciągnąć pola

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aaaa, dobra, nie ogarnąłem :D
Myślałęm, żę to zrzut z mojego kodu 😅😅

<MntoLock/>
</>
}
{currentFormStepComponent}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Jeśli zwracamy jsxa to lepiej to zrobić nowym komponentem, taki sposób jest ryzykowny, może powodować niepotzrebne renderowania i też w drzewie DOM się niepoprawnie wyświetla. Zrobiłabym z tego osobny komponent ;)

},
checkFormValidity: () => {
const form = get().form[get().openedForm];
console.log('checkFormValidity', get().openedForm);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ten console to tak celowo ;) ?

body: JSON.stringify({date}),
});

const lockResponseJson = await lockResponse.json();
Copy link
Contributor

@AnnaJ-P11 AnnaJ-P11 Jan 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Myślę, że mogłby się w tych funkcjach przydać jakie try-catch'e, jakby jakiś error poleciał. Co sądzisz?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try catche są do dodania, ale jak już będziemy mieć faktyczne calle po dane :)

title: form[CreateProposalFormStepEnum.content].value.title.value,
description: form[CreateProposalFormStepEnum.content].value.description.value,
deadlineAt: form[CreateProposalFormStepEnum.content].value.deadlineDate.value,
createdAt: form[CreateProposalFormStepEnum.content].value.creteDate.value,
Copy link
Contributor

@AnnaJ-P11 AnnaJ-P11 Jan 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A przy okazji jeszczed znalazłam literówkę, zapomniałam dopisać ;) .creteDate., pewnie powinno być createDate.

@tplocic20 tplocic20 merged commit a153b54 into develop Jan 11, 2024
1 of 2 checks passed
@tplocic20 tplocic20 deleted the feat/create-proposal-form-store branch January 11, 2024 13:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants