-
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
1 parent
2c115c9
commit 66e15ad
Showing
10 changed files
with
118 additions
and
72 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,19 @@ | ||
import { Models } from "@rematch/core"; | ||
|
||
import { auth } from "@/modules/auth/state"; | ||
import { donationModel } from "@/modules/donation/models"; | ||
import { navModel, profilesModel } from "@/modules/profile/models"; | ||
|
||
export interface RootModel extends Models<RootModel> { | ||
auth: typeof auth; | ||
donation: typeof donationModel; | ||
profiles: typeof profilesModel; | ||
nav: typeof navModel; | ||
} | ||
|
||
export const models: RootModel = { | ||
auth, | ||
donation: donationModel, | ||
profiles: profilesModel, | ||
nav: navModel, | ||
}; |
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
File renamed without changes.
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 was deleted.
Oops, something went wrong.
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,25 @@ | ||
import { useCallback } from "react"; | ||
|
||
import { zodResolver } from "@hookform/resolvers/zod"; | ||
import { SubmitHandler, useForm } from "react-hook-form"; | ||
import { infer as FromSchema } from "zod"; | ||
|
||
import { donationSchema } from "@/common/api/potlock"; | ||
|
||
export const projectDonationSchema = donationSchema; | ||
|
||
export type ProjectDonationInputs = FromSchema<typeof projectDonationSchema>; | ||
|
||
export type ProjectDonationFormParameters = {}; | ||
|
||
export const useProjectDonationForm = (_: ProjectDonationFormParameters) => { | ||
const { handleSubmit, ...form } = useForm<ProjectDonationInputs>({ | ||
resolver: zodResolver(donationSchema), | ||
}); | ||
|
||
const onSubmit: SubmitHandler<ProjectDonationInputs> = useCallback((data) => { | ||
console.log(data); | ||
}, []); | ||
|
||
return { onSubmit: handleSubmit(onSubmit), ...form }; | ||
}; |
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 +1 @@ | ||
export { useDonationModal } from "./components/modal"; | ||
export { useDonationModal } from "./components/DonationModal"; |
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,39 @@ | ||
import { createModel } from "@rematch/core"; | ||
|
||
import { RootModel } from "@/app/_store/models"; | ||
|
||
export type DonationStep = "allocation" | "confirmation" | "done"; | ||
|
||
export type DonationState = { | ||
currentStep: DonationStep; | ||
}; | ||
|
||
const setStep = (state: DonationState, step: DonationStep) => ({ | ||
...state, | ||
currentStep: step, | ||
}); | ||
|
||
export const donationModel = createModel<RootModel>()({ | ||
state: { | ||
currentStep: "allocation", | ||
} as DonationState, | ||
|
||
reducers: { | ||
handleNextStep(state) { | ||
switch (state.currentStep) { | ||
case "allocation": | ||
return setStep(state, "confirmation"); | ||
|
||
case "confirmation": | ||
return setStep(state, "done"); | ||
} | ||
}, | ||
|
||
handlePrevStep(state) { | ||
switch (state.currentStep) { | ||
case "confirmation": | ||
return setStep(state, "allocation"); | ||
} | ||
}, | ||
}, | ||
}); |