new product select

This commit is contained in:
2024-07-24 16:17:26 +03:00
parent 814c06301b
commit 8385d3a85c

View File

@@ -3,8 +3,7 @@ import {FC} from "react";
import useProductsList from "../../pages/ProductsPage/hooks/useProductsList.tsx";
import {omit} from "lodash";
import ObjectSelect, {ObjectSelectProps} from "../ObjectSelect/ObjectSelect.tsx";
import {Text, Tooltip} from "@mantine/core";
import {ComboboxLikeRenderOptionInput} from "@mantine/core/lib/components/Combobox";
import {SelectProps, Text, Tooltip} from "@mantine/core";
import {getProductFields} from "../../types/utils.ts";
type RestProps = {
@@ -14,7 +13,7 @@ type Props = Omit<ObjectSelectProps<ProductSchema>, 'data'> & RestProps;
const ProductSelect: FC<Props> = (props: Props) => {
const {products} = useProductsList({clientId: props.clientId});
const restProps = omit(props, ['clientId']);
const renderOption = (item: ComboboxLikeRenderOptionInput) => {
const renderOption: SelectProps['renderOption'] = (item) => {
const product = products.find(product => product.id == parseInt(item.option.value));
if (!product) return item.option.label;
const productFields = getProductFields(product);