Skip to content

Commit 563e6e0

Browse files
author
Amine Afia
committed
Replace custom Select component with native select in webhook filter UI
1 parent f0fc8ba commit 563e6e0

File tree

1 file changed

+30
-83
lines changed
  • apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/webhooks/components

1 file changed

+30
-83
lines changed

apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/webhooks/components/FilterDetailsStep.tsx

Lines changed: 30 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,13 @@ import {
1111
FormMessage,
1212
} from "@/components/ui/form";
1313
import { Input } from "@/components/ui/input";
14-
import {
15-
Select,
16-
SelectContent,
17-
SelectItem,
18-
SelectTrigger,
19-
SelectValue,
20-
} from "@/components/ui/select";
2114
import { Textarea } from "@/components/ui/textarea";
2215
import { useThirdwebClient } from "@/constants/thirdweb.client";
2316
import { useQueryClient } from "@tanstack/react-query";
2417
import type { UseFormReturn } from "react-hook-form";
2518

2619
import { MultiNetworkSelector } from "@/components/blocks/NetworkSelectors";
20+
import { cn } from "@/lib/utils";
2721
import { truncateMiddle } from "../utils/abiUtils";
2822
import type {
2923
AbiData,
@@ -305,97 +299,50 @@ export function FilterDetailsStep({
305299
{watchFilterType === "event" &&
306300
Object.keys(fetchedAbis).length > 0 &&
307301
eventSignatures.length > 0 ? (
308-
<Select
302+
<select
303+
className={cn(
304+
"flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background selection:bg-foreground/10 placeholder:text-muted-foreground placeholder:text-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm dark:selection:bg-foreground/20",
305+
)}
309306
value={field.value}
310-
onValueChange={(value) => {
311-
field.onChange(value);
312-
// Find the selected event
307+
onChange={(e) => {
308+
field.onChange(e.target.value);
313309
const selectedEvent = eventSignatures.find(
314-
(sig) => sig.signature === value,
310+
(sig) => sig.signature === e.target.value,
315311
);
316-
// Set the ABI for the event
317312
form.setValue("sigHashAbi", selectedEvent?.abi || "");
318313
}}
319314
>
320-
<SelectTrigger>
321-
<SelectValue placeholder="Select an event signature">
322-
{field.value
323-
? eventSignatures.find(
324-
(sig) => sig.signature === field.value,
325-
)?.name || ""
326-
: null}
327-
</SelectValue>
328-
</SelectTrigger>
329-
<SelectContent className="max-h-60 overflow-y-auto">
330-
{eventSignatures.map((event) => {
331-
// Truncate the hash for display purposes
332-
const truncatedHash = truncateMiddle(
333-
event.signature,
334-
6,
335-
4,
336-
);
337-
338-
return (
339-
<SelectItem
340-
key={event.signature}
341-
value={event.signature}
342-
title={event.name}
343-
>
344-
<div className="flex flex-col">
345-
<span className="font-medium">{event.name}</span>
346-
<span className="text-muted-foreground text-xs">
347-
Signature: {truncatedHash}
348-
</span>
349-
</div>
350-
</SelectItem>
351-
);
352-
})}
353-
</SelectContent>
354-
</Select>
315+
<option value="">Select an event signature</option>
316+
{eventSignatures.map((event) => (
317+
<option key={event.signature} value={event.signature}>
318+
{event.name} (Signature:{" "}
319+
{truncateMiddle(event.signature, 6, 4)})
320+
</option>
321+
))}
322+
</select>
355323
) : watchFilterType === "transaction" &&
356324
Object.keys(fetchedTxAbis).length > 0 &&
357325
functionSignatures.length > 0 ? (
358-
<Select
326+
<select
327+
className={cn(
328+
"flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background selection:bg-foreground/10 placeholder:text-muted-foreground placeholder:text-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm dark:selection:bg-foreground/20",
329+
)}
359330
value={field.value}
360-
onValueChange={(value) => {
361-
field.onChange(value);
362-
// Find the selected function
331+
onChange={(e) => {
332+
field.onChange(e.target.value);
363333
const selectedFunction = functionSignatures.find(
364-
(sig) => sig.signature === value,
334+
(sig) => sig.signature === e.target.value,
365335
);
366-
// Set the ABI for the function
367336
form.setValue("sigHashAbi", selectedFunction?.abi || "");
368337
}}
369338
>
370-
<SelectTrigger className="max-w-full">
371-
<SelectValue placeholder="Select a function signature">
372-
{field.value
373-
? functionSignatures.find(
374-
(sig) => sig.signature === field.value,
375-
)?.name || ""
376-
: null}
377-
</SelectValue>
378-
</SelectTrigger>
379-
<SelectContent className="max-h-60 max-w-[600px] overflow-y-auto">
380-
{functionSignatures.map((func) => (
381-
<SelectItem
382-
key={func.signature}
383-
value={func.signature}
384-
title={func.signature}
385-
className="w-full overflow-x-auto"
386-
>
387-
<div className="flex w-full flex-col">
388-
<span className="overflow-x-auto whitespace-nowrap pb-1 font-medium">
389-
{func.name}
390-
</span>
391-
<span className="overflow-x-auto text-muted-foreground text-xs">
392-
Selector: {func.signature}
393-
</span>
394-
</div>
395-
</SelectItem>
396-
))}
397-
</SelectContent>
398-
</Select>
339+
<option value="">Select a function signature</option>
340+
{functionSignatures.map((func) => (
341+
<option key={func.signature} value={func.signature}>
342+
{func.name} (Selector: {func.signature})
343+
</option>
344+
))}
345+
</select>
399346
) : (
400347
<Input
401348
placeholder={

0 commit comments

Comments
 (0)