Download apps/customer-web/lib/offlineCartQueue.ts from ADI576/proflo: direct link, hf CLI and curl.
- Browser
- Download file 862 Bytes
-
https://huggingface.co/spaces/ADI576/proflo/resolve/main/apps/customer-web/lib/offlineCartQueue.ts
- Command line
-
hf download hf://spaces/ADI576/proflo/apps/customer-web/lib/offlineCartQueue.ts
-
curl -L -o offlineCartQueue.ts https://huggingface.co/spaces/ADI576/proflo/resolve/main/apps/customer-web/lib/offlineCartQueue.ts
862 Bytes
| const QUEUE_KEY = "proflo-offline-cart-queue"; | |
| const MAX = 25; | |
| export type QueuedCartAdd = { barcode: string; qty: number; enqueuedAt: string }; | |
| export function readOfflineQueue(): QueuedCartAdd[] { | |
| if (typeof window === "undefined") return []; | |
| try { | |
| const raw = sessionStorage.getItem(QUEUE_KEY); | |
| if (!raw) return []; | |
| const p = JSON.parse(raw) as QueuedCartAdd[]; | |
| return Array.isArray(p) ? p : []; | |
| } catch { | |
| return []; | |
| } | |
| } | |
| export function writeOfflineQueue(items: QueuedCartAdd[]) { | |
| sessionStorage.setItem(QUEUE_KEY, JSON.stringify(items.slice(-MAX))); | |
| } | |
| export function enqueueOfflineAdd(barcode: string, qty: number) { | |
| const next = [...readOfflineQueue(), { barcode, qty, enqueuedAt: new Date().toISOString() }]; | |
| writeOfflineQueue(next); | |
| } | |
| export function clearOfflineQueue() { | |
| sessionStorage.removeItem(QUEUE_KEY); | |
| } | |