-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathPotApplicationModal.tsx
More file actions
87 lines (80 loc) · 2.22 KB
/
PotApplicationModal.tsx
File metadata and controls
87 lines (80 loc) · 2.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import { TextAreaField } from "@/common/ui/form/components";
import {
Button,
Dialog,
DialogContent,
DialogHeader,
DialogTitle,
Form,
FormField,
Spinner,
} from "@/common/ui/layout/components";
import { useWalletUserSession } from "@/common/wallet";
import { type PotApplicationFormParams, usePotApplicationForm } from "../hooks/forms";
export type PotApplicationModalProps = Pick<
PotApplicationFormParams,
"applicantAccountId" | "potConfig" | "onSuccess" | "onFailure"
> & {
open?: boolean;
onCloseClick?: () => void;
daoMode?: boolean;
};
export const PotApplicationModal: React.FC<PotApplicationModalProps> = ({
open,
onCloseClick,
applicantAccountId,
daoMode = false,
potConfig,
onSuccess,
onFailure,
}) => {
const walletUser = useWalletUserSession();
const { form, onSubmit } = usePotApplicationForm({
applicantAccountId,
asDao: daoMode,
potConfig,
onSuccess,
onFailure,
});
return (
<Dialog open={open}>
<DialogContent className="max-w-130" onCloseClick={onCloseClick}>
<DialogHeader>
<DialogTitle>{`Apply to ${potConfig.name}`}</DialogTitle>
</DialogHeader>
<Form {...form}>
<form className="flex flex-col p-6" onSubmit={onSubmit}>
<FormField
control={form.control}
name="message"
render={({ field }) => (
<TextAreaField
label="Application Message"
placeholder="Your application message here..."
rows={5}
className="mt-2"
{...field}
/>
)}
/>
<Button
disabled={!form.formState.isValid || form.formState.isSubmitting}
className="mt-6 min-w-[200px] self-end"
type="submit"
>
{form.formState.isSubmitting ? (
<Spinner />
) : (
<>
{walletUser.isDaoRepresentative
? "Submit Application Proposal"
: "Send Application"}
</>
)}
</Button>
</form>
</Form>
</DialogContent>
</Dialog>
);
};