import type { Order, Settings } from '~/server/utils/store' export function useOrders() { return useFetch('/api/orders', { key: 'orders', default: () => [] }) } export function useAdminSettings() { return useFetch('/api/settings', { key: 'settings' }) } export async function orderAction(id: string, action: 'accept' | 'refuse' | 'advance' | 'refund', minutes?: number) { await $fetch(`/api/orders/${id}`, { method: 'PATCH', body: { action, minutes } }) await refreshNuxtData('orders') } export async function saveSettings(patch: Partial) { await $fetch('/api/settings', { method: 'PATCH', body: patch }) await refreshNuxtData('settings') } // Son de notification (WebAudio — pas de fichier à charger) let ctx: AudioContext | null = null export function unlockSound() { const C = window.AudioContext || (window as any).webkitAudioContext if (!ctx && C) ctx = new C() ctx?.resume() return !!ctx } export function ding() { if (!ctx) return const t0 = ctx.currentTime const delays = [0, 0.18, 0.36] delays.forEach((d, i) => { const o = ctx!.createOscillator() const g = ctx!.createGain() o.type = 'sine' o.frequency.value = i === 2 ? 1175 : 880 o.connect(g); g.connect(ctx!.destination) g.gain.setValueAtTime(0.0001, t0 + d) g.gain.exponentialRampToValueAtTime(0.3, t0 + d + 0.02) g.gain.exponentialRampToValueAtTime(0.0001, t0 + d + 0.16) o.start(t0 + d); o.stop(t0 + d + 0.18) }) }