Datumsanzeige, Handy-Tabellen als Karten, Übersicht mit Kurzlisten

- Reine Datumsangaben ohne Uhrzeit: fmtDay für SQL-DATE-Spalten (Rechnungs-
  und Fälligkeitsdatum kamen als UTC-Mitternacht und zeigten „02:00“),
  fmtDate für Laufzeitende, Kündigungsdatum und Gültigkeit
- Tabellen werden auf schmalen Bildschirmen zu Karten; TableCards beschriftet
  die Zellen automatisch mit ihrer Spaltenüberschrift (alle Tabellen, ohne
  Änderung der einzelnen Seiten)
- Übersicht: „Aktuelle Tickets“ und „Offene Rechnungen“ (überfällige zuerst)
  für Personal und Kunden
- Buttons erben die Schrift (Kennzahl-Kacheln auf /lizenzen zeigten die
  Systemschrift); Checkboxen und Radios in Markenfarbe mit fester Größe

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Kundencenter 2026-10-05 14:58:51 +02:00
parent 277d038669
commit 8e77cf0523
16 changed files with 113 additions and 33 deletions

View file

@ -7,7 +7,7 @@ import { useSession } from '@/lib/session';
import { SecretField } from '@/components/SecretField';
import { DomainRecords } from '@/components/DomainRecords';
import { InvoiceList } from '@/components/InvoiceList';
import { Alert, ContractStatusBadge, Empty, Field, fmt, OrderStatusBadge, ResState, ROLE_LABEL, Status } from '@/components/ui';
import { Alert, ContractStatusBadge, Empty, Field, fmt, OrderStatusBadge, ResState, ROLE_LABEL, Status, fmtDate } from '@/components/ui';
interface Org { id: string; name: string; customerNumber: string; customerType: 'private' | 'business'; status: string; billing: Record<string, string | null>; members: { id: string; email: string; name: string; status: string; role: string }[] }
interface CRow { id: string; number: string; status: string; productName: string; termEnd: string | null; cancelEffectiveAt: string | null }
@ -85,11 +85,11 @@ export default function Kunde() {
<div className="card"><div className="row between"><h2>Verträge</h2>{can('orders.write') && <Link className="btn small" href="/bestellen">Bestellung anlegen</Link>}</div>
{contracts === null ? <p className="muted" role="status">Wird geladen …</p> : contracts.length === 0 ? <Empty title="Noch keine Verträge" /> :
<div className="tablewrap"><table><thead><tr><th>Nr.</th><th>Produkt</th><th>Laufzeit bis</th><th>Status</th></tr></thead><tbody>
{contracts.map((c) => <tr key={c.id}><td className="mono"><Link href={`/vertraege/${c.id}`}>{c.number}</Link></td><td>{c.productName}</td><td>{c.termEnd ? fmt(c.termEnd) : 'unbefristet'}{c.cancelEffectiveAt && <div className="small"><span className="badge warn"><span aria-hidden="true">▲</span>Gekündigt zum {fmt(c.cancelEffectiveAt)}</span></div>}</td><td><ContractStatusBadge value={c.status} /></td></tr>)}</tbody></table></div>}</div>
{contracts.map((c) => <tr key={c.id}><td className="mono"><Link href={`/vertraege/${c.id}`}>{c.number}</Link></td><td>{c.productName}</td><td>{c.termEnd ? fmtDate(c.termEnd) : 'unbefristet'}{c.cancelEffectiveAt && <div className="small"><span className="badge warn"><span aria-hidden="true">▲</span>Gekündigt zum {fmtDate(c.cancelEffectiveAt)}</span></div>}</td><td><ContractStatusBadge value={c.status} /></td></tr>)}</tbody></table></div>}</div>
<div className="card"><h2>Ressourcen und Lizenzen</h2>
{ress === null ? <p className="muted" role="status">Wird geladen …</p> : ress.length === 0 ? <Empty title="Keine Ressourcen zugeordnet" /> :
<div className="tablewrap"><table><thead><tr><th>Name</th><th>Status</th><th>Gültig bis</th><th>Lizenzschlüssel</th></tr></thead><tbody>
{ress.map((r) => <tr key={r.id}><td><Link href={`/ressourcen/${r.id}`}>{r.name}</Link>{r.stale && <> <span className="badge warn"><span aria-hidden="true">▲</span>Veraltet</span></>}</td><td><ResState value={r.state} /></td><td>{r.validUntil ? fmt(r.validUntil) : 'unbefristet'}</td><td>{r.canReveal ? <SecretField resourceId={r.id} compact /> : <span className="muted small">–</span>}</td></tr>)}</tbody></table></div>}</div>
{ress.map((r) => <tr key={r.id}><td><Link href={`/ressourcen/${r.id}`}>{r.name}</Link>{r.stale && <> <span className="badge warn"><span aria-hidden="true">▲</span>Veraltet</span></>}</td><td><ResState value={r.state} /></td><td>{r.validUntil ? fmtDate(r.validUntil) : 'unbefristet'}</td><td>{r.canReveal ? <SecretField resourceId={r.id} compact /> : <span className="muted small">–</span>}</td></tr>)}</tbody></table></div>}</div>
{can('domains.read') && <section aria-labelledby="h-dom"><h2 id="h-dom">Domains</h2><DomainRecords orgId={String(id)} /></section>}
{can('invoices.read') && <section aria-labelledby="h-inv"><InvoiceList orgId={String(id)} /></section>}
<div className="card"><h2>Bestellungen</h2>

View file

