Skip to content

Commit 6d48c88

Browse files
committed
[Dashboard] migrate op credits form to shadcn
1 parent 3bb1fe0 commit 6d48c88

File tree

1 file changed

+88
-73
lines changed

1 file changed

+88
-73
lines changed

apps/dashboard/src/components/onboarding/ApplyForOpCreditsForm.tsx

Lines changed: 88 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
11
import type { Team } from "@/api/team";
2+
import { MultiSelect } from "@/components/blocks/multi-select";
23
import { Button } from "@/components/ui/button";
34
import { Input } from "@/components/ui/input";
5+
import { Label } from "@/components/ui/label";
6+
import {
7+
Select,
8+
SelectContent,
9+
SelectItem,
10+
SelectTrigger,
11+
SelectValue,
12+
} from "@/components/ui/select";
413
import { Textarea } from "@/components/ui/textarea";
514
import type { Account } from "@3rdweb-sdk/react/hooks/useApi";
6-
import { Flex, FormControl } from "@chakra-ui/react";
7-
import { Select as ChakraSelect } from "chakra-react-select";
815
import { useTrack } from "hooks/analytics/useTrack";
916
import { useLocalStorage } from "hooks/useLocalStorage";
1017
import { useTxNotifications } from "hooks/useTxNotifications";
1118
import { useMemo } from "react";
1219
import { useForm } from "react-hook-form";
13-
import { FormHelperText, FormLabel } from "tw-components";
1420
import { PlanToCreditsRecord } from "./ApplyForOpCreditsModal";
1521
import { applyOpSponsorship } from "./applyOpSponsorship";
1622

