Skip to content

Commit

Permalink
wip: Restructure donation flow
Browse files Browse the repository at this point in the history
  • Loading branch information
carina-akaia committed Jun 18, 2024
1 parent 6d11a71 commit 1a58110
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 7 deletions.
17 changes: 17 additions & 0 deletions src/modules/donation/components/DonationConfirmation.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { UseFormReturn } from "react-hook-form";

import { DonationInputs } from "../models";

export type DonationConfirmationProps = {
form: UseFormReturn<DonationInputs>;
};

export const DonationConfirmation = ({
form: _,
}: DonationConfirmationProps) => {
return (
<div>
<h1>Confirm donation</h1>
</div>
);
};
12 changes: 7 additions & 5 deletions src/modules/donation/components/DonationFlow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,20 @@ import { useMemo } from "react";
import { dispatch } from "@/app/_store";
import { Button, DialogFooter, Form } from "@/common/ui/components";

import { DonationConfirmation } from "./DonationConfirmation";
import { DonationPotAllocation } from "./DonationPotAllocation";
import { DonationProjectAllocation } from "./DonationProjectAllocation";
import { DonationSuccess } from "./DonationSuccess";
import { useDonationForm } from "../hooks/forms";
import { DonationState, DonationSubmissionInputs } from "../models";

export type DonationFlowProps = DonationSubmissionInputs &
DonationState & {
closeDialog: VoidFunction;
closeModal: VoidFunction;
};

export const DonationFlow: React.FC<DonationFlowProps> = ({
closeDialog: _,
closeModal,
currentStep,
...props
}) => {
Expand All @@ -33,15 +35,15 @@ export const DonationFlow: React.FC<DonationFlowProps> = ({
);

case "confirmation":
return <></>;
return <DonationConfirmation {...{ form }} />;

case "success":
return <></>;
return <DonationSuccess {...{ closeModal }} />;

default:
return "Error: Unable to proceed with the next step";
}
}, [currentStep, form, props]);
}, [closeModal, currentStep, form, props]);

return (
<Form {...form}>
Expand Down
2 changes: 1 addition & 1 deletion src/modules/donation/components/DonationModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export const DonationModal = create((props: DonationModalProps) => {
</Alert>
</DialogHeader>
) : (
<DonationFlow closeDialog={close} {...props} {...state} />
<DonationFlow closeModal={close} {...props} {...state} />
)}
</DialogContent>
</Dialog>
Expand Down
2 changes: 1 addition & 1 deletion src/modules/donation/components/DonationPotAllocation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useMemo } from "react";
import { UseFormReturn } from "react-hook-form";

import { pagoda } from "@/common/api/pagoda";
import { ByAccountId, ByPotId, potlock } from "@/common/api/potlock";
import { ByPotId, potlock } from "@/common/api/potlock";
import { NEAR_TOKEN_DENOM } from "@/common/constants";
import { walletApi } from "@/common/contracts";
import {
Expand Down
12 changes: 12 additions & 0 deletions src/modules/donation/components/DonationSuccess.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export type DonationSuccessProps = {
closeModal: VoidFunction;
};

export const DonationSuccess = ({ closeModal }: DonationSuccessProps) => {
return (
<div>
<h1>Donation successful!</h1>
<button onClick={closeModal}>Close</button>
</div>
);
};

0 comments on commit 1a58110

Please sign in to comment.