-
Notifications
You must be signed in to change notification settings - Fork 1
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
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
|
||
export async function PUT(req: NextRequest, context: PutMethodContext) { | ||
const address = context.params.address; | ||
const id = context.params.id; |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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]); |
There was a problem hiding this comment.
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]);
There was a problem hiding this comment.
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 :)
There was a problem hiding this comment.
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]);```
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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} |
There was a problem hiding this comment.
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 ;)
app/store/create-proposal.store.ts
Outdated
}, | ||
checkFormValidity: () => { | ||
const form = get().form[get().openedForm]; | ||
console.log('checkFormValidity', get().openedForm); |
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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.
No description provided.