Link tenant packages to events and show usage in billing
This commit is contained in:
@@ -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'),
|
||||
|
||||
Reference in New Issue
Block a user