"use client";

import { FC } from "react";
import useBarcodeTemplatesList from "@/app/barcode-templates/hooks/useBarcodeTemplatesList";
import ObjectSelect, {
    ObjectSelectProps,
} from "@/components/selects/ObjectSelect/ObjectSelect";
import { BarcodeTemplateSchema } from "@/lib/client";

type Props = Omit<ObjectSelectProps<BarcodeTemplateSchema>, "data">;

const BarcodeTemplateSelect: FC<Props> = props => {
    const { barcodeTemplates } = useBarcodeTemplatesList();

    return (
        <ObjectSelect
            data={barcodeTemplates}
            getLabelFn={template =>
                `${template.name} (${template.attributes.map(a => a.name).join(", ")})`
            }
            {...props}
        />
    );
};

export default BarcodeTemplateSelect;
