From 3785fdb410dd375618cab4ff2e6f956e32817c1a Mon Sep 17 00:00:00 2001 From: fakz9 Date: Tue, 21 May 2024 06:17:29 +0300 Subject: [PATCH] feat: deal product services --- .../components/ServicesTable/columns.tsx | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/pages/ServicesPage/components/ServicesTable/columns.tsx b/src/pages/ServicesPage/components/ServicesTable/columns.tsx index 91366d4..20c0965 100644 --- a/src/pages/ServicesPage/components/ServicesTable/columns.tsx +++ b/src/pages/ServicesPage/components/ServicesTable/columns.tsx @@ -1,8 +1,25 @@ import {useMemo} from "react"; import {MRT_ColumnDef} from "mantine-react-table"; import {ServiceSchema} from "../../../../client"; +import {List} from "@mantine/core"; export const useServicesTableColumns = () => { + const getPriceRow = (service: ServiceSchema) => { + if (service.priceRanges.length == 0) + return <>{service.price}₽; + return ( + <> + + {service.priceRanges.map(range => ( + + {`${range.fromQuantity} - ${range.toQuantity}: ${range.price}₽`} + + ))} + + + ); + } + return useMemo[]>(() => [ { accessorKey: "category", @@ -23,7 +40,7 @@ export const useServicesTableColumns = () => { header: "Цена", enableGrouping: false, enableSorting: false, - + Cell: ({row}) => getPriceRow(row.original) }, ], []);