feat: make server own tabs
CI / build-and-test (push) Canceled after 0s

This commit is contained in:
2026-10-20 16:18:36 +02:00
parent 1e4438ec5a
commit 0ca9f4d16a
31 changed files with 2101 additions and 892 deletions
+9 -9
View File
@@ -9,6 +9,7 @@ export type Role = 'admin' | 'viewer';
export type TabLine = { productName: string; quantity: number; unitPriceInCents: number };
/** An open tab as the server holds it: every terminal of the venue shows the same. */
export interface Tab {
tabId: string;
customerName: string;
@@ -16,11 +17,7 @@ export interface Tab {
totalInCents: number;
itemCount: number;
items: TabLine[] | null;
deviceId: string;
deviceName: string;
deviceLastSeenAt: string;
deviceRevokedAt: string | null;
lastReportedAt: string;
lastChangedAt: string;
plannedTabId: string | null;
email: string | null;
}
@@ -40,7 +37,8 @@ export interface Command {
createdAt: string;
processedAt: string | null;
result: string | null;
deviceId: string;
/** Null for a tab the server settled itself */
deviceId: string | null;
}
export interface Device {
@@ -259,8 +257,10 @@ export const tabsApi = {
// Devices API
export const devicesApi = {
get: (venueId: string) =>
api<{ device: Device | null }>(`/venues/${venueId}/devices`),
list: (venueId: string) =>
api<{ devices: Device[] }>(`/venues/${venueId}/devices`),
unpair: (venueId: string, deviceId: string) =>
api(`/venues/${venueId}/commands/devices/${deviceId}/revoke`, { method: 'POST' }),
generateCode: () => api<{ code: string; expiresAt: string }>('/devices/generation-code'),
};
@@ -285,7 +285,7 @@ export const commandsApi = {
);
},
create: (venueId: string, data: { tabId: string; type: string; expectedVersion: number; paymentMethod: string }) =>
api<{ id: string; status: string; warning?: string }>(`/venues/${venueId}/commands`, {
api<{ id: string; status: string; amountInCents: number }>(`/venues/${venueId}/commands`, {
method: 'POST',
body: JSON.stringify(data),
}),