@ -3,9 +3,32 @@ import { useEffect, useState } from 'react';
import Link from 'next/link';
import { api, errMsg } from '@/lib/api';
import { useSession } from '@/lib/session';
import { Alert, Empty } from '@/components/ui';
import { Alert, Empty, InvoiceStatusBadge, TicketStatusBadge, eur, fmt, fmtDay } from '@/components/ui';
interface Sys { jobs: Record<string, number>; oldestPendingJob: string | null; backup?: { configured: boolean; lastRunAt?: string | null; ok?: boolean; ageHours?: number | null; stale?: boolean; error?: string | null; sizeBytes?: number | null; targets?: { name: string; ok: boolean }[]; lastRestoreTestAt?: string | null; restoreOk?: boolean | null; restoreStale?: boolean } }
interface RecentTicket { id: string; number: string; orgName: string; subject: string; status: string; lastMessageAt: string }
interface OpenInvoice { id: string; number: string | null; orgName: string; status: string; overdue: boolean; dueDate: string | null; totalGrossCents: number }
/** Kurzlisten auf der Übersicht: zuletzt aktive Tickets und offene Rechnungen. */
function Recent({ staff, tickets, invoices }: { staff: boolean; tickets: boolean; invoices: boolean }) {
const [t, setT] = useState<RecentTicket[] | null>(null); const [inv, setInv] = useState<OpenInvoice[] | null>(null);
useEffect(() => {
if (tickets) api<RecentTicket[]>('GET', '/tickets').then((l) => setT(l.filter((x) => x.status !== 'resolved' && x.status !== 'closed').sort((a, b) => b.lastMessageAt.localeCompare(a.lastMessageAt)).slice(0, 5))).catch(() => setT([]));
if (invoices) api<OpenInvoice[]>('GET', '/invoices').then((l) => setInv(l.filter((x) => x.status === 'open').sort((a, b) => Number(b.overdue) - Number(a.overdue) || (a.dueDate ?? '').localeCompare(b.dueDate ?? '')).slice(0, 5))).catch(() => setInv([]));
}, [tickets, invoices]);
if (!tickets && !invoices) return null;
return (<div className="grid wide">
{tickets && <section className="card"><div className="row between"><h2>Aktuelle Tickets</h2><Link className="small" href="/tickets">Alle Tickets</Link></div>
{t === null ? <p className="muted small" role="status">Wird geladen …</p> : t.length === 0 ? <p className="muted">Keine offenen Tickets.</p>
: <ul className="list">{t.map((x) => <li key={x.id}><Link href={`/tickets/${x.id}`}><span className="title">{x.subject}</span><span className="meta">{x.number}{staff && ` · ${x.orgName}`} · {fmt(x.lastMessageAt)}</span></Link><TicketStatusBadge value={x.status} /></li>)}</ul>}
</section>}
{invoices && <section className="card"><div className="row between"><h2>Offene Rechnungen</h2><Link className="small" href="/rechnungen">Alle Rechnungen</Link></div>
{inv === null ? <p className="muted small" role="status">Wird geladen …</p> : inv.length === 0 ? <p className="muted">Keine offenen Rechnungen.</p>
: <ul className="list">{inv.map((x) => <li key={x.id}><Link href={`/rechnungen/${x.id}`}><span className="title">{x.number ?? 'Entwurf'} · {eur(x.totalGrossCents)}</span><span className="meta">{staff && `${x.orgName} · `}fällig {x.dueDate ? fmtDay(x.dueDate) : '–'}</span></Link><InvoiceStatusBadge value={x.status} overdue={x.overdue} /></li>)}</ul>}
</section>}
</div>);
}
export default function Dashboard() {
const { me, can } = useSession();
const [mine, setMine] = useState<{ contracts: { status: string; cancelEffectiveAt: string | null }[]; resources: { state: string; stale: boolean }[]; orders: { status: string }[] } | null>(null);
@ -49,5 +72,6 @@ export default function Dashboard() {
{sys && <div className="card"><div className="stat">{failed}</div><p className="muted">Aufträge mit Fehlern / Prüfbedarf</p>{failed > 0 && <span className="badge err"><span aria-hidden="true">✕</span>Prüfen</span>}</div>}
</div>
</>)}
<Recent staff={me.kind === 'staff'} tickets={me.kind === 'customer' || can('tickets.read')} invoices={me.kind === 'customer' || can('invoices.read')} />
</>);
}

View file

