OrderSets UI Improvement
This commit is contained in:
parent
66622c326d
commit
59d988d3d6
3 changed files with 56 additions and 9 deletions
|
|
@ -19,7 +19,7 @@ def pick_order(orders):
|
||||||
|
|
||||||
for add_on in picked.add_ons:
|
for add_on in picked.add_ons:
|
||||||
if add_on.probability > random.random():
|
if add_on.probability > random.random():
|
||||||
result.append(add_on.name)
|
result.append(f"+ {add_on.name}")
|
||||||
|
|
||||||
return (result, picked.repeat)
|
return (result, picked.repeat)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -146,6 +146,8 @@ def sub_order_sets(username, sub):
|
||||||
'time': op.time,
|
'time': op.time,
|
||||||
'weekends': op.weekends,
|
'weekends': op.weekends,
|
||||||
'weekdays': op.weekdays,
|
'weekdays': op.weekdays,
|
||||||
|
'probability': op.probability,
|
||||||
|
'punishment_pool_name': op.punishment_pool.name if op.punishment_pool is not None else None,
|
||||||
'orders': [{
|
'orders': [{
|
||||||
'id': order.id,
|
'id': order.id,
|
||||||
} for order in op.orders]
|
} for order in op.orders]
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,13 @@
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { Title, Card, Text, Flex, Badge, Box } from "@mantine/core";
|
import {
|
||||||
|
Title,
|
||||||
|
Card,
|
||||||
|
Text,
|
||||||
|
Flex,
|
||||||
|
Badge,
|
||||||
|
Box,
|
||||||
|
RingProgress,
|
||||||
|
} from "@mantine/core";
|
||||||
import { TimeValue } from "@mantine/dates";
|
import { TimeValue } from "@mantine/dates";
|
||||||
import { IconPencil, IconPlus, IconTrash } from "@tabler/icons-react";
|
import { IconPencil, IconPlus, IconTrash } from "@tabler/icons-react";
|
||||||
|
|
||||||
|
|
@ -10,8 +18,18 @@ import { useFetcher } from "react-router";
|
||||||
export interface OrderSetProps {
|
export interface OrderSetProps {
|
||||||
orderSets: (Pick<
|
orderSets: (Pick<
|
||||||
OrderSet,
|
OrderSet,
|
||||||
"id" | "name" | "scheduled" | "time" | "weekends" | "weekdays" | "orders"
|
| "id"
|
||||||
> & { orders: Pick<OrderSetOrder, "id" | "name"> })[];
|
| "name"
|
||||||
|
| "scheduled"
|
||||||
|
| "time"
|
||||||
|
| "weekends"
|
||||||
|
| "weekdays"
|
||||||
|
| "orders"
|
||||||
|
| "probability"
|
||||||
|
> & {
|
||||||
|
orders: Pick<OrderSetOrder, "id" | "name">;
|
||||||
|
punishment_pool_name: string;
|
||||||
|
})[];
|
||||||
username: string;
|
username: string;
|
||||||
linkBack?: React.ReactNode;
|
linkBack?: React.ReactNode;
|
||||||
}
|
}
|
||||||
|
|
@ -41,7 +59,17 @@ export const OrderSets: React.FC<OrderSetProps> = ({
|
||||||
<Flex gap="md" wrap="wrap">
|
<Flex gap="md" wrap="wrap">
|
||||||
{orderSets
|
{orderSets
|
||||||
? orderSets.map(
|
? orderSets.map(
|
||||||
({ id, name, scheduled, orders, time, weekdays, weekends }) => (
|
({
|
||||||
|
id,
|
||||||
|
name,
|
||||||
|
scheduled,
|
||||||
|
orders,
|
||||||
|
time,
|
||||||
|
weekdays,
|
||||||
|
weekends,
|
||||||
|
probability,
|
||||||
|
punishment_pool_name,
|
||||||
|
}) => (
|
||||||
<Card
|
<Card
|
||||||
key={id}
|
key={id}
|
||||||
shadow="sm"
|
shadow="sm"
|
||||||
|
|
@ -54,16 +82,33 @@ export const OrderSets: React.FC<OrderSetProps> = ({
|
||||||
<Flex direction="column" gap="md" h="100%">
|
<Flex direction="column" gap="md" h="100%">
|
||||||
<Title order={4}>{name}</Title>
|
<Title order={4}>{name}</Title>
|
||||||
{scheduled ? (
|
{scheduled ? (
|
||||||
<Flex gap="md" align="center">
|
<>
|
||||||
<Text>
|
<Text>
|
||||||
Scheduled: <TimeValue value={time} format="12h" />
|
Scheduled: <TimeValue value={time} format="12h" />
|
||||||
</Text>
|
</Text>
|
||||||
{weekdays ? <Badge color="blue">Weekdays</Badge> : null}
|
<Flex gap="md" align="center">
|
||||||
{weekends ? <Badge color="blue">Weekends</Badge> : null}
|
{weekdays ? (
|
||||||
</Flex>
|
<Badge color="blue">Weekdays</Badge>
|
||||||
|
) : null}
|
||||||
|
{weekends ? (
|
||||||
|
<Badge color="blue">Weekends</Badge>
|
||||||
|
) : null}
|
||||||
|
<RingProgress
|
||||||
|
size={80}
|
||||||
|
label={<Text size="xs">{probability * 100}%</Text>}
|
||||||
|
sections={[
|
||||||
|
{ color: "cyan", value: probability * 100 },
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
</Flex>
|
||||||
|
</>
|
||||||
) : null}
|
) : null}
|
||||||
<Text mb="md" flex={1}>
|
<Text mb="md" flex={1}>
|
||||||
Orders: {orders.length}
|
Orders: {orders.length}
|
||||||
|
<br />
|
||||||
|
{punishment_pool_name
|
||||||
|
? `Punishments: ${punishment_pool_name}`
|
||||||
|
: null}
|
||||||
</Text>
|
</Text>
|
||||||
<Flex gap="md" justify="end">
|
<Flex gap="md" justify="end">
|
||||||
<ConfirmDialogButton
|
<ConfirmDialogButton
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue