Files
TaxHacker_s23/components/forms/select-currency.tsx
2025-03-27 08:48:47 +01:00

35 lines
775 B
TypeScript

import { Currency } from "@prisma/client"
import { SelectProps } from "@radix-ui/react-select"
import { useMemo } from "react"
import { FormSelect } from "./simple"
export const FormSelectCurrency = ({
title,
currencies,
emptyValue,
placeholder,
hideIfEmpty = false,
...props
}: {
title: string
currencies: Currency[]
emptyValue?: string
placeholder?: string
hideIfEmpty?: boolean
} & SelectProps) => {
const items = useMemo(
() => currencies.map((currency) => ({ code: currency.code, name: `${currency.code} - ${currency.name}` })),
[currencies]
)
return (
<FormSelect
title={title}
items={items}
emptyValue={emptyValue}
placeholder={placeholder}
hideIfEmpty={hideIfEmpty}
{...props}
/>
)
}