Replace the profile tab with prescription management (inline reminders and family invite), add a shared tab top bar, separate notifications from orders, and support any-branch guest checkout with GSH codes. Co-authored-by: Cursor <cursoragent@cursor.com>
32 lines
971 B
TypeScript
32 lines
971 B
TypeScript
/** Shared commerce numbers so cart, checkout and orders stay consistent. */
|
|
export const DELIVERY_FEE = 80;
|
|
export const DEMO_VOUCHER = "GISHEN10";
|
|
export const DEMO_VOUCHER_PCT = 0.1;
|
|
export const DEMO_OTP = "1234";
|
|
|
|
/** Short branch-counter code guests show to fulfill pickup at any location. */
|
|
export function generatePickupCode() {
|
|
const alphabet = "ABCDEFGHJKLMNPQRSTUVWXYZ23456789";
|
|
let body = "";
|
|
for (let i = 0; i < 4; i += 1) {
|
|
body += alphabet[Math.floor(Math.random() * alphabet.length)];
|
|
}
|
|
return `GSH-${body}`;
|
|
}
|
|
|
|
export function voucherDiscount(subtotal: number, code: string | null | undefined) {
|
|
if (!code) return 0;
|
|
if (code.trim().toUpperCase() === DEMO_VOUCHER) {
|
|
return Math.round(subtotal * DEMO_VOUCHER_PCT);
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
export function orderSubtotalTotal(input: {
|
|
subtotal: number;
|
|
deliveryFee: number;
|
|
discount?: number;
|
|
}) {
|
|
return Math.max(0, input.subtotal + input.deliveryFee - (input.discount ?? 0));
|
|
}
|