import type { Order } from '~/server/utils/store'
export function printTicket(o: Order) {
const w = window.open('', '_blank', 'width=380,height=640')
if (!w) return
const lines = o.items.map(i => `
| ${i.qty}× | ${i.name} ${i.size} ${[i.meat, i.sauce, ...(i.extras || [])].filter(Boolean).join(' · ')}${i.note ? ` « ${i.note} »` : ''} | ${eur(i.unit * i.qty)} |
`).join('')
w.document.write(`Ticket ${o.num}
PANZAÏ · #${o.num}
${new Date(o.createdAt).toLocaleString('fr-FR')}
${o.mode === 'livraison' ? 'LIVRAISON' : 'RETRAIT'} — ${o.client.name} · ${o.client.phone}
${o.address ? `${o.address}
` : ''}${o.slot ? `Créneau : ${o.slot}
` : ''}
Total : ${eur(o.total)} — ${o.paid ? 'PAYÉ' : 'À ENCAISSER'}
`)
w.document.close()
w.focus()
setTimeout(() => w.print(), 250)
}