feat: deal product services
This commit is contained in:
@@ -1,8 +1,25 @@
|
|||||||
import {useMemo} from "react";
|
import {useMemo} from "react";
|
||||||
import {MRT_ColumnDef} from "mantine-react-table";
|
import {MRT_ColumnDef} from "mantine-react-table";
|
||||||
import {ServiceSchema} from "../../../../client";
|
import {ServiceSchema} from "../../../../client";
|
||||||
|
import {List} from "@mantine/core";
|
||||||
|
|
||||||
export const useServicesTableColumns = () => {
|
export const useServicesTableColumns = () => {
|
||||||
|
const getPriceRow = (service: ServiceSchema) => {
|
||||||
|
if (service.priceRanges.length == 0)
|
||||||
|
return <>{service.price}₽</>;
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<List>
|
||||||
|
{service.priceRanges.map(range => (
|
||||||
|
<List.Item>
|
||||||
|
{`${range.fromQuantity} - ${range.toQuantity}: ${range.price}₽`}
|
||||||
|
</List.Item>
|
||||||
|
))}
|
||||||
|
</List>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return useMemo<MRT_ColumnDef<ServiceSchema>[]>(() => [
|
return useMemo<MRT_ColumnDef<ServiceSchema>[]>(() => [
|
||||||
{
|
{
|
||||||
accessorKey: "category",
|
accessorKey: "category",
|
||||||
@@ -23,7 +40,7 @@ export const useServicesTableColumns = () => {
|
|||||||
header: "Цена",
|
header: "Цена",
|
||||||
enableGrouping: false,
|
enableGrouping: false,
|
||||||
enableSorting: false,
|
enableSorting: false,
|
||||||
|
Cell: ({row}) => getPriceRow(row.original)
|
||||||
|
|
||||||
},
|
},
|
||||||
], []);
|
], []);
|
||||||
|
|||||||
Reference in New Issue
Block a user