@wopr-network/platform-ui-core 1.10.0 → 1.12.0
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
|
@@ -76,6 +76,16 @@ const PREF_GROUPS: PrefGroup[] = [
|
|
|
76
76
|
},
|
|
77
77
|
],
|
|
78
78
|
},
|
|
79
|
+
{
|
|
80
|
+
title: "Fleet Updates",
|
|
81
|
+
items: [
|
|
82
|
+
{
|
|
83
|
+
key: "fleet_updates",
|
|
84
|
+
label: "Fleet Updates",
|
|
85
|
+
description: "Get notified when updates are available or applied to your fleet.",
|
|
86
|
+
},
|
|
87
|
+
],
|
|
88
|
+
},
|
|
79
89
|
];
|
|
80
90
|
|
|
81
91
|
// ---------------------------------------------------------------------------
|
|
@@ -9,6 +9,7 @@ import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
|
|
|
9
9
|
import {
|
|
10
10
|
type CheckoutResult,
|
|
11
11
|
createCheckout,
|
|
12
|
+
getChargeStatus,
|
|
12
13
|
getSupportedPaymentMethods,
|
|
13
14
|
type SupportedPaymentMethod,
|
|
14
15
|
} from "@/lib/api";
|
|
@@ -43,6 +44,32 @@ export function BuyCryptoCreditPanel() {
|
|
|
43
44
|
const [loading, setLoading] = useState(false);
|
|
44
45
|
const [error, setError] = useState<string | null>(null);
|
|
45
46
|
const [checkout, setCheckout] = useState<CheckoutResult | null>(null);
|
|
47
|
+
const [paymentStatus, setPaymentStatus] = useState<"waiting" | "detected" | "credited" | null>(
|
|
48
|
+
null,
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
// Poll charge status after checkout
|
|
52
|
+
useEffect(() => {
|
|
53
|
+
if (!checkout?.referenceId) {
|
|
54
|
+
setPaymentStatus(null);
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
setPaymentStatus("waiting");
|
|
58
|
+
const interval = setInterval(async () => {
|
|
59
|
+
try {
|
|
60
|
+
const status = await getChargeStatus(checkout.referenceId);
|
|
61
|
+
if (status.credited) {
|
|
62
|
+
setPaymentStatus("credited");
|
|
63
|
+
clearInterval(interval);
|
|
64
|
+
} else if (status.status === "Settled" || status.status === "Processing") {
|
|
65
|
+
setPaymentStatus("detected");
|
|
66
|
+
}
|
|
67
|
+
} catch {
|
|
68
|
+
// Ignore poll errors
|
|
69
|
+
}
|
|
70
|
+
}, 5000);
|
|
71
|
+
return () => clearInterval(interval);
|
|
72
|
+
}, [checkout?.referenceId]);
|
|
46
73
|
|
|
47
74
|
// Fetch available payment methods from backend on mount
|
|
48
75
|
useEffect(() => {
|
|
@@ -148,10 +175,27 @@ export function BuyCryptoCreditPanel() {
|
|
|
148
175
|
<p className="text-xs text-muted-foreground">
|
|
149
176
|
Only send {checkout.token} on the {checkout.chain} network.
|
|
150
177
|
</p>
|
|
178
|
+
{paymentStatus === "waiting" && (
|
|
179
|
+
<p className="text-xs text-yellow-500 animate-pulse">Waiting for payment...</p>
|
|
180
|
+
)}
|
|
181
|
+
{paymentStatus === "detected" && (
|
|
182
|
+
<p className="text-xs text-blue-500">Payment detected, confirming...</p>
|
|
183
|
+
)}
|
|
184
|
+
{paymentStatus === "credited" && (
|
|
185
|
+
<p className="text-xs text-green-500 font-medium">
|
|
186
|
+
Payment confirmed! Credits added to your account.
|
|
187
|
+
</p>
|
|
188
|
+
)}
|
|
151
189
|
</div>
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
190
|
+
{paymentStatus === "credited" ? (
|
|
191
|
+
<Button variant="outline" size="sm" onClick={handleReset}>
|
|
192
|
+
Done
|
|
193
|
+
</Button>
|
|
194
|
+
) : (
|
|
195
|
+
<Button variant="ghost" size="sm" onClick={handleReset}>
|
|
196
|
+
Cancel
|
|
197
|
+
</Button>
|
|
198
|
+
)}
|
|
155
199
|
</motion.div>
|
|
156
200
|
) : (
|
|
157
201
|
<>
|
package/src/lib/api.ts
CHANGED
|
@@ -1362,6 +1362,20 @@ export async function createCheckout(methodId: string, amountUsd: number): Promi
|
|
|
1362
1362
|
return trpcVanilla.billing.checkout.mutate({ methodId, amountUsd });
|
|
1363
1363
|
}
|
|
1364
1364
|
|
|
1365
|
+
// --- Charge status polling ---
|
|
1366
|
+
|
|
1367
|
+
export interface ChargeStatusResult {
|
|
1368
|
+
status: string;
|
|
1369
|
+
credited: boolean;
|
|
1370
|
+
amountUsdCents: number;
|
|
1371
|
+
token: string | null;
|
|
1372
|
+
chain: string | null;
|
|
1373
|
+
}
|
|
1374
|
+
|
|
1375
|
+
export async function getChargeStatus(referenceId: string): Promise<ChargeStatusResult> {
|
|
1376
|
+
return trpcVanilla.billing.chargeStatus.query({ referenceId });
|
|
1377
|
+
}
|
|
1378
|
+
|
|
1365
1379
|
// --- Admin payment method management ---
|
|
1366
1380
|
|
|
1367
1381
|
export interface PaymentMethodAdmin {
|
|
@@ -1692,6 +1706,7 @@ export interface NotificationPreferences {
|
|
|
1692
1706
|
agent_status_changes: boolean;
|
|
1693
1707
|
account_role_changes: boolean;
|
|
1694
1708
|
account_team_invites: boolean;
|
|
1709
|
+
fleet_updates: boolean;
|
|
1695
1710
|
}
|
|
1696
1711
|
|
|
1697
1712
|
// --- Public platform health (no auth required) ---
|