Skip to content

Commit 560fde7

Browse files
committed
Update UX, add stability and change pizzas
1 parent d7cfd72 commit 560fde7

6 files changed

Lines changed: 76 additions & 79 deletions

File tree

src/app/admin/prepare/order/page.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ const ItemTracker = ({
149149
textColor="white"
150150
className="font-medium"
151151
>
152-
{assignMode ? t('Admin.OrderManager.Actions.cancel') : t('Admin.OrderManager.Actions.assignToOrder')}
152+
{assignMode ? t('Admin.OrderManager.Actions.cancel') : t('Admin.OrderManager.Actions.assignToOrder', { count: selectedTickets.size })}
153153
</Button>
154154
<Button
155155
onClick={() => setSelectedTickets(new Set())}
@@ -544,6 +544,12 @@ export default function OrderManagerDashboard() {
544544
},
545545
});
546546

547+
const retrieveOrder = (id: string) => {
548+
if (window.confirm(`Are you sure you want to retrieve the order?`)) {
549+
retrieveOrderMutation.mutate({ id });
550+
}
551+
}
552+
547553
const assignTicketsMutation = useMutation({
548554
mutationFn: async ({ ticketIds, orderId }: { ticketIds: string[]; orderId: string }) => {
549555
const promises = ticketIds.map(ticketId =>
@@ -690,9 +696,7 @@ export default function OrderManagerDashboard() {
690696
id: order._id.toString(),
691697
ignoreTickets
692698
})}
693-
onRetrieve={() => retrieveOrderMutation.mutate({
694-
id: order._id.toString(),
695-
})}
699+
onRetrieve={() => retrieveOrder(order._id.toString())}
696700
onTogglePaid={() => togglePaidMutation.mutate({
697701
order: order,
698702
isPaid: !order.isPaid

src/app/admin/prepare/pizza/page.tsx

Lines changed: 42 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use client'
22

33
import React, { useEffect, useMemo, useState } from 'react';
4-
import { AlertCircle, Clock, Trash2, X } from 'lucide-react';
4+
import { Clock, Trash2 } from 'lucide-react';
55
import { Heading } from "@/app/components/layout/Heading";
66
import { useTranslations } from 'next-intl';
77
import { timeslotToDate, timeslotToLocalTime } from "@/lib/time";
@@ -12,6 +12,7 @@ import { deleteTicket, updateTicket, useTickets } from "@/lib/fetch/ticket";
1212
import { ItemTicketDocumentWithItem, TICKET_STATUS, TicketStatus } from "@/model/ticket";
1313
import Button from '@/app/components/Button';
1414
import SearchInput from "@/app/components/SearchInput";
15+
import ErrorMessage from "@/app/components/ErrorMessage";
1516

1617
const PizzaMakerStation = () => {
1718
const queryClient = useQueryClient();
@@ -194,15 +195,15 @@ const PizzaMakerStation = () => {
194195
disabled={selectedTickets.size === 0}
195196
className="w-full py-4 text-lg font-semibold bg-green-500 hover:bg-green-600 disabled:bg-gray-300 disabled:cursor-not-allowed rounded-xl"
196197
>
197-
Mark Ready ({selectedTickets.size})
198+
{t('Admin.Prepare.Actions.markReady', { count: selectedTickets.size })}
198199
</Button>
199200

200201
<Button
201202
onClick={markSelectedNotReady}
202203
disabled={selectedTickets.size === 0}
203204
className="w-full py-4 text-lg font-semibold bg-yellow-500 hover:bg-yellow-600 disabled:bg-gray-300 disabled:cursor-not-allowed rounded-xl"
204205
>
205-
Mark Not Ready ({selectedTickets.size})
206+
{t('Admin.Prepare.Actions.markNotReady', { count: selectedTickets.size })}
206207
</Button>
207208

208209
<Button
@@ -211,7 +212,7 @@ const PizzaMakerStation = () => {
211212
className="w-full py-4 text-lg font-semibold bg-red-500 hover:bg-red-600 disabled:bg-gray-300 disabled:cursor-not-allowed rounded-xl flex items-center justify-center gap-2"
212213
>
213214
<Trash2 className="w-5 h-5"/>
214-
Delete Tickets ({selectedTickets.size})
215+
{t('Admin.Prepare.Actions.deleteTickets', { count: selectedTickets.size })}
215216
</Button>
216217
</div>
217218

@@ -226,38 +227,43 @@ const PizzaMakerStation = () => {
226227
return 1
227228
}
228229
return (timeslotToDate(a.timeslot)?.getTime() || 0) - (timeslotToDate(b.timeslot)?.getTime() || 0)
229-
}).map(ticket => (
230-
<button
231-
key={`${ticket._id.toString()}-${ticket.status}`}
232-
onClick={() => toggleTicketSelection(ticket._id.toString())}
233-
className={`
234-
border-2 px-4 py-3 rounded-xl text-base flex items-center justify-between cursor-pointer
235-
transition-all duration-200 hover:shadow-md
236-
${ticket.status !== TICKET_STATUS.DEMANDED && !selectedTickets.has(ticket._id.toString())
237-
? 'bg-green-50 border-green-200 text-gray-600'
238-
: 'bg-white'
239-
}
240-
${ticket.status !== TICKET_STATUS.DEMANDED && selectedTickets.has(ticket._id.toString())
241-
? 'border-blue-500 border-green-200 text-gray-600'
242-
: 'bg-white'
243-
}
244-
${selectedTickets.has(ticket._id.toString()) ? 'border-blue-500' : 'border-gray-200 hover:border-gray-300'}
245-
`}
246-
>
247-
<div className="flex flex-col">
248-
<span className="font-semibold">{ticket.itemTypeRef.name}</span>
249-
{ticket?.orderId && (
250-
<span
251-
className="text-sm text-gray-500">Order: {ticket.orderId.toString().slice(-6)}</span>
230+
}).map(ticket => {
231+
let color = ''
232+
let border = ''
233+
234+
if (ticket.status === TICKET_STATUS.DEMANDED) {
235+
color = 'gray'
236+
} else {
237+
border = 'green'
238+
}
239+
240+
if (selectedTickets.has(ticket._id.toString())) {
241+
border = 'primary'
242+
}
243+
244+
return (
245+
<Button
246+
key={`${ticket._id.toString()}-${ticket.status}`}
247+
onClick={() => toggleTicketSelection(ticket._id.toString())}
248+
color={color}
249+
border={border}
250+
className="px-4 py-3 rounded-xl text-base flex items-center justify-between"
251+
>
252+
<div className="flex flex-col">
253+
<span className="font-semibold">{ticket.itemTypeRef.name}</span>
254+
{ticket?.orderId && (
255+
<span
256+
className="text-sm text-gray-500">Order: {ticket.orderId.toString().slice(-6)}</span>
257+
)}
258+
</div>
259+
{ticket.timeslot && (
260+
<span className="bg-gray-100 py-1 px-3 rounded-full text-sm font-medium">
261+
{timeslotToLocalTime(ticket.timeslot)}
262+
</span>
252263
)}
253-
</div>
254-
{ticket.timeslot && (
255-
<span className="bg-gray-100 py-1 px-3 rounded-full text-sm font-medium">
256-
{timeslotToLocalTime(ticket.timeslot)}
257-
</span>
258-
)}
259-
</button>
260-
))}
264+
</Button>
265+
);
266+
})}
261267
</div>
262268

263269
{upcomingItems.size === 0 && (
@@ -316,17 +322,7 @@ const PizzaMakerStation = () => {
316322

317323
{/* Error Toast */}
318324
{error && (
319-
<div
320-
className="fixed bottom-8 right-8 bg-red-500 text-white rounded-xl px-6 py-4 flex items-center gap-3 shadow-2xl z-50">
321-
<AlertCircle className="w-6 h-6"/>
322-
<span className="font-medium">{error}</span>
323-
<button
324-
onClick={() => setError('')}
325-
className="ml-2 text-white hover:text-gray-200"
326-
>
327-
<X className="w-5 h-5"/>
328-
</button>
329-
</div>
325+
<ErrorMessage error={error}/>
330326
)}
331327
</>
332328
);

src/app/api/system/reset/route.ts

Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,11 @@ async function initAndLoadConfig(): Promise<EditableConfig> {
8181

8282

8383
const pizzasByName = {
84-
Salami: ["Cheese 🧀", "Tomato Sauce 🍅", "Salami 🍕"],
85-
"Ham and mushrooms": ["Cheese 🧀", "Tomato Sauce 🍅", "Ham 🥓", "Mushrooms 🍄"],
86-
Capricciosa: ["Cheese 🧀", "Tomato Sauce 🍅", "Mushrooms 🍄", "Artichokes 🌱", "Olives 🫒", "Ham 🥓", "Basil 🌿"],
87-
Margherita: ["Cheese 🧀", "Tomato Sauce 🍅", "Basil 🌿"],
88-
Veggies: ["Cheese 🧀", "Tomato Sauce 🍅", "Mushrooms 🍄", "Onions 🧅", "Green Peppers 🫑", "Olives 🫒"],
89-
"Margherita vegan": ["Vegan Cheese 🧀", "Tomato Sauce 🍅", "Basil 🌿"],
90-
"Capricciosa vegan": ["Vegan Cheese 🧀", "Tomato Sauce 🍅", "Mushrooms 🍄", "Artichokes 🌱", "Olives 🫒", "Basil 🌿"]
84+
Salami: ["Cheese 🧀", "Salami 🍕"],
85+
Margherita: ["Cheese 🧀", "Cherry Tomatoes 🍅", "Basil 🌿"],
86+
Veggies: ["Cheese 🧀", "Mushrooms 🍄", "Onions 🧅", "Red Bell Peppers 🫑", "Tomatoes 🍅", "Olives 🫒"],
87+
"Margherita vegan": ["Vegan Cheese 🧀", "Cherry Tomaten 🍅", "Basil 🌿"],
88+
"Veggies vegan": ["Vegan Cheese 🧀", "Mushrooms 🍄", "Onions 🧅", "Red Bell Peppers 🫑", "Tomatoes 🍅", "Olives 🫒"],
9189
};
9290

9391
/**
@@ -97,7 +95,7 @@ const pizzasByName = {
9795
export async function GET() {
9896
await dbConnect();
9997
await initAndLoadConfig()
100-
return Response.json({ status: "success" });
98+
return Response.json({ message: 'Successfully basic reconfigured system. You have to reset the database!' })
10199
}
102100

103101
/**
@@ -123,22 +121,6 @@ export async function POST() {
123121
ingredients: pizzasByName['Salami'],
124122
size: 0.5
125123
},
126-
{
127-
name: 'Ham and mushrooms half',
128-
price: 4,
129-
dietary: 'meat',
130-
type: 'pizza',
131-
ingredients: pizzasByName['Ham and mushrooms'],
132-
size: 0.5
133-
},
134-
{
135-
name: 'Capricciosa half',
136-
price: 4,
137-
type: 'pizza',
138-
dietary: 'meat',
139-
ingredients: pizzasByName['Capricciosa'],
140-
size: 0.5
141-
},
142124
{ name: 'Margherita half', price: 6, type: 'pizza', ingredients: pizzasByName['Margherita'], size: 0.5 },
143125
{ name: 'Veggies half', price: 6, type: 'pizza', ingredients: pizzasByName['Veggies'], size: 0.5 },
144126
{
@@ -150,11 +132,11 @@ export async function POST() {
150132
size: 0.5
151133
},
152134
{
153-
name: 'Capricciosa vegan half',
135+
name: 'Veggies vegan half',
154136
price: 3,
155137
dietary: 'vegan',
156138
type: 'pizza',
157-
ingredients: pizzasByName['Capricciosa vegan'],
139+
ingredients: pizzasByName['Veggies vegan'],
158140
size: 0.5
159141
},
160142
];
@@ -164,5 +146,5 @@ export async function POST() {
164146

165147
await initAndLoadConfig()
166148

167-
return Response.json({ message: 'Successfully reset system' })
149+
return Response.json({ message: 'Successfully reconfigured system' })
168150
}

src/app/components/Button.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,16 @@ const Button = (button: ButtonProps) => {
3838
const isDisabled = button.disabled || isRateLimited;
3939
let color: string = '';
4040
if (button.color) {
41-
if (button.color !== "white" && button.color !== "black") {
41+
if (button.color !== "white" && button.color !== "black" && button.color !== "gray") {
4242
color = `bg-${button.color}-500`;
4343
if (!isDisabled) {
4444
color += ` hover:bg-${button.color}-600`
4545
}
46+
} else if (button.color === "gray") {
47+
color = `bg-${button.color}-100`;
48+
if (!isDisabled) {
49+
color += ` hover:bg-${button.color}-300`
50+
}
4651
} else if (button.color === "white") {
4752
color = "bg-white";
4853
} else if (button.color === "black") {

src/i18n/locales/de.yaml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,11 @@ translation:
180180
status: Status
181181
is_done: ✅ Erledigt
182182

183+
Actions:
184+
markReady: 'Fertig ({count})'
185+
markNotReady: 'Nicht fertig ({count})'
186+
deleteTickets: 'Tickets löschen ({count})'
187+
183188
OrderManager:
184189
title: "Ausgabestation"
185190
description: "Verfolge Artikel und liefere Bestellungen aus"
@@ -196,7 +201,7 @@ translation:
196201

197202
# Buttons and Actions
198203
Actions:
199-
assignToOrder: "Bestellung zuweisen"
204+
assignToOrder: "Bestellung zuweisen ({count})"
200205
cancel: "Abbrechen"
201206
clear: "Leeren"
202207
markReady: "Als fertig markieren"

src/i18n/locales/en.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,11 @@ translation:
178178
status: Status
179179
is_done: ✅ Done
180180

181+
Actions:
182+
markReady: 'Mark Ready ({count})'
183+
markNotReady: 'Mark Not Ready ({count})'
184+
deleteTickets: 'Delete Tickets ({count})'
185+
181186
OrderManager:
182187
title: "Delivery Station"
183188
description: "Track items and deliver orders"

0 commit comments

Comments
 (0)