import React from "react"; import { Title, Card, Text, Flex, Badge, Box, RingProgress, } 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" | "probability" > & { orders: Pick; punishment_pool_name: string; })[]; 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, probability, punishment_pool_name, }) => ( {name} {scheduled ? ( <> Scheduled: {time.split(",").map((time) => (
))}
{weekdays ? ( Weekdays ) : null} {weekends ? ( Weekends ) : null} {probability * 100}%} sections={[ { color: "cyan", value: probability * 100 }, ]} /> ) : null} Orders: {orders.length}
{punishment_pool_name ? `Punishments: ${punishment_pool_name}` : null}
handleDelete(id)} > Edit
), ) : null}
New ); };