@@ -73,10 +79,8 @@ export const ApplyForOpCreditsForm: React.FC<ApplyForOpCreditsFormProps> = ({
7379
);
7480

7581
return (
76-
<Flex
77-
direction="column"
78-
gap={4}
79-
as="form"
82+
<form
83+
className="flex flex-col gap-4"
8084
onSubmit={form.handleSubmit(async (data) => {
8185
const fields = Object.keys(data).map((key) => ({
8286
name: key,
@@ -127,67 +131,84 @@ export const ApplyForOpCreditsForm: React.FC<ApplyForOpCreditsFormProps> = ({
127131
}
128132
})}
129133
>
130-
<Flex flexDir="column" gap={4}>
131-
<Flex gap={4}>
132-
<FormControl gap={6} isRequired>
133-
<FormLabel>First Name</FormLabel>
134+
<div className="flex flex-col gap-4">
135+
<div className="flex flex-col gap-4 md:flex-row">
136+
<div className="flex flex-1 flex-col gap-2">
137+
<Label>First Name</Label>
134138
<Input {...form.register("firstname", { required: true })} />
135-
</FormControl>
136-
<FormControl gap={6} isRequired>
137-
<FormLabel>Last Name</FormLabel>
139+
</div>
140+
<div className="flex flex-1 flex-col gap-2">
141+
<Label>Last Name</Label>
138142
<Input {...form.register("lastname", { required: true })} />
139-
</FormControl>
140-
</Flex>
143+
</div>
144+
</div>
141145

142-
<FormControl gap={6} isRequired>
143-
<FormLabel>Company Name</FormLabel>
146+
<div className="flex flex-col gap-2">
147+
<Label>Company Name</Label>
144148
<Input {...form.register("company", { required: true })} />
145-
</FormControl>
149+
</div>
146150

147-
<FormControl gap={6} isRequired>
148-
<FormLabel>Company Website</FormLabel>
151+
<div className="flex flex-col gap-2">
152+
<Label>Company Website</Label>
149153
<Input type="url" {...form.register("website", { required: true })} />
150-
<FormHelperText>URL should start with https://</FormHelperText>
151-
</FormControl>
152-
<FormControl gap={6} isRequired>
153-
<FormLabel>Company Social Account</FormLabel>
154+
<p className="text-muted-foreground text-sm">
155+
URL should start with https://
156+
</p>
157+
</div>
158+
<div className="flex flex-col gap-2">
159+
<Label>Company Social Account</Label>
154160
<Input
155161
type="url"
156162
{...form.register("twitterhandle", { required: true })}
157163
/>
158-
<FormHelperText>URL should start with https://</FormHelperText>
159-
</FormControl>
160-
<FormControl gap={6} isRequired>
161-
<FormLabel>Industry</FormLabel>
162-
<ChakraSelect
163-
options={[
164-
"DAOs",
165-
"Education & Community",
166-
"Fandom & Rewards",
167-
"Gaming & Metaverse",
168-
"Infra & Dev Tools",
169-
"NFTs",
170-
"Payments & Finance (DeFi)",
171-
"Security & Identity",
172-
"Social",
173-
"Other",
174-
].map((vertical) => ({
175-
label: vertical,
176-
value:
177-
vertical === "Payments & Finance (DeFi)" ? "DeFi" : vertical,
178-
}))}
179-
placeholder="Select industry"
180-
isRequired
181-
onChange={(value) => {
182-
if (value?.value) {
183-
form.setValue("superchain_verticals", value.value);
184-
}
164+
<p className="text-muted-foreground text-sm">
165+
URL should start with https://
166+
</p>
167+
</div>
168+
<div className="flex flex-col gap-2">
169+
<Label>Industry</Label>
170+
<Select
171+
onValueChange={(value) => {
172+
form.setValue("superchain_verticals", value);
185173
}}
186-
/>
187-
</FormControl>
188-
<FormControl gap={6} isRequired>
189-
<FormLabel>Chain</FormLabel>
190-
<ChakraSelect
174+
>
175+
<SelectTrigger>
176+
<SelectValue placeholder="Select industry" />
177+
</SelectTrigger>
178+
<SelectContent>
179+
{[
180+
"DAOs",
181+
"Education & Community",
182+
"Fandom & Rewards",
183+
"Gaming & Metaverse",
184+
"Infra & Dev Tools",
185+
"NFTs",
186+
"Payments & Finance (DeFi)",
187+
"Security & Identity",
188+
"Social",
189+
"Other",
190+
].map((vertical) => (
191+
<SelectItem
192+
key={vertical}
193+
value={
194+
vertical === "Payments & Finance (DeFi)" ? "DeFi" : vertical
195+
}
196+
>
197+
{vertical}
198+
</SelectItem>
199+
))}
200+
</SelectContent>
201+
</Select>
202+
</div>
203+
<div className="flex flex-col gap-2">
204+
<Label>Chain</Label>
205+
<MultiSelect
206+
selectedValues={(form.watch("superchain_chain") || "")
207+
.split(";")
208+
.filter(Boolean)}
209+
onSelectedValuesChange={(values) =>
210+
form.setValue("superchain_chain", values.join(";"))
211+
}
191212
options={[
192213
"Optimism",
193214
"Base",
@@ -208,27 +229,21 @@ export const ApplyForOpCreditsForm: React.FC<ApplyForOpCreditsFormProps> = ({
208229
label: chain === "Optimism" ? "OP Mainnet" : chain,
209230
value: chain,
210231
}))}
211-
onChange={(values) => {
212-
form.setValue(
213-
"superchain_chain",
214-
values.map(({ value }) => value).join(";"),
215-
);
216-
}}
217-
isMulti
218-
selectedOptionStyle="check"
219232
placeholder="Select chains"
220-
isRequired
233+
className="w-full"
221234
/>
222-
</FormControl>
223-
<FormControl gap={6}>
224-
<FormLabel>Tell us more about your project</FormLabel>
235+
</div>
236+
<div className="flex flex-col gap-2">
237+
<Label>Tell us more about your project</Label>
225238
<Textarea
226239
{...form.register("what_would_you_like_to_meet_about_")}
227240
placeholder="Tell us more about your project -- the more you share, the easier you make the approval process."
228241
/>
229-
<FormHelperText>Minimum 150 characters recommended.</FormHelperText>
230-
</FormControl>
231-
</Flex>
242+
<p className="text-muted-foreground text-sm">
243+
Minimum 150 characters recommended.
244+
</p>
245+
</div>
246+
</div>
232247
<div className="flex flex-row">
233248
<Button
234249
className="w-full"
@@ -238,6 +253,6 @@ export const ApplyForOpCreditsForm: React.FC<ApplyForOpCreditsFormProps> = ({
238253
{form.formState.isSubmitting ? "Applying..." : "Apply now"}
239254
</Button>
240255
</div>
241-
</Flex>
256+
</form>
242257
);
243258
};

0 commit comments

Comments
 (0)