@wopr-network/platform-ui-core 1.19.5 → 1.19.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -75,8 +75,15 @@ function CreditsContent() {
|
|
|
75
75
|
|
|
76
76
|
const balance: CreditBalanceData | null = rawBalance
|
|
77
77
|
? {
|
|
78
|
-
balance:
|
|
79
|
-
|
|
78
|
+
balance:
|
|
79
|
+
((rawBalance as { balance_credits?: number; balance_cents?: number }).balance_credits ??
|
|
80
|
+
(rawBalance as { balance_cents?: number }).balance_cents ??
|
|
81
|
+
0) / 100,
|
|
82
|
+
dailyBurn:
|
|
83
|
+
((rawBalance as { daily_burn_credits?: number; daily_burn_cents?: number })
|
|
84
|
+
.daily_burn_credits ??
|
|
85
|
+
(rawBalance as { daily_burn_cents?: number }).daily_burn_cents ??
|
|
86
|
+
0) / 100,
|
|
80
87
|
runway: (rawBalance as { runway_days?: number | null }).runway_days ?? null,
|
|
81
88
|
}
|
|
82
89
|
: null;
|
package/src/lib/api.ts
CHANGED
|
@@ -1279,8 +1279,8 @@ export interface CheckoutResponse {
|
|
|
1279
1279
|
export async function getCreditBalance(): Promise<CreditBalance> {
|
|
1280
1280
|
const res = await trpcVanilla.billing.creditsBalance.query({});
|
|
1281
1281
|
return {
|
|
1282
|
-
balance: (res?.balance_cents ?? 0) / 100,
|
|
1283
|
-
dailyBurn: (res?.daily_burn_cents ?? 0) / 100,
|
|
1282
|
+
balance: (res?.balance_credits ?? res?.balance_cents ?? 0) / 100,
|
|
1283
|
+
dailyBurn: (res?.daily_burn_credits ?? res?.daily_burn_cents ?? 0) / 100,
|
|
1284
1284
|
runway: res?.runway_days ?? null,
|
|
1285
1285
|
};
|
|
1286
1286
|
}
|
|
@@ -19,12 +19,15 @@ export interface OrgMemberUsageRow {
|
|
|
19
19
|
|
|
20
20
|
// ---- API calls ----
|
|
21
21
|
|
|
22
|
-
export async function getOrgCreditBalance(
|
|
23
|
-
const res = await trpcVanilla.
|
|
22
|
+
export async function getOrgCreditBalance(_orgId: string): Promise<OrgCreditBalance> {
|
|
23
|
+
const res = await trpcVanilla.billing.creditsBalance.query({});
|
|
24
24
|
return {
|
|
25
|
-
balance:
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
balance:
|
|
26
|
+
(res?.balance_credits ?? (res as { balance_cents?: number })?.balance_cents ?? 0) / 100,
|
|
27
|
+
dailyBurn:
|
|
28
|
+
(res?.daily_burn_credits ?? (res as { daily_burn_cents?: number })?.daily_burn_cents ?? 0) /
|
|
29
|
+
100,
|
|
30
|
+
runway: (res as { runway_days?: number | null })?.runway_days ?? null,
|
|
28
31
|
};
|
|
29
32
|
}
|
|
30
33
|
|
|
@@ -33,45 +36,34 @@ export async function getOrgMemberUsage(orgId: string): Promise<{
|
|
|
33
36
|
periodStart: string;
|
|
34
37
|
members: OrgMemberUsageRow[];
|
|
35
38
|
}> {
|
|
36
|
-
|
|
37
|
-
const members = Array.isArray(res?.members) ? res.members : [];
|
|
39
|
+
// org.orgMemberUsage not yet implemented — return empty
|
|
38
40
|
return {
|
|
39
|
-
orgId
|
|
40
|
-
periodStart:
|
|
41
|
-
members:
|
|
42
|
-
members as Array<{
|
|
43
|
-
memberId?: string;
|
|
44
|
-
name?: string;
|
|
45
|
-
email?: string;
|
|
46
|
-
creditsConsumedCents?: number;
|
|
47
|
-
lastActiveAt?: string | null;
|
|
48
|
-
}>
|
|
49
|
-
).map((m) => ({
|
|
50
|
-
memberId: m.memberId ?? "",
|
|
51
|
-
name: m.name ?? "",
|
|
52
|
-
email: m.email ?? "",
|
|
53
|
-
creditsConsumed: (m.creditsConsumedCents ?? 0) / 100,
|
|
54
|
-
lastActiveAt: m.lastActiveAt ?? null,
|
|
55
|
-
})),
|
|
41
|
+
orgId,
|
|
42
|
+
periodStart: new Date().toISOString(),
|
|
43
|
+
members: [],
|
|
56
44
|
};
|
|
57
45
|
}
|
|
58
46
|
|
|
59
|
-
export async function getOrgBillingInfo(
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
47
|
+
export async function getOrgBillingInfo(_orgId: string) {
|
|
48
|
+
try {
|
|
49
|
+
const res = await trpcVanilla.billing.billingInfo.query({});
|
|
50
|
+
return {
|
|
51
|
+
paymentMethods: Array.isArray(res?.paymentMethods) ? res.paymentMethods : [],
|
|
52
|
+
invoices: Array.isArray(res?.invoices)
|
|
53
|
+
? (res.invoices as Invoice[]).map((inv) => ({
|
|
54
|
+
id: inv.id ?? "",
|
|
55
|
+
date: inv.date ?? "",
|
|
56
|
+
amount: inv.amount ?? 0,
|
|
57
|
+
status: inv.status ?? ("paid" as const),
|
|
58
|
+
downloadUrl: inv.downloadUrl ?? "",
|
|
59
|
+
hostedUrl: inv.hostedUrl ?? "",
|
|
60
|
+
hostedLineItems: inv.hostedLineItems,
|
|
61
|
+
}))
|
|
62
|
+
: ([] as Invoice[]),
|
|
63
|
+
};
|
|
64
|
+
} catch {
|
|
65
|
+
return { paymentMethods: [], invoices: [] as Invoice[] };
|
|
66
|
+
}
|
|
75
67
|
}
|
|
76
68
|
|
|
77
69
|
export async function createOrgTopupCheckout(
|