new product select
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user