@wopr-network/platform-ui-core 1.1.1 → 1.1.3
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 +1 -1
- package/src/lib/api.ts +2 -2
- package/src/lib/brand-config.ts +29 -1
package/package.json
CHANGED
package/src/lib/api.ts
CHANGED
|
@@ -1274,8 +1274,8 @@ export interface CheckoutResponse {
|
|
|
1274
1274
|
export async function getCreditBalance(): Promise<CreditBalance> {
|
|
1275
1275
|
const res = await trpcVanilla.billing.creditsBalance.query({});
|
|
1276
1276
|
return {
|
|
1277
|
-
balance: (res?.balance_cents ?? 0) / 100,
|
|
1278
|
-
dailyBurn: (res?.daily_burn_cents ?? 0) / 100,
|
|
1277
|
+
balance: (res?.balance_credits ?? res?.balance_cents ?? 0) / 100,
|
|
1278
|
+
dailyBurn: (res?.daily_burn_credits ?? res?.daily_burn_cents ?? 0) / 100,
|
|
1279
1279
|
runway: res?.runway_days ?? null,
|
|
1280
1280
|
};
|
|
1281
1281
|
}
|
package/src/lib/brand-config.ts
CHANGED
|
@@ -74,6 +74,34 @@ export interface BrandConfig {
|
|
|
74
74
|
* its env vars in .env (or .env.local) and the config picks them up
|
|
75
75
|
* at build time — no code changes required.
|
|
76
76
|
*/
|
|
77
|
+
/**
|
|
78
|
+
* Parse NEXT_PUBLIC_BRAND_NAV_ITEMS env var.
|
|
79
|
+
* Format: JSON array of {label, href} objects.
|
|
80
|
+
* Example: '[{"label":"Home","href":"/"},{"label":"Settings","href":"/settings"}]'
|
|
81
|
+
* Returns null if unset or invalid (falls back to defaults).
|
|
82
|
+
*/
|
|
83
|
+
function parseNavItems(raw: string | undefined): Array<{ label: string; href: string }> | null {
|
|
84
|
+
if (!raw) return null;
|
|
85
|
+
try {
|
|
86
|
+
const parsed = JSON.parse(raw);
|
|
87
|
+
if (
|
|
88
|
+
Array.isArray(parsed) &&
|
|
89
|
+
parsed.every(
|
|
90
|
+
(item: unknown) =>
|
|
91
|
+
typeof item === "object" &&
|
|
92
|
+
item !== null &&
|
|
93
|
+
typeof (item as { label?: unknown }).label === "string" &&
|
|
94
|
+
typeof (item as { href?: unknown }).href === "string",
|
|
95
|
+
)
|
|
96
|
+
) {
|
|
97
|
+
return parsed as Array<{ label: string; href: string }>;
|
|
98
|
+
}
|
|
99
|
+
} catch {
|
|
100
|
+
// Invalid JSON — fall back to defaults
|
|
101
|
+
}
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
|
|
77
105
|
function envDefaults(): BrandConfig {
|
|
78
106
|
// Direct process.env.X access is required — Next.js Turbopack only inlines
|
|
79
107
|
// NEXT_PUBLIC_* vars when accessed as literal dot-property references.
|
|
@@ -102,7 +130,7 @@ function envDefaults(): BrandConfig {
|
|
|
102
130
|
companyLegalName: process.env.NEXT_PUBLIC_BRAND_COMPANY_LEGAL || "Platform Inc.",
|
|
103
131
|
price: process.env.NEXT_PUBLIC_BRAND_PRICE || "",
|
|
104
132
|
homePath: process.env.NEXT_PUBLIC_BRAND_HOME_PATH || "/marketplace",
|
|
105
|
-
navItems: [
|
|
133
|
+
navItems: parseNavItems(process.env.NEXT_PUBLIC_BRAND_NAV_ITEMS) ?? [
|
|
106
134
|
{ label: "Dashboard", href: "/dashboard" },
|
|
107
135
|
{ label: "Chat", href: "/chat" },
|
|
108
136
|
{ label: "Marketplace", href: "/marketplace" },
|