/** biome-ignore-all lint/a11y/noStaticElementInteractions: yes maam */ "use client"; import { FileSearch2, RefreshCw, X } from "lucide-react"; import { type ComponentProps, useEffect, useRef, useState } from "react"; import { b2sClient } from "@/app/(ui)/admin/cdn/table"; import { useFormContext } from "@/components/form"; import { SimpleTooltip } from "@/components/tooltip"; import { Button } from "@/components/ui/button"; import { InputGroup, InputGroupAddon, InputGroupInput, } from "@/components/ui/input-group"; import { Input } from "@/components/ui/input"; import { Kbd } from "@/components/ui/kbd"; import { Label } from "@/components/ui/label"; import { MultiSelect, MultiSelectContent, MultiSelectGroup, MultiSelectItem, MultiSelectTrigger, MultiSelectValue, } from "@/components/ui/multi-select"; import { cn } from "@/lib/utils"; import { VirtualizedComboBox } from "@/components/combobox"; import { Spinner } from "@/components/ui/spinner"; export function CurrencyInput(props: ComponentProps) { return ( ฿ ); } export function PriceInput() { const { values, setValue } = useFormContext(); return (
setValue("price", e.target.value)} /> บาท
); } export function ServiceSelect({ types, onValueChange, value = "", }: { types: { id: string; display: string; price: number }[]; onValueChange?: (v: string) => void; value?: string; }) { return ( onValueChange?.(v.filter(Boolean).join(","))} > {types.map((t) => ( {t.display}{" "} {t.price} บาท ))} ); } export function SlipUpload({ value: externalValue, onValueChange, }: { value?: File | null | undefined; onValueChange?: (value: File | null) => void; }) { const ref = useRef(null); const [value, setValue] = useState(externalValue); const isSelected = !!value?.name; useEffect(() => { if ( typeof externalValue === "object" && externalValue && Object.keys(externalValue).length === 0 ) // ignore {} return; setValue(externalValue); }, [externalValue]); function choose() { ref.current?.click(); } return ( <> { const file = ref.current?.files?.[0] || null; setValue(file); onValueChange?.(file); }} /> ); } export function UserSelect({ value, onValueChange, }: { value?: string; onValueChange?: (value: string) => void; }) { const [loading, setLoading] = useState(false); const [users, setUsers] = useState< { username: string; uid: string; display: string }[] >([]); const [bump, setBump] = useState(0); useEffect(() => { setLoading(true); fetch("/api/discord/users") .then((r) => r.json()) .then(setUsers) .finally(() => setLoading(false)); }, [bump]); return (
({ label: ( <> {e.display} {e.username} ), context: [e.display, e.username], value: e.uid, }))} className="grow bg-transparent! hover:bg-accent!" />
); }