@ -8,6 +8,7 @@ import { ROLE_LABEL } from '@/components/ui';
import { ThemeToggle } from '@/components/ThemeToggle';
import { Icon, type IconName } from '@/components/Icon';
import { Brand, SiteFooter } from '@/components/Brand';
import { TableCards } from '@/components/TableCards';
const ICONS: Record<string, IconName> = {
'/dashboard': 'home', '/lizenzen': 'key', '/ressourcen': 'server', '/vertraege': 'fileText', '/bestellungen': 'cart', '/rechnungen': 'receipt', '/tickets': 'ticket', '/admin/posteingang': 'inbox',
@ -65,7 +66,7 @@ export default function AppLayout({ children }: { children: ReactNode }) {
)}
<div className="shell">
<div className="topbar"><Brand sub={false} /><ThemeToggle compact /></div>
{nav}<main id="main" className="main">{trial && path !== '/einstellungen/lizenz' && <div className="alert warn" role="status">{trial} <Link href="/einstellungen/lizenz">Lizenz hinterlegen</Link></div>}{children}<SiteFooter /></main>
{nav}<main id="main" className="main">{trial && path !== '/einstellungen/lizenz' && <div className="alert warn" role="status">{trial} <Link href="/einstellungen/lizenz">Lizenz hinterlegen</Link></div>}{children}<SiteFooter /><TableCards /></main>
{!enrollNeeded && <nav className="bottomnav" aria-label="Hauptnavigation (mobil)">
{bottomLink('/dashboard', 'Übersicht', 'home')}
{(me.kind === 'customer' || can('resources.read')) && bottomLink('/ressourcen', 'Ressourcen', 'server')}

View file

@ -4,7 +4,7 @@ import Link from 'next/link';
import { useParams } from 'next/navigation';
import { api, errMsg } from '@/lib/api';
import { useSession } from '@/lib/session';
import { Alert, Field, ResState, fmt } from '@/components/ui';
import { Alert, Field, ResState, fmt, fmtDate } from '@/components/ui';
import { SecretField } from '@/components/SecretField';
import { LicKind, type Lic } from '@/components/Licenses';
@ -68,7 +68,7 @@ export default function Lizenz() {
}
function extend(e: FormEvent<HTMLFormElement>) {
e.preventDefault(); const f = new FormData(e.currentTarget); const until = String(f.get('until') ?? ''); const preset = String(f.get('preset') ?? ''); const reason = String(f.get('reason') ?? '').trim() || undefined;
if (until) { const iso = new Date(`${until}T23:59:59`).toISOString(); ask('Verlängern', `Die Lizenz gilt dann bis ${fmt(iso)}.`, () => lifecycle({ action: 'extend', until: iso, reason })); return; }
if (until) { const iso = new Date(`${until}T23:59:59`).toISOString(); ask('Verlängern', `Die Lizenz gilt dann bis ${fmtDate(iso)}.`, () => lifecycle({ action: 'extend', until: iso, reason })); return; }
if (!preset) { setMsg({ k: 'warn', t: 'Bitte ein Datum oder eine Laufzeit wählen.' }); return; }
const [count, durationType] = preset.split(':');
ask('Verlängern', `Die Lizenz wird um ${count} ${DURATION[durationType!]}${Number(count) > 1 ? 'e' : ''} verlängert (ab dem späteren von heute und dem aktuellen Ablauf).`, () => lifecycle({ action: 'extend', durationType, count: Number(count), reason }));
@ -98,8 +98,8 @@ export default function Lizenz() {
<Dd label="Programm">{d.program ?? '–'}</Dd>
<Dd label="Produkt">{d.product ?? d.edition ?? '–'}</Dd>
<Dd label="Laufzeit">{d.durationType ? DURATION[d.durationType] ?? d.durationType : '–'}</Dd>
<Dd label="Gültig ab">{d.validFrom ? fmt(d.validFrom) : '–'}</Dd>
<Dd label="Gültig bis">{d.validUntil ? fmt(d.validUntil) : 'unbefristet'}</Dd>
<Dd label="Gültig ab">{d.validFrom ? fmtDate(d.validFrom) : '–'}</Dd>
<Dd label="Gültig bis">{d.validUntil ? fmtDate(d.validUntil) : 'unbefristet'}</Dd>
<Dd label="Letzte Prüfung durch das Programm">{d.lastCheckAt ? fmt(d.lastCheckAt) : 'noch nie'}</Dd>
<Dd label="Abrechnung">{d.contractId ? <Link href={`/vertraege/${d.contractId}`}>Vertrag {d.contractNumber}</Link> : 'ohne Berechnung'}</Dd>
{d.parent && <Dd label="Basislizenz"><Link href={`/lizenzen/${d.parent.id}`}>{d.parent.program}{d.parent.product ? ` · ${d.parent.product}` : ''}</Link></Dd>}
@ -166,7 +166,7 @@ export default function Lizenz() {
</>}
{(!d.addon && (d.addons.length > 0 || d.can.manage)) && <div className="card"><div className="row between"><h2>Add-ons</h2>{d.can.manage && d.orgId && <Link className="btn small" href={`/lizenzen/neu?org=${d.orgId}&parent=${d.id}`}>Add-on vergeben</Link>}</div>
{d.addons.length === 0 ? <p className="muted">Keine Add-ons.</p> : <ul>{d.addons.map((x) => <li key={x.id}><Link href={`/lizenzen/${x.id}`}>{x.product ?? x.name}</Link> <ResState value={x.state} /> <span className="small muted">bis {x.validUntil ? fmt(x.validUntil) : 'unbefristet'}</span></li>)}</ul>}
{d.addons.length === 0 ? <p className="muted">Keine Add-ons.</p> : <ul>{d.addons.map((x) => <li key={x.id}><Link href={`/lizenzen/${x.id}`}>{x.product ?? x.name}</Link> <ResState value={x.state} /> <span className="small muted">bis {x.validUntil ? fmtDate(x.validUntil) : 'unbefristet'}</span></li>)}</ul>}
</div>}
{staff && d.history.length > 0 && <div className="card"><h2>Verlauf</h2><div className="tablewrap"><table><thead><tr><th>Zeitpunkt</th><th>Vorgang</th><th>Durch</th><th>Ergebnis</th></tr></thead><tbody>

View file

@ -3,7 +3,7 @@ import { useCallback, useEffect, useState } from 'react';
import Link from 'next/link';
import { api, errMsg } from '@/lib/api';
import { useSession } from '@/lib/session';
import { Alert, Empty, ResState, fmt } from '@/components/ui';
import { Alert, Empty, ResState, fmt, fmtDate } from '@/components/ui';
import { SecretField } from '@/components/SecretField';
import { LicKind, type Lic } from '@/components/Licenses';
@ -49,7 +49,7 @@ export default function Lizenzen() {
<td><Link href={`/lizenzen/${l.id}`}>{l.program ?? l.name}{l.product ? ` · ${l.product}` : ''}</Link><LicKind l={l} /><div className="mono small muted">{l.keyMasked}</div></td>
<td>{l.orgId ? <Link href={`/admin/kunden/${l.orgId}`}>{l.customerNumber} · {l.orgName}</Link> : <span className="badge warn"><span aria-hidden="true">▲</span>Nicht zugewiesen</span>}</td>
<td><ResState value={l.state} /></td>
<td>{l.validUntil ? <>{fmt(l.validUntil)}{soon(l.validUntil) && l.state === 'active' && <> <span className="badge warn"><span aria-hidden="true">▲</span>bald</span></>}</> : 'unbefristet'}</td>
<td>{l.validUntil ? <>{fmtDate(l.validUntil)}{soon(l.validUntil) && l.state === 'active' && <> <span className="badge warn"><span aria-hidden="true">▲</span>bald</span></>}</> : 'unbefristet'}</td>
<td>{devices(l)}</td>
<td>{l.contractId ? <Link href={`/vertraege/${l.contractId}`}>{l.contractNumber}</Link> : <span className="muted small">ohne Berechnung</span>}</td>
</tr>)}</tbody></table></div></div>
@ -58,7 +58,7 @@ export default function Lizenzen() {
<div className="productcard" key={l.id}>
<div className="row between"><h3><Link href={`/lizenzen/${l.id}`}>{l.program ?? l.name}</Link></h3><ResState value={l.state} /></div>
<div className="id">{l.product ?? l.edition}<LicKind l={l} /></div>
<div className="small muted">Gültig bis: {l.validUntil ? fmt(l.validUntil) : 'unbefristet'}</div>
<div className="small muted">Gültig bis: {l.validUntil ? fmtDate(l.validUntil) : 'unbefristet'}</div>
<div className="small muted">Geräte: {devices(l)}</div>
<div style={{ marginTop: 4 }}><SecretField resourceId={l.id} compact /></div>
<div style={{ marginTop: 8 }}><Link className="btn small" href={`/lizenzen/${l.id}`}>Details und Geräte</Link></div>

View file

@ -4,7 +4,7 @@ import { useParams, useSearchParams } from 'next/navigation';
import Link from 'next/link';
import { api, errMsg } from '@/lib/api';
import { useSession } from '@/lib/session';
import { Alert, Field, InvoiceStatusBadge, eur, fmt } from '@/components/ui';
import { Alert, Field, InvoiceStatusBadge, eur, fmt, fmtDay } from '@/components/ui';
interface Item { id: string; description: string; quantity: number; unitPriceNetCents: number; taxBp: number; discountBp: number; netCents: number; taxCents: number; grossCents: number }
interface Inv { id: string; number: string | null; orgId: string; orgName: string; status: string; overdue: boolean; issueDate: string | null; dueDate: string | null; paymentMethod: string | null; note: string | null; totalNetCents: number; totalTaxCents: number; totalGrossCents: number; cancelsInvoiceId: string | null; cancelledByInvoiceId: string | null; items: Item[]; canWrite: boolean }
@ -51,7 +51,7 @@ export default function RechnungDetail() {
const isDraft = inv.status === 'draft';
return (<>
<div className="row between"><h1>{inv.number ?? 'Entwurf'} {inv.orgName && <span className="muted">· {inv.orgName}</span>}</h1><Link className="btn" href="/rechnungen">← Rechnungen</Link></div>
<p className="muted small"><InvoiceStatusBadge value={inv.status} overdue={inv.overdue} />{inv.issueDate && <> · ausgestellt {fmt(inv.issueDate)}</>}{inv.dueDate && <> · fällig {fmt(inv.dueDate)}</>}{inv.paymentMethod && <> · {inv.paymentMethod}</>}</p>
<p className="muted small"><InvoiceStatusBadge value={inv.status} overdue={inv.overdue} />{inv.issueDate && <> · ausgestellt {fmtDay(inv.issueDate)}</>}{inv.dueDate && <> · fällig {fmtDay(inv.dueDate)}</>}{inv.paymentMethod && <> · {inv.paymentMethod}</>}</p>
{inv.cancelsInvoiceId && <Alert kind="info">Dies ist eine Stornorechnung zu <Link href={`/rechnungen/${inv.cancelsInvoiceId}`}>einer anderen Rechnung</Link>.</Alert>}
{inv.cancelledByInvoiceId && <Alert kind="warn">Diese Rechnung wurde storniert. Storno: <Link href={`/rechnungen/${inv.cancelledByInvoiceId}`}>ansehen</Link></Alert>}
{err && <Alert kind="err">{err}</Alert>}{ok && <Alert kind="ok">{ok}</Alert>}

View file

@ -3,7 +3,7 @@ import { useEffect, useState } from 'react';
import Link from 'next/link';
import { useRouter } from 'next/navigation';
import { api, errMsg } from '@/lib/api';
import { Alert, Empty, eur, fmt } from '@/components/ui';
import { Alert, Empty, eur, fmt, fmtDay } from '@/components/ui';
interface OverdueInv { id: string; number: string | null; orgName: string; customerNumber: string; dueDate: string | null; totalGrossCents: number }
interface DueContract { id: string; number: string; orgId: string; orgName: string; customerNumber: string; productName: string | null; lastInvoicedAt: string | null; dueSince: string; lastGrossCents: number | null }
@ -28,7 +28,7 @@ export default function Faellig() {
{d.overdueInvoices.length === 0 ? <Empty title="Keine überfälligen Rechnungen" /> :
<div className="tablewrap"><table><thead><tr><th>Nr.</th><th>Kunde</th><th>Fällig seit</th><th>Betrag</th></tr></thead><tbody>
{d.overdueInvoices.map((i) => (<tr key={i.id}><td className="mono"><Link href={`/rechnungen/${i.id}`}>{i.number}</Link></td><td>{i.orgName} <span className="muted small">({i.customerNumber})</span></td>
<td><span className="badge err"><span aria-hidden="true">▲</span>{i.dueDate ? fmt(i.dueDate) : '–'}</span></td><td>{eur(i.totalGrossCents)}</td></tr>))}
<td><span className="badge err"><span aria-hidden="true">▲</span>{i.dueDate ? fmtDay(i.dueDate) : '–'}</span></td><td>{eur(i.totalGrossCents)}</td></tr>))}
</tbody></table></div>}
</div>
<div className="card">

View file

@ -4,7 +4,7 @@ import Link from 'next/link';
import { useParams } from 'next/navigation';
import { api, errMsg } from '@/lib/api';
import { useSession } from '@/lib/session';
import { ACTION_LABEL, Alert, Field, JobStatus, ResState, fmt, eur, CUSTOMER_ACTIONS } from '@/components/ui';
import { ACTION_LABEL, Alert, Field, JobStatus, ResState, fmt, eur, CUSTOMER_ACTIONS, fmtDate } from '@/components/ui';
import { SecretField } from '@/components/SecretField';
import { uuid } from '@/lib/uuid';
import { HostingPanel, UsageBars } from '@/components/HostingPanel';
@ -64,8 +64,8 @@ export default function Ressource() {
{d.missing && <Alert kind="warn">Diese Ressource wurde beim letzten Abgleich nicht mehr beim Anbieter gefunden.</Alert>}
<div className="card"><h2>Details</h2>
<dl className="cols" style={{ margin: 0 }}>
<div><dt className="muted small">Gültig ab</dt><dd style={{ margin: 0 }}>{d.validFrom ? fmt(d.validFrom) : '–'}</dd></div>
<div><dt className="muted small">Gültig bis</dt><dd style={{ margin: 0 }}>{d.validUntil ? fmt(d.validUntil) : 'unbefristet'}</dd></div>
<div><dt className="muted small">Gültig ab</dt><dd style={{ margin: 0 }}>{d.validFrom ? fmtDate(d.validFrom) : '–'}</dd></div>
<div><dt className="muted small">Gültig bis</dt><dd style={{ margin: 0 }}>{d.validUntil ? fmtDate(d.validUntil) : 'unbefristet'}</dd></div>
{d.type !== 'hosting_account' && Object.entries(d.limits).map(([k, v]) => <div key={k}><dt className="muted small">{LIMIT_LABEL[k] ?? k}</dt><dd style={{ margin: 0 }}>{v === null ? 'unbegrenzt' : String(v)}{d.usage[k] !== undefined ? ` (genutzt: ${String(d.usage[k])})` : ''}</dd></div>)}
{d.details.edition && <div><dt className="muted small">Edition</dt><dd style={{ margin: 0 }}>{String(d.details.edition)}</dd></div>}
{d.details.program && <div><dt className="muted small">Programm</dt><dd style={{ margin: 0 }}>{String(d.details.program)}</dd></div>}

View file

@ -3,7 +3,7 @@ import { useEffect, useState, type FormEvent } from 'react';
import Link from 'next/link';
import { api, errMsg } from '@/lib/api';
import { useSession } from '@/lib/session';
import { Alert, Empty, Field, ResState, fmt } from '@/components/ui';
import { Alert, Empty, Field, ResState, fmt, fmtDate } from '@/components/ui';
import { SecretField } from '@/components/SecretField';
interface R { id: string; type: string; name: string; state: string; validUntil: string | null; syncedAt: string; stale: boolean; staleReason: string | null; orgId: string | null; instance?: string; canReveal?: boolean }
@ -58,13 +58,13 @@ export default function Ressourcen() {
{staff ? (
<div className="card"><div className="tablewrap"><table><thead><tr><th>Name</th>{!lic && <th>Typ</th>}<th>Status</th><th>Gültig bis</th><th>Stand</th>{lic && <th>Lizenzschlüssel</th>}</tr></thead><tbody>
{rows.map((r) => <tr key={r.id}><td><Link href={`/ressourcen/${r.id}`}>{r.name}</Link>{!r.orgId && <> <span className="badge warn"><span aria-hidden="true">▲</span>Nicht zugewiesen</span></>}{canAssign && !r.orgId && <div style={{ marginTop: 8 }}><AssignCell r={r} custs={custs} onError={setErr} onCreated={(c, cr) => { setCusts((l) => [...l, c]); setErr(''); setOk(`Kunde ${cr.customerNumber} angelegt. ` + (cr.mail === 'sent' ? 'Die Einladung wurde per E-Mail versendet.' : cr.inviteLink ? `E-Mail-Versand ist nicht eingerichtet. Einladungslink (nur jetzt sichtbar): ${cr.inviteLink}` : '') + ' Jetzt noch „Zuweisen“ klicken.'); }} onDone={() => { setErr(''); setOk(`„${r.name}“ wurde zugewiesen. Kunden dürfen daran zunächst keine Aktionen ausführen (im Produkt bzw. an der Ressource freigebbar).`); void reload(); }} /></div>}</td>{!lic && <td>{TYPE[r.type] ?? r.type}</td>}<td><ResState value={r.state} /></td>
<td>{r.validUntil ? fmt(r.validUntil) : 'unbefristet'}</td><td className="small">{fmt(r.syncedAt)}{r.stale && <> <span className="badge warn"><span aria-hidden="true">▲</span>Veraltet</span></>}</td>{lic && <td>{r.canReveal ? <SecretField resourceId={r.id} compact /> : <span className="muted small">–</span>}</td>}</tr>)}</tbody></table></div></div>
<td>{r.validUntil ? fmtDate(r.validUntil) : 'unbefristet'}</td><td className="small">{fmt(r.syncedAt)}{r.stale && <> <span className="badge warn"><span aria-hidden="true">▲</span>Veraltet</span></>}</td>{lic && <td>{r.canReveal ? <SecretField resourceId={r.id} compact /> : <span className="muted small">–</span>}</td>}</tr>)}</tbody></table></div></div>
) : (
<div className="productgrid">{rows.map((r) => (
<div className="productcard" key={r.id}>
<div className="row between"><h3><Link href={`/ressourcen/${r.id}`}>{r.name}</Link></h3><ResState value={r.state} /></div>
{!lic && <div className="id">{TYPE[r.type] ?? r.type}</div>}
<div className="small muted">Gültig bis: {r.validUntil ? fmt(r.validUntil) : 'unbefristet'}</div>
<div className="small muted">Gültig bis: {r.validUntil ? fmtDate(r.validUntil) : 'unbefristet'}</div>
<div className="small muted">Stand: {fmt(r.syncedAt)}{r.stale && <> <span className="badge warn"><span aria-hidden="true">▲</span>Veraltet</span></>}</div>
{lic && r.canReveal && <div style={{ marginTop: 4 }}><SecretField resourceId={r.id} compact /></div>}
<div style={{ marginTop: 8 }}><Link className="btn small" href={`/ressourcen/${r.id}`}>Details ansehen</Link></div>

View file

@ -4,7 +4,7 @@ import Link from 'next/link';
import { useParams } from 'next/navigation';
import { api, errMsg } from '@/lib/api';
import { useSession } from '@/lib/session';
import { Alert, ContractStatusBadge, Field, fmt, INTERVAL, type Price, PriceText } from '@/components/ui';
import { Alert, ContractStatusBadge, Field, fmt, INTERVAL, type Price, PriceText, fmtDate } from '@/components/ui';
interface D { id: string; number: string; orgName: string; status: string; productName: string; startedAt: string | null; termEnd: string | null; renewal: string; renewalTermMonths: number; noticeDays: number; cancelRequestedAt: string | null; cancelEffectiveAt: string | null; cancelledAt: string | null; resourceId: string | null; canCancel: boolean; canEdit?: boolean;
price: Price & { customerType: string; name: string; sku: string; version: number; terms: { termMonths: number }; basis: 'net' | 'gross'; unitRecurringCents: number; unitSetupCents: number; adjusted?: { at: string; reason: string } } }
@ -16,7 +16,7 @@ export default function Vertrag() {
const load = useCallback(() => api<D>('GET', `/contracts/${id}`).then(setD).catch((e) => setMsg({ k: 'err', t: errMsg(e) })), [id]);
useEffect(() => { void load(); }, [load]);
if (!d) return msg ? <Alert kind={msg.k}>{msg.t}</Alert> : <p className="muted" role="status">Wird geladen …</p>;
async function cancel(immediate: boolean) { try { const r = await api<{ cancelEffectiveAt: string }>('POST', `/contracts/${id}/cancel`, { immediate }); setConfirm(null); setMsg({ k: 'ok', t: `Die Kündigung wurde vorgemerkt und wird wirksam am ${fmt(r.cancelEffectiveAt)}.` }); void load(); } catch (x) { setMsg({ k: 'err', t: errMsg(x) }); } }
async function cancel(immediate: boolean) { try { const r = await api<{ cancelEffectiveAt: string }>('POST', `/contracts/${id}/cancel`, { immediate }); setConfirm(null); setMsg({ k: 'ok', t: `Die Kündigung wurde vorgemerkt und wird wirksam am ${fmtDate(r.cancelEffectiveAt)}.` }); void load(); } catch (x) { setMsg({ k: 'err', t: errMsg(x) }); } }
async function revoke() { try { await api('POST', `/contracts/${id}/cancel/revoke`); setMsg({ k: 'ok', t: 'Die Kündigung wurde zurückgenommen.' }); void load(); } catch (x) { setMsg({ k: 'err', t: errMsg(x) }); } }
async function save(e: FormEvent<HTMLFormElement>) {
e.preventDefault(); const f = new FormData(e.currentTarget); const g = (k: string) => String(f.get(k) ?? '');
@ -34,12 +34,12 @@ export default function Vertrag() {
<p><Link href="/vertraege">← Alle Verträge</Link></p>
<div className="row between"><h1>{d.productName}</h1><ContractStatusBadge value={d.status} /></div><p className="muted"><span className="mono">{d.number}</span> · {d.orgName}</p>
{msg && <Alert kind={msg.k}>{msg.t}</Alert>}
{pending && <Alert kind="warn">Dieser Vertrag ist gekündigt und endet am <strong>{fmt(d.cancelEffectiveAt!)}</strong>.</Alert>}
{pending && <Alert kind="warn">Dieser Vertrag ist gekündigt und endet am <strong>{fmtDate(d.cancelEffectiveAt!)}</strong>.</Alert>}
<div className="card"><h2>Konditionen</h2>
<dl className="cols" style={{ margin: 0 }}>
<div><dt className="muted small">Preis</dt><dd style={{ margin: 0 }}><PriceText p={d.price} priv={priv} /></dd></div>
<div><dt className="muted small">Beginn</dt><dd style={{ margin: 0 }}>{d.startedAt ? fmt(d.startedAt) : '–'}</dd></div>
<div><dt className="muted small">Laufzeit bis</dt><dd style={{ margin: 0 }}>{d.termEnd ? fmt(d.termEnd) : 'unbefristet'}</dd></div>
<div><dt className="muted small">Laufzeit bis</dt><dd style={{ margin: 0 }}>{d.termEnd ? fmtDate(d.termEnd) : 'unbefristet'}</dd></div>
<div><dt className="muted small">Verlängerung</dt><dd style={{ margin: 0 }}>{d.renewal === 'auto' ? `automatisch um ${d.renewalTermMonths} Monat(e)` : 'keine'}</dd></div>
<div><dt className="muted small">Kündigungsfrist</dt><dd style={{ margin: 0 }}>{d.noticeDays} Tage</dd></div>
<div><dt className="muted small">Abrechnung</dt><dd style={{ margin: 0 }}>{INTERVAL[d.price.interval]}</dd></div></dl>

View file

@ -3,7 +3,7 @@ import { useEffect, useState } from 'react';
import Link from 'next/link';
import { api, errMsg } from '@/lib/api';
import { useSession } from '@/lib/session';
import { Alert, ContractStatusBadge, Empty, Field, fmt, type Price, PriceText } from '@/components/ui';
import { Alert, ContractStatusBadge, Empty, Field, fmt, type Price, PriceText, fmtDate } from '@/components/ui';
interface C { id: string; number: string; orgName: string; status: string; productName: string; termEnd: string | null; cancelEffectiveAt: string | null; price: Price & { customerType: string } }
export default function Vertraege() {
@ -16,6 +16,6 @@ export default function Vertraege() {
{list === null ? <p className="muted" role="status">Wird geladen …</p> : list.length === 0 ? <Empty title="Keine Verträge">Verträge entstehen aus Bestellungen.</Empty> :
<div className="tablewrap"><table><thead><tr><th>Nr.</th><th>Produkt</th>{staff && <th>Kunde</th>}<th>Preis</th><th>Laufzeit bis</th><th>Status</th></tr></thead><tbody>
{list.map((c) => <tr key={c.id}><td className="mono"><Link href={`/vertraege/${c.id}`}>{c.number}</Link></td><td>{c.productName}</td>{staff && <td>{c.orgName}</td>}<td className="small"><PriceText p={c.price} priv={c.price.customerType === 'private'} /></td>
<td>{c.termEnd ? fmt(c.termEnd) : 'unbefristet'}{c.cancelEffectiveAt && <div className="small"><span className="badge warn"><span aria-hidden="true">▲</span>Gekündigt zum {fmt(c.cancelEffectiveAt)}</span></div>}</td><td><ContractStatusBadge value={c.status} /></td></tr>)}</tbody></table></div>}
<td>{c.termEnd ? fmtDate(c.termEnd) : 'unbefristet'}{c.cancelEffectiveAt && <div className="small"><span className="badge warn"><span aria-hidden="true">▲</span>Gekündigt zum {fmtDate(c.cancelEffectiveAt)}</span></div>}</td><td><ContractStatusBadge value={c.status} /></td></tr>)}</tbody></table></div>}
</div></>);
}

View file

@ -77,6 +77,19 @@ a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset:
.shell { grid-template-columns: minmax(0, 1fr); } .nav { display: none; } .nav.open { display: flex; position: fixed; inset: 0 20% 56px 0; height: auto; z-index: 5; box-shadow: 0 0 0 100vmax rgba(0,0,0,.4); overflow: auto; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); padding: var(--s3); background: var(--surface); border-bottom: 1px solid var(--border); }
.main { padding: var(--s4) var(--s3) calc(var(--s4) + 56px); min-height: 0; }
/* Tabellen als Karten: jede Zeile ein Block, Zellen mit ihrer Spaltenüberschrift (data-label, siehe TableCards) */
.tablewrap { border: none; border-radius: 0; overflow: visible; }
.tablewrap table, .tablewrap tbody, .tablewrap tr, .tablewrap td { display: block; width: 100%; }
.tablewrap thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.tablewrap tbody tr { border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px; margin-bottom: 10px; }
.tablewrap tbody tr:hover { background: transparent; }
.tablewrap td, .tablewrap th:first-child, .tablewrap td:first-child { border: none; padding: 5px 0; }
.tablewrap td[data-label] { display: grid; grid-template-columns: minmax(92px, 36%) minmax(0, 1fr); gap: 12px; align-items: baseline; }
.tablewrap td[data-label]::before { content: attr(data-label); font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.tablewrap td:first-child { font-weight: 600; }
.tablewrap td:first-child[data-label] { display: block; padding-bottom: 8px; margin-bottom: 4px; border-bottom: 1px solid var(--border); }
.tablewrap td:first-child::before { content: none; }
.tablewrap td:empty { display: none; }
.topbar .brand { color: var(--text); } .topbar .brandmark { width: 30px; height: 30px; }
.bottomnav { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; background: var(--surface); border-top: 1px solid var(--border); box-shadow: var(--shadow-md); padding-bottom: env(safe-area-inset-bottom, 0); }
.bottomnav a, .bottomnav button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 2px 10px; font-size: .72rem; color: var(--muted); text-decoration: none; background: none; border: none; font: inherit; min-height: 56px; }
@ -87,6 +100,14 @@ a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset:
.grid { display: grid; gap: var(--s4); grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); margin-bottom: var(--s4); align-items: start; }
.grid > .card { margin-bottom: 0; }
.grid > .card:hover { box-shadow: var(--shadow-md); }
.grid.wide { grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); padding: 10px 0; border-top: 1px solid var(--border); }
.list li:first-child { border-top: none; }
.list a { display: flex; flex-direction: column; min-width: 0; text-decoration: none; }
.list a .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list a:hover .title { text-decoration: underline; }
.list a .meta { font-size: .85rem; color: var(--muted); }
.stat { font-size: 2.25rem; font-variant-numeric: tabular-nums; font-weight: 700; line-height: 1.1; letter-spacing: -0.02em; } .row { display: flex; gap: var(--s3); align-items: center; flex-wrap: wrap; } .row.between { justify-content: space-between; }
.btn { font: inherit; font-weight: 500; padding: 10px 18px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; min-height: 44px; box-shadow: var(--shadow-sm); }
.btn:hover { background: var(--surface-2); transform: translateY(-1px); box-shadow: var(--shadow-md); }
@ -97,6 +118,8 @@ a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset:
.field { display: grid; gap: 6px; margin-bottom: var(--s3); } .field label { font-weight: 600; font-size: .9rem; }
input, select, textarea { font: inherit; padding: 10px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); min-height: 44px; width: 100%; }
input:focus-visible, select:focus-visible, textarea:focus-visible { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); outline: none; }
button { font: inherit; color: inherit; }
input[type='checkbox'], input[type='radio'] { width: 20px; height: 20px; min-height: 0; padding: 0; flex: none; accent-color: var(--accent); cursor: pointer; }
.cols { display: grid; gap: var(--s3); grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
table { width: 100%; border-collapse: collapse; } th, td { text-align: left; padding: 12px var(--s3); border-bottom: 1px solid var(--border); vertical-align: top; } th { font-size: .78rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); background: var(--surface-2); }
tbody tr:hover { background: var(--surface-2); } tbody tr:last-child td { border-bottom: none; }

View file

@ -3,7 +3,7 @@ import { useCallback, useEffect, useState, type FormEvent } from 'react';
import { api, errMsg } from '@/lib/api';
import { copyText } from '@/lib/clipboard';
import { generatePassword, MIN_CHILD_PASSWORD } from '@/lib/password';
import { Alert, Empty, Field, fmt } from '@/components/ui';
import { Alert, Empty, Field, fmt, fmtDate } from '@/components/ui';
type Kind = 'domain' | 'email' | 'database' | 'ftp' | 'certificate';
interface Child { id: string; kind: Kind; name: string; state: string; validUntil?: string | null; details: Record<string, any> }
@ -107,7 +107,7 @@ export function HostingPanel({ resourceId, canLogin }: { resourceId: string; can
{r.kind === 'email' && <>{bytes(d.sizeBytes)} von {d.maxSizeBytes ? bytes(d.maxSizeBytes) : 'unbegrenzt'}{d.forwardings?.length ? ` · Weiterleitung an ${d.forwardings.join(', ')}` : ''}</>}
{r.kind === 'database' && <>Benutzer <span className="mono">{d.user}</span> · {bytes(d.sizeBytes)}</>}
{r.kind === 'ftp' && <>Verzeichnis <span className="mono">{d.home}</span></>}
{r.kind === 'certificate' && <>{d.issuer ?? '–'} · gültig bis {r.validUntil ? fmt(r.validUntil) : '–'} · {(d.securedDomains ?? []).join(', ')}</>}</td>
{r.kind === 'certificate' && <>{d.issuer ?? '–'} · gültig bis {r.validUntil ? fmtDate(r.validUntil) : '–'} · {(d.securedDomains ?? []).join(', ')}</>}</td>
<td><span className={`badge ${c}`}><span aria-hidden="true">{i}</span>{l}</span></td>
{canWrite && <td>{del === r.id ? <div role="alertdialog" aria-label="Löschen bestätigen"><p className="small" style={{ margin: '0 0 8px' }}><strong>„{r.name}“ endgültig löschen?</strong>{r.kind !== 'domain' ? ' Die Daten gehen verloren.' : ' Zugehörige Inhalte können verloren gehen.'}</p><div className="row"><button className="btn small danger" disabled={busy} onClick={() => submit('delete', {}, { id: r.id, okText: 'Wurde gelöscht.' })}>Ja, löschen</button><button className="btn small" onClick={() => setDel(null)}>Abbrechen</button></div></div>
: <div className="row" style={{ gap: 8 }}><button className="btn small danger" onClick={() => setDel(r.id)} disabled={busy || (r.kind === 'domain' && d.system)}>Löschen</button></div>}</td>}</tr>); })}</tbody></table></div>)}

