diff --git a/src/modules/dealModularEditorTabs/FulfillmentBase/desktop/components/ProductView/components/ProductFieldsList.tsx b/src/modules/dealModularEditorTabs/FulfillmentBase/desktop/components/ProductView/components/ProductFieldsList.tsx index 1315a77..884049f 100644 --- a/src/modules/dealModularEditorTabs/FulfillmentBase/desktop/components/ProductView/components/ProductFieldsList.tsx +++ b/src/modules/dealModularEditorTabs/FulfillmentBase/desktop/components/ProductView/components/ProductFieldsList.tsx @@ -20,16 +20,22 @@ type Props = { product: ProductSchema; }; +export const getProductFieldList = (product: ProductSchema) => { + return Object.entries(product) + .map(([key, value]) => { + const fieldName = ProductFieldNames[key as keyof ProductSchema]; + if (!fieldName || isNil(value) || value === "") return null; + return ( + + {fieldName}: {value.toString()}{" "} + + ); + }) + .filter(obj => !!obj); +}; + const ProductFieldsList: FC = ({ product }) => { - const fieldList = Object.entries(product).map(([key, value]) => { - const fieldName = ProductFieldNames[key as keyof ProductSchema]; - if (!fieldName || isNil(value) || value === "") return null; - return ( - - {fieldName}: {value.toString()}{" "} - - ); - }); + const fieldList = getProductFieldList(product); return <>{fieldList}; }; diff --git a/src/modules/dealModularEditorTabs/FulfillmentBase/shared/components/ProductSelect/utils/renderProductOption.tsx b/src/modules/dealModularEditorTabs/FulfillmentBase/shared/components/ProductSelect/utils/renderProductOption.tsx index 9f51ad5..9c3b9f3 100644 --- a/src/modules/dealModularEditorTabs/FulfillmentBase/shared/components/ProductSelect/utils/renderProductOption.tsx +++ b/src/modules/dealModularEditorTabs/FulfillmentBase/shared/components/ProductSelect/utils/renderProductOption.tsx @@ -1,11 +1,18 @@ import { + Box, ComboboxItem, ComboboxLikeRenderOptionInput, + Image, + rem, SelectProps, + Stack, + Text, Tooltip, } from "@mantine/core"; import { ProductSchema } from "@/lib/client"; -import ProductFieldsList from "@/modules/dealModularEditorTabs/FulfillmentBase/desktop/components/ProductView/components/ProductFieldsList"; +import ProductFieldsList, { + getProductFieldList, +} from "@/modules/dealModularEditorTabs/FulfillmentBase/desktop/components/ProductView/components/ProductFieldsList"; const renderProductOption = ( products: ProductSchema[] @@ -15,34 +22,35 @@ const renderProductOption = ( product => product.id === Number(item.option.value) ); if (!product) return item.option.label; - // const imageUrl = - // product.images && product.images[0] - // ? product.images[0].imageUrl - // : undefined; + + const fieldsList = getProductFieldList(product); return ( + - {/*{imageUrl && (*/} - {/* */} - {/*)}*/} - + {product.imageUrl && ( + {product.name} + )} + }> -
+ {product.name}
- {/*{product.barcodes && (*/} - {/* {product.barcodes[0]}*/} - {/*)}*/} -
+ {product.barcodes && ( + {product.barcodes[0]} + )} +
); };