Link tenant packages to events and show usage in billing
Some checks failed
linter / quality (push) Has been cancelled
tests / ci (push) Has been cancelled
tests / ui (push) Has been cancelled

This commit is contained in:
Codex Agent
2026-02-06 12:54:33 +01:00
parent fa114ac0dc
commit 0291d537fb
11 changed files with 572 additions and 51 deletions

View File

@@ -506,6 +506,23 @@ export async function fetchHelpCenterArticle(slug: string, locale?: string): Pro
}
export type TenantPackageSummary = {
current_event?: {
id: number;
slug: string;
name: string | Record<string, string> | null;
status: string | null;
event_date: string | null;
linked_at: string | null;
} | null;
last_event?: {
id: number;
slug: string;
name: string | Record<string, string> | null;
status: string | null;
event_date: string | null;
linked_at: string | null;
} | null;
linked_events_count?: number;
id: number;
package_id: number;
package_name: string;
@@ -1109,6 +1126,50 @@ function normalizeDashboard(payload: JsonValue | null): DashboardSummary | null
export function normalizeTenantPackage(pkg: JsonValue): TenantPackageSummary {
const packageData = pkg.package ?? {};
return {
current_event:
(pkg as any).current_event && typeof (pkg as any).current_event === 'object'
? {
id: Number((pkg as any).current_event.id ?? 0),
slug: String((pkg as any).current_event.slug ?? ''),
name: ((pkg as any).current_event.name ?? null) as string | Record<string, string> | null,
status:
typeof (pkg as any).current_event.status === 'string'
? String((pkg as any).current_event.status)
: null,
event_date:
typeof (pkg as any).current_event.event_date === 'string'
? String((pkg as any).current_event.event_date)
: null,
linked_at:
typeof (pkg as any).current_event.linked_at === 'string'
? String((pkg as any).current_event.linked_at)
: null,
}
: null,
last_event:
(pkg as any).last_event && typeof (pkg as any).last_event === 'object'
? {
id: Number((pkg as any).last_event.id ?? 0),
slug: String((pkg as any).last_event.slug ?? ''),
name: ((pkg as any).last_event.name ?? null) as string | Record<string, string> | null,
status:
typeof (pkg as any).last_event.status === 'string'
? String((pkg as any).last_event.status)
: null,
event_date:
typeof (pkg as any).last_event.event_date === 'string'
? String((pkg as any).last_event.event_date)
: null,
linked_at:
typeof (pkg as any).last_event.linked_at === 'string'
? String((pkg as any).last_event.linked_at)
: null,
}
: null,
linked_events_count:
(pkg as any).linked_events_count === undefined || (pkg as any).linked_events_count === null
? 0
: Number((pkg as any).linked_events_count),
id: Number(pkg.id ?? 0),
package_id: Number(pkg.package_id ?? packageData.id ?? 0),
package_name: String(packageData.name ?? pkg.package_name ?? 'Unbekanntes Package'),