View file

@ -3,7 +3,7 @@ import { useCallback, useEffect, useState, type FormEvent } from 'react';
import Link from 'next/link';
import { api, errMsg } from '@/lib/api';
import { useSession } from '@/lib/session';
import { Alert, Empty, Field, InvoiceStatusBadge, eur, fmt } from '@/components/ui';
import { Alert, Empty, Field, InvoiceStatusBadge, eur, fmt, fmtDay } from '@/components/ui';
interface Inv { id: string; number: string | null; orgId: string; orgName: string; customerNumber: string; status: string; overdue: boolean; issueDate: string | null; dueDate: string | null; totalGrossCents: number; createdAt: string }
interface Cust { id: string; name: string; customerNumber: string }
@ -35,7 +35,7 @@ export function InvoiceList({ orgId }: { orgId?: string }) {
{list === null ? <p className="muted" role="status">Wird geladen …</p> : list.length === 0 ? <Empty title="Keine Rechnungen" /> :
<div className="tablewrap"><table><thead><tr><th>Nr.</th>{!orgId && <th>Kunde</th>}<th>Status</th><th>Datum</th><th>Fällig</th><th>Betrag</th></tr></thead><tbody>
{list.map((i) => (<tr key={i.id}><td className="mono"><Link href={`/rechnungen/${i.id}`}>{i.number ?? 'Entwurf'}</Link></td>{!orgId && <td>{i.orgName}</td>}
<td><InvoiceStatusBadge value={i.status} overdue={i.overdue} /></td><td className="small">{i.issueDate ? fmt(i.issueDate) : '–'}</td><td className="small">{i.dueDate ? fmt(i.dueDate) : '–'}</td><td>{eur(i.totalGrossCents)}</td></tr>))}
<td><InvoiceStatusBadge value={i.status} overdue={i.overdue} /></td><td className="small">{i.issueDate ? fmtDay(i.issueDate) : '–'}</td><td className="small">{i.dueDate ? fmtDay(i.dueDate) : '–'}</td><td>{eur(i.totalGrossCents)}</td></tr>))}
</tbody></table></div>}
</div>
</>);

