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