new product select
This commit is contained in:
@@ -1,3 +1,8 @@
|
||||
import {ProductSchema} from "../client";
|
||||
import {isNil} from "lodash";
|
||||
import {Text} from "@mantine/core";
|
||||
import {ProductFieldNames} from "../pages/LeadsPage/tabs/ProductAndServiceTab/components/ProductView/ProductView.tsx";
|
||||
|
||||
export type ObjectWithNameAndId = {
|
||||
id: number;
|
||||
name: string;
|
||||
@@ -10,4 +15,12 @@ export type BaseFormInputProps<T> = {
|
||||
}
|
||||
export const formatDate = (date: string) => {
|
||||
return new Date(date).toLocaleDateString("ru-RU");
|
||||
}
|
||||
|
||||
export const getProductFields = (product: ProductSchema) => {
|
||||
return Object.entries(product).map(([key, value]) => {
|
||||
const fieldName = ProductFieldNames[key as keyof ProductSchema];
|
||||
if (!fieldName || isNil(value) || value === '' || !value) return;
|
||||
return [fieldName.toString(), value.toString()];
|
||||
}).filter(obj => obj !== undefined) || [];
|
||||
}
|
||||
Reference in New Issue
Block a user