View file

@ -0,0 +1,28 @@
'use client';
import { useEffect } from 'react';
import { usePathname } from 'next/navigation';
/** Beschriftet Tabellenzellen mit ihrer Spaltenüberschrift (data-label), damit Tabellen auf schmalen Bildschirmen
* als Karten erscheinen können (siehe .tablewrap in globals.css). Beobachtet nachgeladene Zeilen. */
export function TableCards() {
const path = usePathname();
useEffect(() => {
const main = document.getElementById('main'); if (!main) return;
const label = () => main.querySelectorAll<HTMLTableElement>('.tablewrap table').forEach((t) => {
const heads = [...t.querySelectorAll('thead th')].map((th) => th.textContent?.trim() ?? '');
t.querySelectorAll('tbody tr').forEach((tr) => {
let col = 0;
for (const cell of tr.children) {
const span = (cell as HTMLTableCellElement).colSpan || 1; const l = span === 1 ? heads[col] : '';
if (l) { if (cell.getAttribute('data-label') !== l) cell.setAttribute('data-label', l); } else cell.removeAttribute('data-label');
col += span;
}
});
});
label();
// nur childList beobachten: das Setzen der Attribute löst so keine weitere Runde aus
const mo = new MutationObserver(label); mo.observe(main, { childList: true, subtree: true });
return () => mo.disconnect();
}, [path]);
return null;
}

View file

@ -16,6 +16,10 @@ export const Field = ({ id, label, children, hint }: { id: string; label: string
);
export const Empty = ({ title, children }: { title: string; children?: ReactNode }) => <div className="empty"><h3>{title}</h3>{children}</div>;
export const fmt = (d: string | Date) => new Date(d).toLocaleString('de-DE', { dateStyle: 'medium', timeStyle: 'short' });
/** Zeitpunkt nur als Datum (Laufzeitende, Gültigkeit) – in der Ortszeit des Betrachters. */
export const fmtDate = (d: string | Date) => new Date(d).toLocaleDateString('de-DE', { dateStyle: 'medium' });
/** Reine Datumsspalte (SQL DATE, kommt als UTC-Mitternacht) – ohne Zeitzonenverschiebung. */
export const fmtDay = (d: string | Date) => new Date(d).toLocaleDateString('de-DE', { dateStyle: 'medium', timeZone: 'UTC' });
export const ROLE_LABEL: Record<string, string> = { support: 'Support', accounting: 'Buchhaltung', admin: 'Administrator', superadmin: 'Superadministrator', owner: 'Inhaber', member: 'Mitglied' };
export const STATE: Record<string, { cls: string; icon: string; label: string }> = {