import React from "react"; import { Title, Card, Text, Flex, Badge, Box } from "@mantine/core"; import { TimeValue } from "@mantine/dates"; import { IconPencil, IconPlus, IconTrash } from "@tabler/icons-react"; import { ConfirmDialogButton } from "./ConfirmDialogButton"; import { NavigateButton } from "./NavigateButton"; import { useFetcher } from "react-router"; export interface OrderSetProps { orderSets: (Pick< OrderSet, "id" | "name" | "scheduled" | "time" | "weekends" | "weekdays" | "orders" > & { orders: Pick })[]; username: string; linkBack?: React.ReactNode; } export const OrderSets: React.FC = ({ orderSets, username, linkBack, }) => { const fetcher = useFetcher(); const handleDelete = React.useCallback( (id: number) => { fetcher.submit(null, { action: `/orders/${username}/${id}`, method: "DELETE", }); }, [fetcher], ); return ( <> Order Sets for {username} {linkBack ? linkBack : null} {orderSets ? orderSets.map( ({ id, name, scheduled, orders, time, weekdays, weekends }) => ( {name} {scheduled ? ( Scheduled: {weekdays ? Weekdays : null} {weekends ? Weekends : null} ) : null} Orders: {orders.length} handleDelete(id)} > Edit ), ) : null} New ); };