feat(POS-FIX-6): completed feature
This commit is contained in:
@@ -3,11 +3,12 @@
|
||||
const API = '/api';
|
||||
|
||||
async function apiFetch<T>(path: string, init?: RequestInit): Promise<T> {
|
||||
const hasBody = init?.body !== undefined && init.body !== null && init.body !== '';
|
||||
const res = await fetch(`${API}${path}`, {
|
||||
...init,
|
||||
credentials: 'include',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
...(hasBody ? { 'Content-Type': 'application/json' } : {}),
|
||||
...(init?.headers ?? {}),
|
||||
},
|
||||
});
|
||||
@@ -102,6 +103,12 @@ export const posApi = {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ email }),
|
||||
}),
|
||||
/** Print receipt for any sale (pending, completed, refunded). */
|
||||
printReceipt: (orderId: string) =>
|
||||
apiFetch<{ url: string }>(`/pos/sales/${encodeURIComponent(orderId)}/print`),
|
||||
/** Get full receipt for a sale (used for returns). */
|
||||
getReceipt: <T>(orderId: string) =>
|
||||
apiFetch<T>(`/pos/sales/${encodeURIComponent(orderId)}/receipt`),
|
||||
};
|
||||
|
||||
export const authApi = {
|
||||
|
||||
Reference in New Issue
Block a user