feat: price by category
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import {BaseMarketplaceSchema} from "../client";
|
||||
import { BaseMarketplaceSchema, ServicePriceCategorySchema } from "../client";
|
||||
|
||||
export type QuickDeal = {
|
||||
name: string;
|
||||
@@ -7,5 +7,6 @@ export type QuickDeal = {
|
||||
comment: string;
|
||||
acceptanceDate: Date;
|
||||
shippingWarehouse: string;
|
||||
baseMarketplace: BaseMarketplaceSchema
|
||||
baseMarketplace: BaseMarketplaceSchema;
|
||||
category?: ServicePriceCategorySchema;
|
||||
}
|
||||
14
src/types/UseObjectState.ts
Normal file
14
src/types/UseObjectState.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
type UseObjectState<T> = {
|
||||
onCreateClick?: () => void;
|
||||
onCreate: (values: T) => void;
|
||||
|
||||
onDeleteClick?: (item: T) => void;
|
||||
onDelete: (item: T) => void;
|
||||
|
||||
onChangeClick?: (item: T) => void;
|
||||
onChange: (item: T) => void;
|
||||
|
||||
objects: T[];
|
||||
}
|
||||
|
||||
export default UseObjectState;
|
||||
@@ -1,6 +1,9 @@
|
||||
import {ProductSchema} from "../client";
|
||||
import {isNil} from "lodash";
|
||||
import {ProductFieldNames} from "../pages/LeadsPage/tabs/ProductAndServiceTab/components/ProductView/ProductView.tsx";
|
||||
import { ProductSchema } from "../client";
|
||||
import { isNil } from "lodash";
|
||||
import { ProductFieldNames } from "../pages/LeadsPage/tabs/ProductAndServiceTab/components/ProductView/ProductView.tsx";
|
||||
import UseObjectState from "./UseObjectState.ts";
|
||||
import { CRUDTableProps } from "./CRUDTable.tsx";
|
||||
import { MRT_RowData } from "mantine-react-table";
|
||||
|
||||
export type ObjectWithNameAndId = {
|
||||
id: number;
|
||||
@@ -14,12 +17,22 @@ 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;
|
||||
if (!fieldName || isNil(value) || value === "" || !value) return;
|
||||
return [fieldName.toString(), value.toString()];
|
||||
}).filter(obj => obj !== undefined) || [];
|
||||
};
|
||||
|
||||
|
||||
export function ObjectStateToTableProps<T extends MRT_RowData>(state: UseObjectState<T>): CRUDTableProps<T> {
|
||||
return {
|
||||
items: state.objects,
|
||||
onDelete: state.onDelete,
|
||||
onChange: state.onChange,
|
||||
onCreate: state.onCreate,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user