#!/usr/bin/env node /** * Generate 80 QR code SVGs for table ordering (40 Backaplan + 40 Askim). * * Usage: * node scripts/generate-table-qr-codes.mjs * * Output: * public/images/booking/backaplan/qr-backaplan-001.svg ... qr-backaplan-040.svg * public/images/booking/askim/qr-askim-001.svg ... qr-askim-040.svg * * Each QR points to: * https://shahikitchen.se/orderfromtable?table=backaplan-001 * https://shahikitchen.se/orderfromtable?table=askim-001 * etc. */ import QRCode from 'qrcode'; import fs from 'fs/promises'; import path from 'path'; import { fileURLToPath } from 'url'; const __dirname = path.dirname(fileURLToPath(import.meta.url)); const ROOT = path.resolve(__dirname, '..'); const BASE_URL = 'https://shahikitchen.se/orderfromtable'; const BRANCHES = [ { key: 'backaplan', label: 'Backaplan', dir: 'backaplan' }, { key: 'askim', label: 'Askim', dir: 'askim' }, ]; const MIN_TABLE = 1; const MAX_TABLE = 40; function pad3(n) { return String(n).padStart(3, '0'); } async function ensureDir(dir) { await fs.mkdir(dir, { recursive: true }); } async function generateOne(branchKey, tableNum, outputPath) { const tableId = `${branchKey}-${pad3(tableNum)}`; const url = `${BASE_URL}?table=${tableId}`; const svg = await QRCode.toString(url, { type: 'svg', width: 320, margin: 2, errorCorrectionLevel: 'Q', // Good balance for physical use (tables, stands, possibly dirty) color: { dark: '#111111', // near-black for high contrast print light: '#FFFFFF', }, }); // Add a small metadata comment (harmless in SVG) const svgWithMeta = svg.replace( '\n { console.error('QR generation failed:', err); process.exit(1); });