Files
TaxHacker_s23/components/forms/select-category.tsx
2025-05-03 10:23:13 +02:00

37 lines
789 B
TypeScript

"use client"
import { Category } from "@/prisma/client"
import { SelectProps } from "@radix-ui/react-select"
import { useMemo } from "react"
import { FormSelect } from "./simple"
export const FormSelectCategory = ({
title,
categories,
emptyValue,
placeholder,
hideIfEmpty = false,
...props
}: {
title: string
categories: Category[]
emptyValue?: string
placeholder?: string
hideIfEmpty?: boolean
} & SelectProps) => {
const items = useMemo(
() => categories.map((category) => ({ code: category.code, name: category.name, color: category.color })),
[categories]
)
return (
<FormSelect
title={title}
items={items}
emptyValue={emptyValue}
placeholder={placeholder}
hideIfEmpty={hideIfEmpty}
{...props}
/>
)
}