import { useState } from 'react' import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query' import toast from 'react-hot-toast' import client from '../api/client' // ── Helpers ─────────────────────────────────────────────────────────────────── function fmt(n) { if (n == null) return '—' return n.toLocaleString('el-GR', { minimumFractionDigits: 2, maximumFractionDigits: 2 }) + ' €' } function fmtDate(iso) { if (!iso) return '—' return new Date(iso).toLocaleDateString('el-GR', { day: '2-digit', month: '2-digit', year: 'numeric' }) } function fmtDateTime(iso) { if (!iso) return '—' return new Date(iso).toLocaleString('el-GR', { day: '2-digit', month: '2-digit', hour: '2-digit', minute: '2-digit' }) } const ORDER_STATUS_LABELS = { closed: 'Κλειστή', paid: 'Πληρωμένη', open: 'Ανοιχτή', partially_paid: 'Μερική πλ.', cancelled: 'Ακυρωμένη', } const ORDER_STATUS_COLORS = { closed: '#6b7280', paid: '#16a34a', open: '#3b82f6', partially_paid: '#d97706', cancelled: '#ef4444', } const inputStyle = { width: '100%', padding: '8px 11px', border: '1px solid #e5e7eb', borderRadius: 8, fontSize: 13.5, outline: 'none', fontFamily: 'inherit', background: 'white', } // ── Customer modal (create / edit) ─────────────────────────────────────────── const EMPTY_FORM = { name: '', nickname: '', phone: '', email: '', notes: '' } function CustomerModal({ initial, onClose, onSave, isPending }) { const [form, setForm] = useState(initial ?? EMPTY_FORM) const f = (k, v) => setForm(p => ({ ...p, [k]: v })) const isNew = !initial?.id return (

{isNew ? 'Νέος Πελάτης' : 'Επεξεργασία Πελάτη'}

f('name', e.target.value)} autoFocus placeholder="π.χ. Γιώργος Παπαδόπουλος" />
f('nickname', e.target.value)} placeholder="π.χ. Μεγάλος Γιάννης" />
f('phone', e.target.value)} placeholder="π.χ. 6912345678" />
f('email', e.target.value)} placeholder="email@example.com" />