76 lines
2.0 KiB
TypeScript
76 lines
2.0 KiB
TypeScript
import { getJson, postJson, putJson } from './client';
|
|
|
|
export type WaiterAssignment = {
|
|
waiterId: string;
|
|
tableId: string;
|
|
status: string;
|
|
activeOrders: number;
|
|
};
|
|
|
|
export type WaiterAssignmentsResponse = {
|
|
contextId: string;
|
|
locationId: string;
|
|
summary: string;
|
|
assignments: WaiterAssignment[];
|
|
recentActivity: string[];
|
|
};
|
|
|
|
export type WaiterRecentActivityResponse = {
|
|
contextId: string;
|
|
locationId: string;
|
|
summary: string;
|
|
recentActivity: string[];
|
|
};
|
|
|
|
export type SubmitFloorOrderRequest = {
|
|
contextId: string;
|
|
tableId: string;
|
|
orderId: string;
|
|
itemCount: number;
|
|
};
|
|
|
|
export type SubmitFloorOrderResponse = {
|
|
contextId: string;
|
|
orderId: string;
|
|
accepted: boolean;
|
|
summary: string;
|
|
status: string;
|
|
processedAtUtc: string;
|
|
};
|
|
|
|
export type UpdateFloorOrderRequest = {
|
|
contextId: string;
|
|
tableId: string;
|
|
orderId: string;
|
|
itemCount: number;
|
|
};
|
|
|
|
export type UpdateFloorOrderResponse = {
|
|
contextId: string;
|
|
orderId: string;
|
|
accepted: boolean;
|
|
summary: string;
|
|
status: string;
|
|
processedAtUtc: string;
|
|
};
|
|
|
|
export async function loadDashboard(contextId: string): Promise<WaiterAssignmentsResponse> {
|
|
return getJson<WaiterAssignmentsResponse>(`/api/waiter/floor/assignments?contextId=${encodeURIComponent(contextId)}`);
|
|
}
|
|
|
|
export async function loadRecentActivity(contextId: string): Promise<WaiterRecentActivityResponse> {
|
|
return getJson<WaiterRecentActivityResponse>(`/api/waiter/floor/activity?contextId=${encodeURIComponent(contextId)}`);
|
|
}
|
|
|
|
export async function submitFloorOrder(request: SubmitFloorOrderRequest): Promise<SubmitFloorOrderResponse> {
|
|
return postJson<SubmitFloorOrderResponse>('/api/waiter/floor/orders', request);
|
|
}
|
|
|
|
export async function updateFloorOrder(request: UpdateFloorOrderRequest): Promise<UpdateFloorOrderResponse> {
|
|
return putJson<UpdateFloorOrderResponse>(`/api/waiter/floor/orders/${encodeURIComponent(request.orderId)}`, {
|
|
contextId: request.contextId,
|
|
tableId: request.tableId,
|
|
itemCount: request.itemCount
|
|
});
|
|
}
|