@djangocfg/ext-payments 1.0.13 → 1.0.17

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.
Files changed (59) hide show
  1. package/dist/config.cjs +5 -8
  2. package/dist/config.js +5 -8
  3. package/dist/hooks.cjs +1 -1
  4. package/dist/hooks.js +1 -1
  5. package/dist/index.cjs +1085 -1107
  6. package/dist/index.d.cts +480 -41
  7. package/dist/index.d.ts +480 -41
  8. package/dist/index.js +1037 -1093
  9. package/package.json +13 -16
  10. package/src/api/generated/ext_payments/CLAUDE.md +7 -3
  11. package/src/api/generated/ext_payments/_utils/fetchers/ext_payments__payments.ts +237 -5
  12. package/src/api/generated/ext_payments/_utils/hooks/ext_payments__payments.ts +71 -3
  13. package/src/api/generated/ext_payments/_utils/schemas/PaginatedWithdrawalListList.schema.ts +24 -0
  14. package/src/api/generated/ext_payments/_utils/schemas/PaymentCreateRequest.schema.ts +21 -0
  15. package/src/api/generated/ext_payments/_utils/schemas/WithdrawalCreateRequest.schema.ts +21 -0
  16. package/src/api/generated/ext_payments/_utils/schemas/WithdrawalDetail.schema.ts +42 -0
  17. package/src/api/generated/ext_payments/_utils/schemas/WithdrawalList.schema.ts +29 -0
  18. package/src/api/generated/ext_payments/_utils/schemas/index.ts +5 -0
  19. package/src/api/generated/ext_payments/enums.ts +36 -0
  20. package/src/api/generated/ext_payments/ext_payments__payments/client.ts +58 -5
  21. package/src/api/generated/ext_payments/ext_payments__payments/models.ts +141 -0
  22. package/src/api/generated/ext_payments/schema.json +579 -3
  23. package/src/components/ActivityItem.tsx +118 -0
  24. package/src/components/ActivityList.tsx +93 -0
  25. package/src/components/AddFundsSheet.tsx +258 -0
  26. package/src/components/BalanceHero.tsx +102 -0
  27. package/src/components/PaymentSheet.tsx +290 -0
  28. package/src/components/ResponsiveSheet.tsx +151 -0
  29. package/src/components/WithdrawSheet.tsx +329 -0
  30. package/src/components/index.ts +18 -0
  31. package/src/contexts/WalletContext.tsx +355 -0
  32. package/src/contexts/index.ts +12 -45
  33. package/src/index.ts +6 -18
  34. package/src/contexts/BalancesContext.tsx +0 -63
  35. package/src/contexts/CurrenciesContext.tsx +0 -64
  36. package/src/contexts/OverviewContext.tsx +0 -173
  37. package/src/contexts/PaymentsContext.tsx +0 -122
  38. package/src/contexts/PaymentsExtensionProvider.tsx +0 -56
  39. package/src/contexts/README.md +0 -201
  40. package/src/contexts/RootPaymentsContext.tsx +0 -66
  41. package/src/contexts/types.ts +0 -40
  42. package/src/hooks/index.ts +0 -20
  43. package/src/layouts/PaymentsLayout/PaymentsLayout.tsx +0 -90
  44. package/src/layouts/PaymentsLayout/components/CreatePaymentDialog.tsx +0 -274
  45. package/src/layouts/PaymentsLayout/components/PaymentDetailsDialog.tsx +0 -287
  46. package/src/layouts/PaymentsLayout/components/index.ts +0 -2
  47. package/src/layouts/PaymentsLayout/events.ts +0 -47
  48. package/src/layouts/PaymentsLayout/index.ts +0 -16
  49. package/src/layouts/PaymentsLayout/types.ts +0 -6
  50. package/src/layouts/PaymentsLayout/views/overview/components/BalanceCard.tsx +0 -121
  51. package/src/layouts/PaymentsLayout/views/overview/components/RecentPayments.tsx +0 -139
  52. package/src/layouts/PaymentsLayout/views/overview/components/index.ts +0 -2
  53. package/src/layouts/PaymentsLayout/views/overview/index.tsx +0 -21
  54. package/src/layouts/PaymentsLayout/views/payments/components/PaymentsList.tsx +0 -279
  55. package/src/layouts/PaymentsLayout/views/payments/components/index.ts +0 -1
  56. package/src/layouts/PaymentsLayout/views/payments/index.tsx +0 -18
  57. package/src/layouts/PaymentsLayout/views/transactions/components/TransactionsList.tsx +0 -260
  58. package/src/layouts/PaymentsLayout/views/transactions/components/index.ts +0 -1
  59. package/src/layouts/PaymentsLayout/views/transactions/index.tsx +0 -18
package/dist/index.cjs CHANGED
@@ -6,20 +6,39 @@ var zod = require('zod');
6
6
  var api = require('@djangocfg/ext-base/api');
7
7
  var lucideReact = require('lucide-react');
8
8
  var uiCore = require('@djangocfg/ui-core');
9
- var react = require('react');
10
- var useSWR = require('swr');
9
+ var lib = require('@djangocfg/ui-core/lib');
10
+ var React2 = require('react');
11
+ var useSWR2 = require('swr');
11
12
  var jsxRuntime = require('react/jsx-runtime');
13
+ var moment2 = require('moment');
12
14
  var reactHookForm = require('react-hook-form');
13
15
  var zod$1 = require('@hookform/resolvers/zod');
14
- var moment = require('moment');
15
- var components = require('@djangocfg/ui-nextjs/components');
16
16
  var extBase = require('@djangocfg/ext-base');
17
17
 
18
18
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
19
19
 
20
+ function _interopNamespace(e) {
21
+ if (e && e.__esModule) return e;
22
+ var n = Object.create(null);
23
+ if (e) {
24
+ Object.keys(e).forEach(function (k) {
25
+ if (k !== 'default') {
26
+ var d = Object.getOwnPropertyDescriptor(e, k);
27
+ Object.defineProperty(n, k, d.get ? d : {
28
+ enumerable: true,
29
+ get: function () { return e[k]; }
30
+ });
31
+ }
32
+ });
33
+ }
34
+ n.default = e;
35
+ return Object.freeze(n);
36
+ }
37
+
20
38
  var pRetry__default = /*#__PURE__*/_interopDefault(pRetry);
21
- var useSWR__default = /*#__PURE__*/_interopDefault(useSWR);
22
- var moment__default = /*#__PURE__*/_interopDefault(moment);
39
+ var React2__namespace = /*#__PURE__*/_interopNamespace(React2);
40
+ var useSWR2__default = /*#__PURE__*/_interopDefault(useSWR2);
41
+ var moment2__default = /*#__PURE__*/_interopDefault(moment2);
23
42
 
24
43
  var __defProp = Object.defineProperty;
25
44
  var __export = (target, all) => {
@@ -97,12 +116,12 @@ var ExtPaymentsPayments = class {
97
116
  return response.results || response;
98
117
  }
99
118
  /**
100
- * POST /api/v1/payments/create/ Create new payment. Request body: {
101
- * "amount_usd": "100.00", "currency_code": "USDTTRC20", "description":
102
- * "Optional description" }
119
+ * Create payment
120
+ *
121
+ * Create a new payment with specified amount and currency
103
122
  */
104
- async paymentsCreateCreate() {
105
- const response = await this.client.request("POST", "/cfg/payments/payments/create/");
123
+ async paymentsCreateCreate(data) {
124
+ const response = await this.client.request("POST", "/cfg/payments/payments/create/", { body: data });
106
125
  return response;
107
126
  }
108
127
  /**
@@ -121,6 +140,51 @@ var ExtPaymentsPayments = class {
121
140
  const response = await this.client.request("GET", "/cfg/payments/transactions/", { params });
122
141
  return response;
123
142
  }
143
+ /**
144
+ * ViewSet for withdrawal operations. Endpoints: - GET /withdrawals/ - List
145
+ * user's withdrawal requests - GET /withdrawals/{id}/ - Get withdrawal
146
+ * details - POST /withdrawals/create/ - Create withdrawal request - POST
147
+ * /withdrawals/{id}/cancel/ - Cancel pending withdrawal
148
+ */
149
+ async withdrawalsList(...args) {
150
+ const isParamsObject = args.length === 1 && typeof args[0] === "object" && args[0] !== null && !Array.isArray(args[0]);
151
+ let params;
152
+ if (isParamsObject) {
153
+ params = args[0];
154
+ } else {
155
+ params = { page: args[0], page_size: args[1] };
156
+ }
157
+ const response = await this.client.request("GET", "/cfg/payments/withdrawals/", { params });
158
+ return response;
159
+ }
160
+ /**
161
+ * ViewSet for withdrawal operations. Endpoints: - GET /withdrawals/ - List
162
+ * user's withdrawal requests - GET /withdrawals/{id}/ - Get withdrawal
163
+ * details - POST /withdrawals/create/ - Create withdrawal request - POST
164
+ * /withdrawals/{id}/cancel/ - Cancel pending withdrawal
165
+ */
166
+ async withdrawalsRetrieve(id) {
167
+ const response = await this.client.request("GET", `/cfg/payments/withdrawals/${id}/`);
168
+ return response;
169
+ }
170
+ /**
171
+ * Cancel withdrawal request
172
+ *
173
+ * Cancel a pending withdrawal request
174
+ */
175
+ async withdrawalsCancelCreate(id) {
176
+ const response = await this.client.request("POST", `/cfg/payments/withdrawals/${id}/cancel/`);
177
+ return response;
178
+ }
179
+ /**
180
+ * Create withdrawal request
181
+ *
182
+ * Create a new withdrawal request (requires admin approval)
183
+ */
184
+ async withdrawalsCreateCreate(data) {
185
+ const response = await this.client.request("POST", "/cfg/payments/withdrawals/create/", { body: data });
186
+ return response;
187
+ }
124
188
  };
125
189
 
126
190
  // src/api/generated/ext_payments/ext_payments__payments/models.ts
@@ -683,8 +747,8 @@ var APIClient = class {
683
747
  // src/api/generated/ext_payments/storage.ts
684
748
  var LocalStorageAdapter = class {
685
749
  logger;
686
- constructor(logger2) {
687
- this.logger = logger2;
750
+ constructor(logger) {
751
+ this.logger = logger;
688
752
  }
689
753
  getItem(key) {
690
754
  try {
@@ -726,8 +790,8 @@ var LocalStorageAdapter = class {
726
790
  };
727
791
  var CookieStorageAdapter = class {
728
792
  logger;
729
- constructor(logger2) {
730
- this.logger = logger2;
793
+ constructor(logger) {
794
+ this.logger = logger;
731
795
  }
732
796
  getItem(key) {
733
797
  try {
@@ -776,8 +840,8 @@ var CookieStorageAdapter = class {
776
840
  var MemoryStorageAdapter = class {
777
841
  storage = /* @__PURE__ */ new Map();
778
842
  logger;
779
- constructor(logger2) {
780
- this.logger = logger2;
843
+ constructor(logger) {
844
+ this.logger = logger;
781
845
  }
782
846
  getItem(key) {
783
847
  const value = this.storage.get(key) || null;
@@ -799,7 +863,9 @@ var enums_exports = {};
799
863
  __export(enums_exports, {
800
864
  PaymentDetailStatus: () => PaymentDetailStatus,
801
865
  PaymentListStatus: () => PaymentListStatus,
802
- TransactionTransactionType: () => TransactionTransactionType
866
+ TransactionTransactionType: () => TransactionTransactionType,
867
+ WithdrawalDetailStatus: () => WithdrawalDetailStatus,
868
+ WithdrawalListStatus: () => WithdrawalListStatus
803
869
  });
804
870
  var PaymentDetailStatus = /* @__PURE__ */ ((PaymentDetailStatus2) => {
805
871
  PaymentDetailStatus2["PENDING"] = "pending";
@@ -833,6 +899,24 @@ var TransactionTransactionType = /* @__PURE__ */ ((TransactionTransactionType2)
833
899
  TransactionTransactionType2["ADJUSTMENT"] = "adjustment";
834
900
  return TransactionTransactionType2;
835
901
  })(TransactionTransactionType || {});
902
+ var WithdrawalDetailStatus = /* @__PURE__ */ ((WithdrawalDetailStatus2) => {
903
+ WithdrawalDetailStatus2["PENDING"] = "pending";
904
+ WithdrawalDetailStatus2["APPROVED"] = "approved";
905
+ WithdrawalDetailStatus2["PROCESSING"] = "processing";
906
+ WithdrawalDetailStatus2["COMPLETED"] = "completed";
907
+ WithdrawalDetailStatus2["REJECTED"] = "rejected";
908
+ WithdrawalDetailStatus2["CANCELLED"] = "cancelled";
909
+ return WithdrawalDetailStatus2;
910
+ })(WithdrawalDetailStatus || {});
911
+ var WithdrawalListStatus = /* @__PURE__ */ ((WithdrawalListStatus2) => {
912
+ WithdrawalListStatus2["PENDING"] = "pending";
913
+ WithdrawalListStatus2["APPROVED"] = "approved";
914
+ WithdrawalListStatus2["PROCESSING"] = "processing";
915
+ WithdrawalListStatus2["COMPLETED"] = "completed";
916
+ WithdrawalListStatus2["REJECTED"] = "rejected";
917
+ WithdrawalListStatus2["CANCELLED"] = "cancelled";
918
+ return WithdrawalListStatus2;
919
+ })(WithdrawalListStatus || {});
836
920
 
837
921
  // src/api/generated/ext_payments/_utils/schemas/index.ts
838
922
  var schemas_exports = {};
@@ -840,9 +924,14 @@ __export(schemas_exports, {
840
924
  BalanceSchema: () => BalanceSchema,
841
925
  CurrencySchema: () => CurrencySchema,
842
926
  PaginatedPaymentListListSchema: () => PaginatedPaymentListListSchema,
927
+ PaginatedWithdrawalListListSchema: () => PaginatedWithdrawalListListSchema,
928
+ PaymentCreateRequestSchema: () => PaymentCreateRequestSchema,
843
929
  PaymentDetailSchema: () => PaymentDetailSchema,
844
930
  PaymentListSchema: () => PaymentListSchema,
845
- TransactionSchema: () => TransactionSchema
931
+ TransactionSchema: () => TransactionSchema,
932
+ WithdrawalCreateRequestSchema: () => WithdrawalCreateRequestSchema,
933
+ WithdrawalDetailSchema: () => WithdrawalDetailSchema,
934
+ WithdrawalListSchema: () => WithdrawalListSchema
846
935
  });
847
936
  var BalanceSchema = zod.z.object({
848
937
  balance_usd: zod.z.string(),
@@ -887,6 +976,36 @@ var PaginatedPaymentListListSchema = zod.z.object({
887
976
  previous_page: zod.z.int().nullable().optional(),
888
977
  results: zod.z.array(PaymentListSchema)
889
978
  });
979
+ var WithdrawalListSchema = zod.z.object({
980
+ id: zod.z.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i),
981
+ internal_withdrawal_id: zod.z.string(),
982
+ amount_usd: zod.z.string(),
983
+ final_amount_usd: zod.z.string(),
984
+ currency_code: zod.z.string(),
985
+ currency_token: zod.z.string(),
986
+ status: zod.z.nativeEnum(WithdrawalListStatus),
987
+ status_display: zod.z.string(),
988
+ created_at: zod.z.iso.datetime(),
989
+ completed_at: zod.z.iso.datetime().nullable()
990
+ });
991
+
992
+ // src/api/generated/ext_payments/_utils/schemas/PaginatedWithdrawalListList.schema.ts
993
+ var PaginatedWithdrawalListListSchema = zod.z.object({
994
+ count: zod.z.int(),
995
+ page: zod.z.int(),
996
+ pages: zod.z.int(),
997
+ page_size: zod.z.int(),
998
+ has_next: zod.z.boolean(),
999
+ has_previous: zod.z.boolean(),
1000
+ next_page: zod.z.int().nullable().optional(),
1001
+ previous_page: zod.z.int().nullable().optional(),
1002
+ results: zod.z.array(WithdrawalListSchema)
1003
+ });
1004
+ var PaymentCreateRequestSchema = zod.z.object({
1005
+ amount_usd: zod.z.string(),
1006
+ currency_code: zod.z.string().min(1).max(20),
1007
+ description: zod.z.string().max(500).optional()
1008
+ });
890
1009
  var PaymentDetailSchema = zod.z.object({
891
1010
  id: zod.z.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i),
892
1011
  internal_payment_id: zod.z.string(),
@@ -925,6 +1044,36 @@ var TransactionSchema = zod.z.object({
925
1044
  description: zod.z.string(),
926
1045
  created_at: zod.z.iso.datetime()
927
1046
  });
1047
+ var WithdrawalCreateRequestSchema = zod.z.object({
1048
+ amount_usd: zod.z.string(),
1049
+ currency_code: zod.z.string().min(1).max(20),
1050
+ wallet_address: zod.z.string().min(1).max(255)
1051
+ });
1052
+ var WithdrawalDetailSchema = zod.z.object({
1053
+ id: zod.z.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i),
1054
+ internal_withdrawal_id: zod.z.string(),
1055
+ amount_usd: zod.z.string(),
1056
+ currency_code: zod.z.string(),
1057
+ currency_name: zod.z.string(),
1058
+ currency_token: zod.z.string(),
1059
+ currency_network: zod.z.string(),
1060
+ wallet_address: zod.z.string(),
1061
+ network_fee_usd: zod.z.string(),
1062
+ service_fee_usd: zod.z.string(),
1063
+ total_fee_usd: zod.z.string(),
1064
+ final_amount_usd: zod.z.string(),
1065
+ crypto_amount: zod.z.string().nullable(),
1066
+ status: zod.z.nativeEnum(WithdrawalDetailStatus),
1067
+ status_display: zod.z.string(),
1068
+ transaction_hash: zod.z.string().nullable(),
1069
+ explorer_link: zod.z.string().nullable(),
1070
+ admin_notes: zod.z.string(),
1071
+ created_at: zod.z.iso.datetime(),
1072
+ approved_at: zod.z.iso.datetime().nullable(),
1073
+ completed_at: zod.z.iso.datetime().nullable(),
1074
+ rejected_at: zod.z.iso.datetime().nullable(),
1075
+ cancelled_at: zod.z.iso.datetime().nullable()
1076
+ });
928
1077
 
929
1078
  // src/api/generated/ext_payments/validation-events.ts
930
1079
  function dispatchValidationError(detail) {
@@ -977,12 +1126,16 @@ var fetchers_exports = {};
977
1126
  __export(fetchers_exports, {
978
1127
  createPaymentsPaymentsConfirmCreate: () => createPaymentsPaymentsConfirmCreate,
979
1128
  createPaymentsPaymentsCreateCreate: () => createPaymentsPaymentsCreateCreate,
1129
+ createPaymentsWithdrawalsCancelCreate: () => createPaymentsWithdrawalsCancelCreate,
1130
+ createPaymentsWithdrawalsCreateCreate: () => createPaymentsWithdrawalsCreateCreate,
980
1131
  getPaymentsBalanceRetrieve: () => getPaymentsBalanceRetrieve,
981
1132
  getPaymentsCurrenciesList: () => getPaymentsCurrenciesList,
982
1133
  getPaymentsPaymentsList: () => getPaymentsPaymentsList,
983
1134
  getPaymentsPaymentsRetrieve: () => getPaymentsPaymentsRetrieve,
984
1135
  getPaymentsPaymentsStatusRetrieve: () => getPaymentsPaymentsStatusRetrieve,
985
- getPaymentsTransactionsList: () => getPaymentsTransactionsList
1136
+ getPaymentsTransactionsList: () => getPaymentsTransactionsList,
1137
+ getPaymentsWithdrawalsList: () => getPaymentsWithdrawalsList,
1138
+ getPaymentsWithdrawalsRetrieve: () => getPaymentsWithdrawalsRetrieve
986
1139
  });
987
1140
 
988
1141
  // src/api/generated/ext_payments/api-instance.ts
@@ -1255,11 +1408,11 @@ Method: GET`);
1255
1408
  throw error;
1256
1409
  }
1257
1410
  }
1258
- async function createPaymentsPaymentsCreateCreate(client) {
1411
+ async function createPaymentsPaymentsCreateCreate(data, client) {
1259
1412
  const api = client || getAPIInstance();
1260
- const response = await api.ext_payments_payments.paymentsCreateCreate();
1413
+ const response = await api.ext_payments_payments.paymentsCreateCreate(data);
1261
1414
  try {
1262
- return PaymentListSchema.parse(response);
1415
+ return PaymentDetailSchema.parse(response);
1263
1416
  } catch (error) {
1264
1417
  consola.consola.error("\u274C Zod Validation Failed");
1265
1418
  consola.consola.box(`createPaymentsPaymentsCreateCreate
@@ -1302,6 +1455,174 @@ async function getPaymentsTransactionsList(params, client) {
1302
1455
  const response = await api.ext_payments_payments.transactionsList(params?.limit, params?.offset, params?.type);
1303
1456
  return response;
1304
1457
  }
1458
+ async function getPaymentsWithdrawalsList(params, client) {
1459
+ const api = client || getAPIInstance();
1460
+ const response = await api.ext_payments_payments.withdrawalsList(params?.page, params?.page_size);
1461
+ try {
1462
+ return PaginatedWithdrawalListListSchema.parse(response);
1463
+ } catch (error) {
1464
+ consola.consola.error("\u274C Zod Validation Failed");
1465
+ consola.consola.box(`getPaymentsWithdrawalsList
1466
+ Path: /cfg/payments/withdrawals/
1467
+ Method: GET`);
1468
+ if (error instanceof Error && "issues" in error && Array.isArray(error.issues)) {
1469
+ consola.consola.error("Validation Issues:");
1470
+ error.issues.forEach((issue, index) => {
1471
+ consola.consola.error(` ${index + 1}. ${issue.path.join(".") || "root"}`);
1472
+ consola.consola.error(` \u251C\u2500 Message: ${issue.message}`);
1473
+ if (issue.expected) consola.consola.error(` \u251C\u2500 Expected: ${issue.expected}`);
1474
+ if (issue.received) consola.consola.error(` \u2514\u2500 Received: ${issue.received}`);
1475
+ });
1476
+ }
1477
+ consola.consola.error("Response data:", response);
1478
+ if (typeof window !== "undefined" && error instanceof Error && "issues" in error) {
1479
+ try {
1480
+ const event = new CustomEvent("zod-validation-error", {
1481
+ detail: {
1482
+ operation: "getPaymentsWithdrawalsList",
1483
+ path: "/cfg/payments/withdrawals/",
1484
+ method: "GET",
1485
+ error,
1486
+ response,
1487
+ timestamp: /* @__PURE__ */ new Date()
1488
+ },
1489
+ bubbles: true,
1490
+ cancelable: false
1491
+ });
1492
+ window.dispatchEvent(event);
1493
+ } catch (eventError) {
1494
+ consola.consola.warn("Failed to dispatch validation error event:", eventError);
1495
+ }
1496
+ }
1497
+ throw error;
1498
+ }
1499
+ }
1500
+ async function getPaymentsWithdrawalsRetrieve(id, client) {
1501
+ const api = client || getAPIInstance();
1502
+ const response = await api.ext_payments_payments.withdrawalsRetrieve(id);
1503
+ try {
1504
+ return WithdrawalDetailSchema.parse(response);
1505
+ } catch (error) {
1506
+ consola.consola.error("\u274C Zod Validation Failed");
1507
+ consola.consola.box(`getPaymentsWithdrawalsRetrieve
1508
+ Path: /cfg/payments/withdrawals/{id}/
1509
+ Method: GET`);
1510
+ if (error instanceof Error && "issues" in error && Array.isArray(error.issues)) {
1511
+ consola.consola.error("Validation Issues:");
1512
+ error.issues.forEach((issue, index) => {
1513
+ consola.consola.error(` ${index + 1}. ${issue.path.join(".") || "root"}`);
1514
+ consola.consola.error(` \u251C\u2500 Message: ${issue.message}`);
1515
+ if (issue.expected) consola.consola.error(` \u251C\u2500 Expected: ${issue.expected}`);
1516
+ if (issue.received) consola.consola.error(` \u2514\u2500 Received: ${issue.received}`);
1517
+ });
1518
+ }
1519
+ consola.consola.error("Response data:", response);
1520
+ if (typeof window !== "undefined" && error instanceof Error && "issues" in error) {
1521
+ try {
1522
+ const event = new CustomEvent("zod-validation-error", {
1523
+ detail: {
1524
+ operation: "getPaymentsWithdrawalsRetrieve",
1525
+ path: "/cfg/payments/withdrawals/{id}/",
1526
+ method: "GET",
1527
+ error,
1528
+ response,
1529
+ timestamp: /* @__PURE__ */ new Date()
1530
+ },
1531
+ bubbles: true,
1532
+ cancelable: false
1533
+ });
1534
+ window.dispatchEvent(event);
1535
+ } catch (eventError) {
1536
+ consola.consola.warn("Failed to dispatch validation error event:", eventError);
1537
+ }
1538
+ }
1539
+ throw error;
1540
+ }
1541
+ }
1542
+ async function createPaymentsWithdrawalsCancelCreate(id, client) {
1543
+ const api = client || getAPIInstance();
1544
+ const response = await api.ext_payments_payments.withdrawalsCancelCreate(id);
1545
+ try {
1546
+ return WithdrawalDetailSchema.parse(response);
1547
+ } catch (error) {
1548
+ consola.consola.error("\u274C Zod Validation Failed");
1549
+ consola.consola.box(`createPaymentsWithdrawalsCancelCreate
1550
+ Path: /cfg/payments/withdrawals/{id}/cancel/
1551
+ Method: POST`);
1552
+ if (error instanceof Error && "issues" in error && Array.isArray(error.issues)) {
1553
+ consola.consola.error("Validation Issues:");
1554
+ error.issues.forEach((issue, index) => {
1555
+ consola.consola.error(` ${index + 1}. ${issue.path.join(".") || "root"}`);
1556
+ consola.consola.error(` \u251C\u2500 Message: ${issue.message}`);
1557
+ if (issue.expected) consola.consola.error(` \u251C\u2500 Expected: ${issue.expected}`);
1558
+ if (issue.received) consola.consola.error(` \u2514\u2500 Received: ${issue.received}`);
1559
+ });
1560
+ }
1561
+ consola.consola.error("Response data:", response);
1562
+ if (typeof window !== "undefined" && error instanceof Error && "issues" in error) {
1563
+ try {
1564
+ const event = new CustomEvent("zod-validation-error", {
1565
+ detail: {
1566
+ operation: "createPaymentsWithdrawalsCancelCreate",
1567
+ path: "/cfg/payments/withdrawals/{id}/cancel/",
1568
+ method: "POST",
1569
+ error,
1570
+ response,
1571
+ timestamp: /* @__PURE__ */ new Date()
1572
+ },
1573
+ bubbles: true,
1574
+ cancelable: false
1575
+ });
1576
+ window.dispatchEvent(event);
1577
+ } catch (eventError) {
1578
+ consola.consola.warn("Failed to dispatch validation error event:", eventError);
1579
+ }
1580
+ }
1581
+ throw error;
1582
+ }
1583
+ }
1584
+ async function createPaymentsWithdrawalsCreateCreate(data, client) {
1585
+ const api = client || getAPIInstance();
1586
+ const response = await api.ext_payments_payments.withdrawalsCreateCreate(data);
1587
+ try {
1588
+ return WithdrawalDetailSchema.parse(response);
1589
+ } catch (error) {
1590
+ consola.consola.error("\u274C Zod Validation Failed");
1591
+ consola.consola.box(`createPaymentsWithdrawalsCreateCreate
1592
+ Path: /cfg/payments/withdrawals/create/
1593
+ Method: POST`);
1594
+ if (error instanceof Error && "issues" in error && Array.isArray(error.issues)) {
1595
+ consola.consola.error("Validation Issues:");
1596
+ error.issues.forEach((issue, index) => {
1597
+ consola.consola.error(` ${index + 1}. ${issue.path.join(".") || "root"}`);
1598
+ consola.consola.error(` \u251C\u2500 Message: ${issue.message}`);
1599
+ if (issue.expected) consola.consola.error(` \u251C\u2500 Expected: ${issue.expected}`);
1600
+ if (issue.received) consola.consola.error(` \u2514\u2500 Received: ${issue.received}`);
1601
+ });
1602
+ }
1603
+ consola.consola.error("Response data:", response);
1604
+ if (typeof window !== "undefined" && error instanceof Error && "issues" in error) {
1605
+ try {
1606
+ const event = new CustomEvent("zod-validation-error", {
1607
+ detail: {
1608
+ operation: "createPaymentsWithdrawalsCreateCreate",
1609
+ path: "/cfg/payments/withdrawals/create/",
1610
+ method: "POST",
1611
+ error,
1612
+ response,
1613
+ timestamp: /* @__PURE__ */ new Date()
1614
+ },
1615
+ bubbles: true,
1616
+ cancelable: false
1617
+ });
1618
+ window.dispatchEvent(event);
1619
+ } catch (eventError) {
1620
+ consola.consola.warn("Failed to dispatch validation error event:", eventError);
1621
+ }
1622
+ }
1623
+ throw error;
1624
+ }
1625
+ }
1305
1626
 
1306
1627
  // src/api/generated/ext_payments/index.ts
1307
1628
  var TOKEN_KEY = "auth_token";
@@ -1318,8 +1639,8 @@ var API = class {
1318
1639
  constructor(baseUrl, options) {
1319
1640
  this.baseUrl = baseUrl;
1320
1641
  this.options = options;
1321
- const logger2 = options?.loggerConfig ? new APILogger(options.loggerConfig) : void 0;
1322
- this.storage = options?.storage || new LocalStorageAdapter(logger2);
1642
+ const logger = options?.loggerConfig ? new APILogger(options.loggerConfig) : void 0;
1643
+ this.storage = options?.storage || new LocalStorageAdapter(logger);
1323
1644
  this._loadTokensFromStorage();
1324
1645
  this._client = new APIClient(this.baseUrl, {
1325
1646
  retryConfig: this.options?.retryConfig,
@@ -1430,333 +1751,296 @@ var API = class {
1430
1751
  };
1431
1752
  api.initializeExtensionAPI(configureAPI);
1432
1753
  var apiPayments = api.createExtensionAPI(API);
1433
- function usePaymentsBalanceRetrieve(client) {
1434
- return useSWR__default.default(
1435
- "cfg-payments-balance",
1436
- () => getPaymentsBalanceRetrieve(client)
1437
- );
1438
- }
1439
- function usePaymentsCurrenciesList(client) {
1440
- return useSWR__default.default(
1441
- "cfg-payments-currencies",
1442
- () => getPaymentsCurrenciesList(client)
1443
- );
1444
- }
1445
- function usePaymentsPaymentsList(params, client) {
1446
- return useSWR__default.default(
1447
- params ? ["cfg-payments-payments", params] : "cfg-payments-payments",
1448
- () => getPaymentsPaymentsList(params, client)
1449
- );
1450
- }
1451
- function usePaymentsPaymentsRetrieve(id, client) {
1452
- return useSWR__default.default(
1453
- ["cfg-payments-payment", id],
1454
- () => getPaymentsPaymentsRetrieve(id, client)
1455
- );
1456
- }
1457
- function useCreatePaymentsPaymentsConfirmCreate() {
1458
- const { mutate } = useSWR.useSWRConfig();
1459
- return async (id, client) => {
1460
- const result = await createPaymentsPaymentsConfirmCreate(id, client);
1461
- mutate("cfg-payments-payments-confirm");
1462
- return result;
1463
- };
1464
- }
1465
- function useCreatePaymentsPaymentsCreateCreate() {
1466
- const { mutate } = useSWR.useSWRConfig();
1467
- return async (client) => {
1468
- const result = await createPaymentsPaymentsCreateCreate(client);
1469
- mutate("cfg-payments-payments");
1470
- return result;
1471
- };
1472
- }
1473
- function usePaymentsTransactionsList(params, client) {
1474
- return useSWR__default.default(
1475
- params ? ["cfg-payments-transactions", params] : "cfg-payments-transactions",
1476
- () => getPaymentsTransactionsList(params, client)
1477
- );
1478
- }
1479
- var PaymentsContext = react.createContext(void 0);
1480
- function PaymentsProvider({ children }) {
1481
- const {
1482
- data: payments,
1483
- error: paymentsError,
1484
- isLoading: isLoadingPayments,
1485
- mutate: mutatePayments
1486
- } = usePaymentsPaymentsList({ page: 1, page_size: 1 }, apiPayments);
1487
- const refreshPayments = async () => {
1488
- await mutatePayments();
1489
- };
1490
- const createPaymentMutation = useCreatePaymentsPaymentsCreateCreate();
1491
- const confirmPaymentMutation = useCreatePaymentsPaymentsConfirmCreate();
1492
- const getPayment = async (id) => {
1493
- return getPaymentsPaymentsRetrieve(id, apiPayments);
1494
- };
1495
- const createPayment = async () => {
1496
- const result = await createPaymentMutation(apiPayments);
1497
- await refreshPayments();
1498
- return result;
1499
- };
1500
- const confirmPayment = async (id) => {
1501
- const result = await confirmPaymentMutation(id, apiPayments);
1502
- await refreshPayments();
1503
- return result;
1504
- };
1505
- const checkPaymentStatus = async (id) => {
1506
- return getPaymentsPaymentsStatusRetrieve(id, apiPayments);
1507
- };
1508
- const value = {
1509
- payments,
1510
- isLoadingPayments,
1511
- paymentsError,
1512
- refreshPayments,
1513
- getPayment,
1514
- createPayment,
1515
- confirmPayment,
1516
- checkPaymentStatus
1517
- };
1518
- return /* @__PURE__ */ jsxRuntime.jsx(PaymentsContext.Provider, { value, children });
1519
- }
1520
- function usePaymentsContext() {
1521
- const context = react.useContext(PaymentsContext);
1522
- if (!context) {
1523
- throw new Error("usePaymentsContext must be used within PaymentsProvider");
1524
- }
1525
- return context;
1526
- }
1527
- react.createContext(void 0);
1528
- react.createContext(void 0);
1529
- var OverviewContext = react.createContext(void 0);
1530
- function OverviewProvider({ children }) {
1531
- const swrConfig = {
1532
- revalidateOnFocus: false,
1533
- revalidateOnReconnect: false,
1534
- revalidateIfStale: false
1535
- };
1536
- const {
1537
- data: balance,
1538
- error: balanceError,
1539
- isLoading: isLoadingBalance,
1540
- mutate: mutateBalance
1541
- } = usePaymentsBalanceRetrieve(apiPayments);
1542
- const {
1543
- data: payments,
1544
- error: paymentsError,
1545
- isLoading: isLoadingPayments,
1546
- mutate: mutatePayments
1547
- } = usePaymentsPaymentsList({}, apiPayments);
1548
- const {
1549
- data: transactions,
1550
- error: transactionsError,
1551
- isLoading: isLoadingTransactions,
1552
- mutate: mutateTransactions
1553
- } = usePaymentsTransactionsList({}, apiPayments);
1554
- const createPaymentMutation = useCreatePaymentsPaymentsCreateCreate();
1555
- const isLoadingOverview = isLoadingBalance || isLoadingPayments || isLoadingTransactions;
1556
- const overviewError = balanceError || paymentsError || transactionsError;
1557
- const refreshBalance = async () => {
1558
- await mutateBalance();
1559
- };
1560
- const refreshPayments = async () => {
1561
- await mutatePayments();
1562
- };
1563
- const refreshTransactions = async () => {
1564
- await mutateTransactions();
1565
- };
1566
- const refreshOverview = async () => {
1567
- await Promise.all([
1568
- mutateBalance(),
1569
- mutatePayments(),
1570
- mutateTransactions()
1571
- ]);
1572
- };
1573
- const createPayment = async () => {
1574
- const result = await createPaymentMutation(apiPayments);
1575
- await refreshOverview();
1576
- return result;
1577
- };
1578
- const value = {
1579
- balance,
1580
- isLoadingBalance,
1581
- balanceError,
1582
- refreshBalance,
1583
- payments,
1584
- isLoadingPayments,
1585
- paymentsError,
1586
- refreshPayments,
1587
- transactions,
1588
- isLoadingTransactions,
1589
- transactionsError,
1590
- refreshTransactions,
1591
- createPayment,
1592
- isLoadingOverview,
1593
- overviewError,
1594
- refreshOverview
1595
- };
1596
- return /* @__PURE__ */ jsxRuntime.jsx(useSWR.SWRConfig, { value: swrConfig, children: /* @__PURE__ */ jsxRuntime.jsx(OverviewContext.Provider, { value, children }) });
1597
- }
1598
- function useOverviewContext() {
1599
- const context = react.useContext(OverviewContext);
1600
- if (!context) {
1601
- throw new Error("useOverviewContext must be used within OverviewProvider");
1602
- }
1603
- return context;
1604
- }
1605
- var RootPaymentsContext = react.createContext(void 0);
1606
- function RootPaymentsProvider({ children }) {
1607
- const {
1608
- data: currencies,
1609
- error: currenciesError,
1610
- isLoading: isLoadingCurrencies,
1611
- mutate: mutateCurrencies
1612
- } = usePaymentsCurrenciesList(apiPayments);
1613
- const refreshCurrencies = async () => {
1614
- await mutateCurrencies();
1615
- };
1616
- const value = {
1617
- currencies,
1618
- isLoadingCurrencies,
1619
- currenciesError,
1620
- refreshCurrencies
1621
- };
1622
- return /* @__PURE__ */ jsxRuntime.jsx(RootPaymentsContext.Provider, { value, children });
1623
- }
1624
- function useRootPaymentsContext() {
1625
- const context = react.useContext(RootPaymentsContext);
1754
+ var WalletContext = React2.createContext(void 0);
1755
+ function useWallet() {
1756
+ const context = React2.useContext(WalletContext);
1626
1757
  if (!context) {
1627
- throw new Error("useRootPaymentsContext must be used within RootPaymentsProvider");
1758
+ throw new Error("useWallet must be used within WalletProvider");
1628
1759
  }
1629
1760
  return context;
1630
1761
  }
1631
- var isDevelopment = process.env.NODE_ENV === "development";
1632
- var logger = consola.createConsola({
1633
- level: isDevelopment ? 4 : 1
1634
- }).withTag("ext-payments");
1635
- var paymentsLogger = logger;
1636
-
1637
- // src/layouts/PaymentsLayout/events.ts
1638
- var PAYMENT_EVENTS = {
1639
- OPEN_CREATE_PAYMENT_DIALOG: "payments:open-create-payment",
1640
- OPEN_PAYMENT_DETAILS_DIALOG: "payments:open-payment-details",
1641
- CLOSE_DIALOG: "payments:close-dialog"
1642
- };
1643
- var openCreatePaymentDialog = () => {
1644
- window.dispatchEvent(new Event(PAYMENT_EVENTS.OPEN_CREATE_PAYMENT_DIALOG));
1645
- };
1646
- var openPaymentDetailsDialog = (id) => {
1647
- window.dispatchEvent(
1648
- new CustomEvent(PAYMENT_EVENTS.OPEN_PAYMENT_DETAILS_DIALOG, {
1649
- detail: { id }
1650
- })
1651
- );
1652
- };
1653
- var closePaymentsDialog = () => {
1654
- window.dispatchEvent(new Event(PAYMENT_EVENTS.CLOSE_DIALOG));
1655
- };
1656
- var PaymentCreateSchema = zod.z.object({
1657
- amount_usd: zod.z.number().min(0.01, "Amount must be at least $0.01"),
1658
- currency_code: zod.z.string().min(1, "Please select a currency")
1659
- });
1660
- var CreatePaymentDialog = () => {
1661
- const [open, setOpen] = react.useState(false);
1662
- const [isSubmitting, setIsSubmitting] = react.useState(false);
1663
- const { createPayment } = usePaymentsContext();
1664
- const { currencies, isLoadingCurrencies } = useRootPaymentsContext();
1665
- const form = reactHookForm.useForm({
1666
- resolver: zod$1.zodResolver(PaymentCreateSchema),
1762
+ function BalanceHero({ onAddFunds, onWithdraw, className }) {
1763
+ const { balance, balanceAmount, isLoadingBalance, refreshWallet } = useWallet();
1764
+ const formattedBalance = new Intl.NumberFormat("en-US", {
1765
+ style: "currency",
1766
+ currency: "USD",
1767
+ minimumFractionDigits: 2,
1768
+ maximumFractionDigits: 2
1769
+ }).format(balanceAmount);
1770
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: lib.cn("flex flex-col items-center py-16 px-4", className), children: [
1771
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-center mb-6", children: isLoadingBalance ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1772
+ /* @__PURE__ */ jsxRuntime.jsx(uiCore.Skeleton, { className: "h-12 w-48 mx-auto mb-2" }),
1773
+ /* @__PURE__ */ jsxRuntime.jsx(uiCore.Skeleton, { className: "h-4 w-24 mx-auto" })
1774
+ ] }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1775
+ /* @__PURE__ */ jsxRuntime.jsx("h1", { className: "text-5xl font-bold tracking-tight tabular-nums", children: formattedBalance }),
1776
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-muted-foreground mt-1", children: "Available Balance" })
1777
+ ] }) }),
1778
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3", children: [
1779
+ /* @__PURE__ */ jsxRuntime.jsxs(
1780
+ uiCore.Button,
1781
+ {
1782
+ size: "lg",
1783
+ onClick: onAddFunds,
1784
+ className: "rounded-full px-6",
1785
+ children: [
1786
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Plus, { className: "h-5 w-5 mr-2" }),
1787
+ "Add Funds"
1788
+ ]
1789
+ }
1790
+ ),
1791
+ /* @__PURE__ */ jsxRuntime.jsxs(
1792
+ uiCore.Button,
1793
+ {
1794
+ size: "lg",
1795
+ variant: "outline",
1796
+ onClick: onWithdraw,
1797
+ className: "rounded-full px-6",
1798
+ children: [
1799
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ArrowUpRight, { className: "h-5 w-5 mr-2" }),
1800
+ "Withdraw"
1801
+ ]
1802
+ }
1803
+ ),
1804
+ /* @__PURE__ */ jsxRuntime.jsx(
1805
+ uiCore.Button,
1806
+ {
1807
+ size: "icon",
1808
+ variant: "ghost",
1809
+ onClick: () => refreshWallet(),
1810
+ className: "rounded-full",
1811
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.RefreshCw, { className: "h-4 w-4" })
1812
+ }
1813
+ )
1814
+ ] }),
1815
+ balance && !isLoadingBalance && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-6 mt-6 text-sm text-muted-foreground", children: [
1816
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-center", children: [
1817
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "block font-medium text-foreground", children: [
1818
+ "$",
1819
+ parseFloat(balance.total_deposited || "0").toFixed(2)
1820
+ ] }),
1821
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Total Deposited" })
1822
+ ] }),
1823
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-8 w-px bg-border" }),
1824
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-center", children: [
1825
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "block font-medium text-foreground", children: [
1826
+ "$",
1827
+ parseFloat(balance.total_withdrawn || "0").toFixed(2)
1828
+ ] }),
1829
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Total Withdrawn" })
1830
+ ] })
1831
+ ] })
1832
+ ] });
1833
+ }
1834
+ var statusConfig = {
1835
+ pending: {
1836
+ icon: lucideReact.Clock,
1837
+ color: "text-yellow-500",
1838
+ bg: "bg-yellow-500/10"
1839
+ },
1840
+ confirming: {
1841
+ icon: lucideReact.Loader2,
1842
+ color: "text-blue-500",
1843
+ bg: "bg-blue-500/10",
1844
+ animate: true
1845
+ },
1846
+ completed: {
1847
+ icon: lucideReact.CheckCircle2,
1848
+ color: "text-green-500",
1849
+ bg: "bg-green-500/10"
1850
+ },
1851
+ failed: {
1852
+ icon: lucideReact.XCircle,
1853
+ color: "text-red-500",
1854
+ bg: "bg-red-500/10"
1855
+ },
1856
+ expired: {
1857
+ icon: lucideReact.AlertCircle,
1858
+ color: "text-muted-foreground",
1859
+ bg: "bg-muted"
1860
+ }
1861
+ };
1862
+ function ActivityItem({ item, onClick }) {
1863
+ const config = statusConfig[item.status];
1864
+ const StatusIcon = config.icon;
1865
+ const isPositive = item.type === "payment" || item.type === "deposit";
1866
+ const DirectionIcon = isPositive ? lucideReact.ArrowDownLeft : lucideReact.ArrowUpRight;
1867
+ const relativeTime = moment2__default.default(item.createdAt).fromNow();
1868
+ return /* @__PURE__ */ jsxRuntime.jsxs(
1869
+ "button",
1870
+ {
1871
+ onClick,
1872
+ className: lib.cn(
1873
+ "w-full flex items-center gap-4 p-4 rounded-xl",
1874
+ "cursor-pointer",
1875
+ "hover:bg-accent active:bg-accent/80 transition-colors",
1876
+ "text-left"
1877
+ ),
1878
+ children: [
1879
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: lib.cn(
1880
+ "flex items-center justify-center w-10 h-10 rounded-full",
1881
+ isPositive ? "bg-green-500/10" : "bg-red-500/10"
1882
+ ), children: item.currency ? /* @__PURE__ */ jsxRuntime.jsx(uiCore.TokenIcon, { symbol: item.currency, size: 24 }) : /* @__PURE__ */ jsxRuntime.jsx(DirectionIcon, { className: lib.cn(
1883
+ "h-5 w-5",
1884
+ isPositive ? "text-green-500" : "text-red-500"
1885
+ ) }) }),
1886
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-1 min-w-0", children: [
1887
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-medium truncate", children: item.description }) }),
1888
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2 text-sm text-muted-foreground", children: [
1889
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: relativeTime }),
1890
+ item.status !== "completed" && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1891
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: "\xB7" }),
1892
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: lib.cn("flex items-center gap-1", config.color), children: [
1893
+ /* @__PURE__ */ jsxRuntime.jsx(StatusIcon, { className: lib.cn("h-3 w-3", config.animate && "animate-spin") }),
1894
+ item.statusDisplay
1895
+ ] })
1896
+ ] })
1897
+ ] })
1898
+ ] }),
1899
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-right", children: [
1900
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: lib.cn(
1901
+ "font-semibold tabular-nums",
1902
+ isPositive ? "text-green-600 dark:text-green-400" : "text-foreground"
1903
+ ), children: item.amountDisplay }),
1904
+ item.status === "completed" && /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CheckCircle2, { className: "h-4 w-4 text-green-500 ml-2 inline-block" })
1905
+ ] })
1906
+ ]
1907
+ }
1908
+ );
1909
+ }
1910
+ function ActivityList({
1911
+ onItemClick,
1912
+ onViewAll,
1913
+ limit = 10,
1914
+ className
1915
+ }) {
1916
+ const { activity, isLoadingActivity, hasMoreActivity } = useWallet();
1917
+ const displayedActivity = limit ? activity.slice(0, limit) : activity;
1918
+ if (isLoadingActivity) {
1919
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: lib.cn("space-y-2", className), children: [
1920
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-between px-4 py-2", children: /* @__PURE__ */ jsxRuntime.jsx(uiCore.Skeleton, { className: "h-5 w-32" }) }),
1921
+ [1, 2, 3, 4, 5].map((i) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-4 p-4", children: [
1922
+ /* @__PURE__ */ jsxRuntime.jsx(uiCore.Skeleton, { className: "h-10 w-10 rounded-full" }),
1923
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-1 space-y-2", children: [
1924
+ /* @__PURE__ */ jsxRuntime.jsx(uiCore.Skeleton, { className: "h-4 w-32" }),
1925
+ /* @__PURE__ */ jsxRuntime.jsx(uiCore.Skeleton, { className: "h-3 w-24" })
1926
+ ] }),
1927
+ /* @__PURE__ */ jsxRuntime.jsx(uiCore.Skeleton, { className: "h-5 w-16" })
1928
+ ] }, i))
1929
+ ] });
1930
+ }
1931
+ if (activity.length === 0) {
1932
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: lib.cn("text-center py-12", className), children: [
1933
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "inline-flex items-center justify-center w-16 h-16 rounded-full bg-muted mb-4", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.History, { className: "h-8 w-8 text-muted-foreground" }) }),
1934
+ /* @__PURE__ */ jsxRuntime.jsx("h3", { className: "font-semibold mb-1", children: "No Activity Yet" }),
1935
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground", children: "Your transactions will appear here" })
1936
+ ] });
1937
+ }
1938
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: lib.cn("pt-6", className), children: [
1939
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between px-4 py-2", children: [
1940
+ /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "font-semibold text-lg", children: "Recent Activity" }),
1941
+ hasMoreActivity && onViewAll && /* @__PURE__ */ jsxRuntime.jsxs(uiCore.Button, { variant: "ghost", size: "sm", onClick: onViewAll, className: "text-primary", children: [
1942
+ "View All",
1943
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronRight, { className: "h-4 w-4 ml-1" })
1944
+ ] })
1945
+ ] }),
1946
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "divide-y divide-border/50", children: displayedActivity.map((item) => /* @__PURE__ */ jsxRuntime.jsx(
1947
+ ActivityItem,
1948
+ {
1949
+ item,
1950
+ onClick: () => onItemClick?.(item)
1951
+ },
1952
+ item.id
1953
+ )) })
1954
+ ] });
1955
+ }
1956
+ var AddFundsSchema = zod.z.object({
1957
+ amount: zod.z.number().min(1, "Minimum $1.00"),
1958
+ currency: zod.z.string().min(1, "Select a currency")
1959
+ });
1960
+ function AddFundsSheet({ open, onOpenChange, onSuccess }) {
1961
+ const { currencies, isLoadingCurrencies, addFunds } = useWallet();
1962
+ const [isSubmitting, setIsSubmitting] = React2.useState(false);
1963
+ const [error, setError] = React2.useState(null);
1964
+ const form = reactHookForm.useForm({
1965
+ resolver: zod$1.zodResolver(AddFundsSchema),
1667
1966
  defaultValues: {
1668
- amount_usd: 10,
1669
- currency_code: "USDT"
1967
+ amount: 100,
1968
+ currency: ""
1670
1969
  }
1671
1970
  });
1672
- const currenciesList = react.useMemo(() => {
1673
- const data = currencies?.currencies || currencies?.results || currencies || [];
1674
- return Array.isArray(data) ? data : [];
1675
- }, [currencies]);
1676
- const currencyOptions = react.useMemo(() => {
1677
- return currenciesList.filter((curr) => curr.is_enabled !== false).map((curr) => ({
1678
- code: curr.code || curr.currency_code || curr.symbol,
1679
- name: curr.name || curr.code || curr.currency_code,
1680
- usd_rate: curr.usd_rate || curr.rate || 1,
1681
- network: curr.network || null
1971
+ const currencyOptions = React2.useMemo(() => {
1972
+ return currencies.map((c) => ({
1973
+ value: c.code,
1974
+ label: c.network ? `${c.code} (${c.network})` : c.code,
1975
+ rate: c.rate,
1976
+ network: c.network
1682
1977
  }));
1683
- }, [currenciesList]);
1684
- const calculateCryptoAmount = react.useMemo(() => {
1685
- const amountUsd = form.watch("amount_usd");
1686
- const currencyCode = form.watch("currency_code");
1687
- const currency = currencyOptions.find((c) => c.code === currencyCode);
1688
- if (!currency || !currency.usd_rate || !amountUsd) {
1689
- return null;
1690
- }
1691
- const cryptoAmount = amountUsd / currency.usd_rate;
1692
- return {
1693
- amount: cryptoAmount,
1694
- currency: currency.code,
1695
- rate: currency.usd_rate,
1696
- network: currency.network
1697
- };
1698
- }, [form.watch("amount_usd"), form.watch("currency_code"), currencyOptions]);
1699
- react.useEffect(() => {
1700
- const handleOpen = () => setOpen(true);
1701
- const handleClose2 = () => setOpen(false);
1702
- window.addEventListener(PAYMENT_EVENTS.OPEN_CREATE_PAYMENT_DIALOG, handleOpen);
1703
- window.addEventListener(PAYMENT_EVENTS.CLOSE_DIALOG, handleClose2);
1704
- return () => {
1705
- window.removeEventListener(PAYMENT_EVENTS.OPEN_CREATE_PAYMENT_DIALOG, handleOpen);
1706
- window.removeEventListener(PAYMENT_EVENTS.CLOSE_DIALOG, handleClose2);
1707
- };
1708
- }, []);
1709
- const handleClose = () => {
1710
- setOpen(false);
1711
- form.reset();
1712
- };
1713
- react.useEffect(() => {
1714
- if (currencyOptions.length > 0 && !form.getValues("currency_code")) {
1715
- form.setValue("currency_code", currencyOptions[0].code);
1978
+ }, [currencies]);
1979
+ React2.useMemo(() => {
1980
+ if (currencyOptions.length > 0 && !form.getValues("currency")) {
1981
+ const usdt = currencyOptions.find((c) => c.value.includes("USDT"));
1982
+ form.setValue("currency", usdt?.value || currencyOptions[0].value);
1716
1983
  }
1717
1984
  }, [currencyOptions, form]);
1718
- const handleSubmit = async (data) => {
1985
+ const selectedCurrency = currencyOptions.find((c) => c.value === form.watch("currency"));
1986
+ const cryptoAmount = React2.useMemo(() => {
1987
+ const amount = form.watch("amount");
1988
+ if (!selectedCurrency?.rate || !amount) return null;
1989
+ return amount / selectedCurrency.rate;
1990
+ }, [form.watch("amount"), selectedCurrency]);
1991
+ const handleSubmit = React2.useCallback(async (data) => {
1719
1992
  try {
1720
1993
  setIsSubmitting(true);
1721
- const result = await createPayment();
1722
- handleClose();
1723
- closePaymentsDialog();
1724
- const paymentData = result;
1725
- const paymentId = paymentData?.payment?.id || paymentData?.id;
1726
- if (paymentId) {
1727
- openPaymentDetailsDialog(String(paymentId));
1728
- }
1729
- } catch (error) {
1730
- paymentsLogger.error("Failed to create payment:", error);
1994
+ setError(null);
1995
+ const result = await addFunds({
1996
+ amount_usd: String(data.amount),
1997
+ currency_code: data.currency
1998
+ });
1999
+ form.reset();
2000
+ onOpenChange(false);
2001
+ onSuccess?.(result);
2002
+ } catch (err) {
2003
+ const message = err?.response?.data?.message || err?.response?.data?.detail || err?.message || "Failed to create payment";
2004
+ setError(message);
1731
2005
  } finally {
1732
2006
  setIsSubmitting(false);
1733
2007
  }
1734
- };
1735
- return /* @__PURE__ */ jsxRuntime.jsx(uiCore.Dialog, { open, onOpenChange: (isOpen) => !isOpen && handleClose(), children: /* @__PURE__ */ jsxRuntime.jsxs(uiCore.DialogContent, { className: "sm:max-w-md", children: [
1736
- /* @__PURE__ */ jsxRuntime.jsxs(uiCore.DialogHeader, { children: [
1737
- /* @__PURE__ */ jsxRuntime.jsx(uiCore.DialogTitle, { children: "Create Payment" }),
1738
- /* @__PURE__ */ jsxRuntime.jsx(uiCore.DialogDescription, { children: "Create a new payment to add funds to your account." })
2008
+ }, [addFunds, form, onOpenChange, onSuccess]);
2009
+ const handleOpenChange = React2.useCallback((open2) => {
2010
+ if (!open2) {
2011
+ setError(null);
2012
+ form.reset();
2013
+ }
2014
+ onOpenChange(open2);
2015
+ }, [form, onOpenChange]);
2016
+ return /* @__PURE__ */ jsxRuntime.jsx(uiCore.ResponsiveSheet, { open, onOpenChange: handleOpenChange, children: /* @__PURE__ */ jsxRuntime.jsxs(uiCore.ResponsiveSheetContent, { className: "sm:max-w-md", children: [
2017
+ /* @__PURE__ */ jsxRuntime.jsxs(uiCore.ResponsiveSheetHeader, { children: [
2018
+ /* @__PURE__ */ jsxRuntime.jsx(uiCore.ResponsiveSheetTitle, { children: "Add Funds" }),
2019
+ /* @__PURE__ */ jsxRuntime.jsx(uiCore.ResponsiveSheetDescription, { children: "Add funds to your wallet using cryptocurrency" })
1739
2020
  ] }),
1740
- /* @__PURE__ */ jsxRuntime.jsx(uiCore.Form, { ...form, children: /* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit: form.handleSubmit(handleSubmit), className: "space-y-4", children: [
2021
+ /* @__PURE__ */ jsxRuntime.jsx(uiCore.Form, { ...form, children: /* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit: form.handleSubmit(handleSubmit), className: "space-y-6 p-4 sm:p-0 sm:mt-4", children: [
1741
2022
  /* @__PURE__ */ jsxRuntime.jsx(
1742
2023
  uiCore.FormField,
1743
2024
  {
1744
2025
  control: form.control,
1745
- name: "amount_usd",
2026
+ name: "amount",
1746
2027
  render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(uiCore.FormItem, { children: [
1747
2028
  /* @__PURE__ */ jsxRuntime.jsx(uiCore.FormLabel, { children: "Amount (USD)" }),
1748
- /* @__PURE__ */ jsxRuntime.jsx(uiCore.FormControl, { children: /* @__PURE__ */ jsxRuntime.jsx(
1749
- uiCore.Input,
1750
- {
1751
- type: "number",
1752
- step: "0.01",
1753
- min: "0.01",
1754
- placeholder: "10.00",
1755
- ...field,
1756
- onChange: (e) => field.onChange(parseFloat(e.target.value) || 0)
1757
- }
1758
- ) }),
1759
- /* @__PURE__ */ jsxRuntime.jsx(uiCore.FormDescription, { children: "The amount you want to pay in USD." }),
2029
+ /* @__PURE__ */ jsxRuntime.jsx(uiCore.FormControl, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative", children: [
2030
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "absolute left-4 top-1/2 -translate-y-1/2 text-muted-foreground text-lg", children: "$" }),
2031
+ /* @__PURE__ */ jsxRuntime.jsx(
2032
+ uiCore.Input,
2033
+ {
2034
+ type: "number",
2035
+ step: "0.01",
2036
+ min: "1",
2037
+ placeholder: "100.00",
2038
+ className: "pl-8 text-2xl h-14 font-semibold",
2039
+ ...field,
2040
+ onChange: (e) => field.onChange(parseFloat(e.target.value) || 0)
2041
+ }
2042
+ )
2043
+ ] }) }),
1760
2044
  /* @__PURE__ */ jsxRuntime.jsx(uiCore.FormMessage, {})
1761
2045
  ] })
1762
2046
  }
@@ -1765,122 +2049,344 @@ var CreatePaymentDialog = () => {
1765
2049
  uiCore.FormField,
1766
2050
  {
1767
2051
  control: form.control,
1768
- name: "currency_code",
2052
+ name: "currency",
1769
2053
  render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(uiCore.FormItem, { children: [
1770
- /* @__PURE__ */ jsxRuntime.jsx(uiCore.FormLabel, { children: "Currency" }),
1771
- /* @__PURE__ */ jsxRuntime.jsxs(
1772
- uiCore.Select,
2054
+ /* @__PURE__ */ jsxRuntime.jsx(uiCore.FormLabel, { children: "Pay with" }),
2055
+ /* @__PURE__ */ jsxRuntime.jsx(uiCore.FormControl, { children: /* @__PURE__ */ jsxRuntime.jsx(
2056
+ uiCore.Combobox,
1773
2057
  {
2058
+ options: currencyOptions,
2059
+ value: field.value,
1774
2060
  onValueChange: field.onChange,
1775
- defaultValue: field.value,
2061
+ placeholder: "Select currency...",
2062
+ searchPlaceholder: "Search...",
1776
2063
  disabled: isLoadingCurrencies,
1777
- children: [
1778
- /* @__PURE__ */ jsxRuntime.jsx(uiCore.FormControl, { children: /* @__PURE__ */ jsxRuntime.jsx(uiCore.SelectTrigger, { children: /* @__PURE__ */ jsxRuntime.jsx(uiCore.SelectValue, { placeholder: "Select currency..." }) }) }),
1779
- /* @__PURE__ */ jsxRuntime.jsx(uiCore.SelectContent, { children: currencyOptions.map((curr) => /* @__PURE__ */ jsxRuntime.jsx(uiCore.SelectItem, { value: curr.code, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
1780
- /* @__PURE__ */ jsxRuntime.jsx(uiCore.TokenIcon, { symbol: curr.code, size: 16 }),
1781
- /* @__PURE__ */ jsxRuntime.jsx("span", { children: curr.code }),
1782
- curr.network && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-xs text-muted-foreground", children: [
1783
- "(",
1784
- curr.network,
1785
- ")"
1786
- ] })
1787
- ] }) }, curr.code)) })
1788
- ]
2064
+ className: "h-14",
2065
+ renderOption: (option) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3 flex-1", children: [
2066
+ /* @__PURE__ */ jsxRuntime.jsx(uiCore.TokenIcon, { symbol: option.value, size: 24 }),
2067
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-medium", children: option.label })
2068
+ ] }),
2069
+ renderValue: (option) => option && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3", children: [
2070
+ /* @__PURE__ */ jsxRuntime.jsx(uiCore.TokenIcon, { symbol: option.value, size: 24 }),
2071
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-medium", children: option.label })
2072
+ ] })
1789
2073
  }
1790
- ),
1791
- /* @__PURE__ */ jsxRuntime.jsx(uiCore.FormDescription, { children: "The cryptocurrency to use for payment." }),
2074
+ ) }),
1792
2075
  /* @__PURE__ */ jsxRuntime.jsx(uiCore.FormMessage, {})
1793
2076
  ] })
1794
2077
  }
1795
2078
  ),
1796
- calculateCryptoAmount && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-sm bg-muted p-4 space-y-3", children: [
2079
+ cryptoAmount !== null && selectedCurrency && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-muted rounded-xl p-4 space-y-2", children: [
1797
2080
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [
1798
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-muted-foreground", children: "You will send" }),
2081
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground", children: "You will send" }),
1799
2082
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
1800
- /* @__PURE__ */ jsxRuntime.jsx(uiCore.TokenIcon, { symbol: calculateCryptoAmount.currency, size: 16 }),
2083
+ /* @__PURE__ */ jsxRuntime.jsx(uiCore.TokenIcon, { symbol: selectedCurrency.value, size: 20 }),
1801
2084
  /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "font-mono font-semibold", children: [
1802
- calculateCryptoAmount.amount.toFixed(8),
2085
+ cryptoAmount.toFixed(8),
1803
2086
  " ",
1804
- calculateCryptoAmount.currency
2087
+ selectedCurrency.value
1805
2088
  ] })
1806
2089
  ] })
1807
2090
  ] }),
1808
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [
1809
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-muted-foreground", children: "You will receive" }),
1810
- /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-lg font-bold", children: [
2091
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between text-sm text-muted-foreground", children: [
2092
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Rate" }),
2093
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
2094
+ "1 ",
2095
+ selectedCurrency.value,
2096
+ " = $",
2097
+ selectedCurrency.rate.toFixed(2)
2098
+ ] })
2099
+ ] })
2100
+ ] }),
2101
+ error && /* @__PURE__ */ jsxRuntime.jsx(uiCore.Alert, { variant: "destructive", children: /* @__PURE__ */ jsxRuntime.jsx(uiCore.AlertDescription, { children: error }) }),
2102
+ /* @__PURE__ */ jsxRuntime.jsx(
2103
+ uiCore.Button,
2104
+ {
2105
+ type: "submit",
2106
+ size: "lg",
2107
+ className: "w-full h-14 text-lg rounded-xl",
2108
+ disabled: isSubmitting || currencyOptions.length === 0,
2109
+ children: isSubmitting ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2110
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.RefreshCw, { className: "h-5 w-5 mr-2 animate-spin" }),
2111
+ "Creating..."
2112
+ ] }) : "Continue"
2113
+ }
2114
+ )
2115
+ ] }) })
2116
+ ] }) });
2117
+ }
2118
+ var WithdrawSchema = zod.z.object({
2119
+ amount: zod.z.number().min(10, "Minimum $10.00"),
2120
+ currency: zod.z.string().min(1, "Select a currency"),
2121
+ wallet_address: zod.z.string().min(26, "Invalid wallet address")
2122
+ });
2123
+ var SERVICE_FEE_PERCENT = 0.01;
2124
+ var NETWORK_FEE_USD = 1;
2125
+ function WithdrawSheet({ open, onOpenChange, onSuccess }) {
2126
+ const { currencies, isLoadingCurrencies, withdraw, balanceAmount } = useWallet();
2127
+ const [isSubmitting, setIsSubmitting] = React2.useState(false);
2128
+ const [error, setError] = React2.useState(null);
2129
+ const form = reactHookForm.useForm({
2130
+ resolver: zod$1.zodResolver(WithdrawSchema),
2131
+ defaultValues: {
2132
+ amount: 10,
2133
+ currency: "",
2134
+ wallet_address: ""
2135
+ }
2136
+ });
2137
+ const currencyOptions = React2.useMemo(() => {
2138
+ return currencies.map((c) => ({
2139
+ value: c.code,
2140
+ label: c.network ? `${c.code} (${c.network})` : c.code,
2141
+ rate: c.rate,
2142
+ network: c.network
2143
+ }));
2144
+ }, [currencies]);
2145
+ React2.useMemo(() => {
2146
+ if (currencyOptions.length > 0 && !form.getValues("currency")) {
2147
+ const usdt = currencyOptions.find((c) => c.value.includes("USDT"));
2148
+ form.setValue("currency", usdt?.value || currencyOptions[0].value);
2149
+ }
2150
+ }, [currencyOptions, form]);
2151
+ const selectedCurrency = currencyOptions.find((c) => c.value === form.watch("currency"));
2152
+ const amount = form.watch("amount") || 0;
2153
+ const feeBreakdown = React2.useMemo(() => {
2154
+ const serviceFee = amount * SERVICE_FEE_PERCENT;
2155
+ const networkFee = NETWORK_FEE_USD;
2156
+ const totalFee = serviceFee + networkFee;
2157
+ const finalAmount = Math.max(0, amount - totalFee);
2158
+ const cryptoAmount = selectedCurrency?.rate ? finalAmount / selectedCurrency.rate : null;
2159
+ return {
2160
+ serviceFee,
2161
+ networkFee,
2162
+ totalFee,
2163
+ finalAmount,
2164
+ cryptoAmount
2165
+ };
2166
+ }, [amount, selectedCurrency]);
2167
+ const insufficientBalance = amount > balanceAmount;
2168
+ const handleSubmit = React2.useCallback(async (data) => {
2169
+ try {
2170
+ setIsSubmitting(true);
2171
+ setError(null);
2172
+ const result = await withdraw({
2173
+ amount_usd: String(data.amount),
2174
+ currency_code: data.currency,
2175
+ wallet_address: data.wallet_address
2176
+ });
2177
+ form.reset();
2178
+ onOpenChange(false);
2179
+ onSuccess?.(result);
2180
+ } catch (err) {
2181
+ const message = err?.response?.data?.error || err?.response?.data?.message || err?.response?.data?.detail || err?.message || "Failed to create withdrawal request";
2182
+ setError(message);
2183
+ } finally {
2184
+ setIsSubmitting(false);
2185
+ }
2186
+ }, [withdraw, form, onOpenChange, onSuccess]);
2187
+ const handleOpenChange = React2.useCallback((open2) => {
2188
+ if (!open2) {
2189
+ setError(null);
2190
+ form.reset();
2191
+ }
2192
+ onOpenChange(open2);
2193
+ }, [form, onOpenChange]);
2194
+ return /* @__PURE__ */ jsxRuntime.jsx(uiCore.ResponsiveSheet, { open, onOpenChange: handleOpenChange, children: /* @__PURE__ */ jsxRuntime.jsxs(uiCore.ResponsiveSheetContent, { className: "sm:max-w-md", children: [
2195
+ /* @__PURE__ */ jsxRuntime.jsxs(uiCore.ResponsiveSheetHeader, { children: [
2196
+ /* @__PURE__ */ jsxRuntime.jsx(uiCore.ResponsiveSheetTitle, { children: "Withdraw" }),
2197
+ /* @__PURE__ */ jsxRuntime.jsx(uiCore.ResponsiveSheetDescription, { children: "Withdraw funds to your cryptocurrency wallet" })
2198
+ ] }),
2199
+ /* @__PURE__ */ jsxRuntime.jsx(uiCore.Form, { ...form, children: /* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit: form.handleSubmit(handleSubmit), className: "space-y-6 p-4 sm:p-0 sm:mt-4", children: [
2200
+ /* @__PURE__ */ jsxRuntime.jsx(
2201
+ uiCore.FormField,
2202
+ {
2203
+ control: form.control,
2204
+ name: "amount",
2205
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(uiCore.FormItem, { children: [
2206
+ /* @__PURE__ */ jsxRuntime.jsx(uiCore.FormLabel, { children: "Amount (USD)" }),
2207
+ /* @__PURE__ */ jsxRuntime.jsx(uiCore.FormControl, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative", children: [
2208
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "absolute left-4 top-1/2 -translate-y-1/2 text-muted-foreground text-lg", children: "$" }),
2209
+ /* @__PURE__ */ jsxRuntime.jsx(
2210
+ uiCore.Input,
2211
+ {
2212
+ type: "number",
2213
+ step: "0.01",
2214
+ min: "10",
2215
+ placeholder: "10.00",
2216
+ className: "pl-8 text-2xl h-14 font-semibold",
2217
+ ...field,
2218
+ onChange: (e) => field.onChange(parseFloat(e.target.value) || 0)
2219
+ }
2220
+ )
2221
+ ] }) }),
2222
+ /* @__PURE__ */ jsxRuntime.jsx(uiCore.FormMessage, {}),
2223
+ insufficientBalance && /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-sm text-destructive mt-1", children: [
2224
+ "Insufficient balance (Available: $",
2225
+ balanceAmount.toFixed(2),
2226
+ ")"
2227
+ ] })
2228
+ ] })
2229
+ }
2230
+ ),
2231
+ /* @__PURE__ */ jsxRuntime.jsx(
2232
+ uiCore.FormField,
2233
+ {
2234
+ control: form.control,
2235
+ name: "currency",
2236
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(uiCore.FormItem, { children: [
2237
+ /* @__PURE__ */ jsxRuntime.jsx(uiCore.FormLabel, { children: "Withdraw as" }),
2238
+ /* @__PURE__ */ jsxRuntime.jsx(uiCore.FormControl, { children: /* @__PURE__ */ jsxRuntime.jsx(
2239
+ uiCore.Combobox,
2240
+ {
2241
+ options: currencyOptions,
2242
+ value: field.value,
2243
+ onValueChange: field.onChange,
2244
+ placeholder: "Select currency...",
2245
+ searchPlaceholder: "Search...",
2246
+ disabled: isLoadingCurrencies,
2247
+ className: "h-14",
2248
+ renderOption: (option) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3 flex-1", children: [
2249
+ /* @__PURE__ */ jsxRuntime.jsx(uiCore.TokenIcon, { symbol: option.value, size: 24 }),
2250
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-medium", children: option.label })
2251
+ ] }),
2252
+ renderValue: (option) => option && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3", children: [
2253
+ /* @__PURE__ */ jsxRuntime.jsx(uiCore.TokenIcon, { symbol: option.value, size: 24 }),
2254
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-medium", children: option.label })
2255
+ ] })
2256
+ }
2257
+ ) }),
2258
+ /* @__PURE__ */ jsxRuntime.jsx(uiCore.FormMessage, {})
2259
+ ] })
2260
+ }
2261
+ ),
2262
+ /* @__PURE__ */ jsxRuntime.jsx(
2263
+ uiCore.FormField,
2264
+ {
2265
+ control: form.control,
2266
+ name: "wallet_address",
2267
+ render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs(uiCore.FormItem, { children: [
2268
+ /* @__PURE__ */ jsxRuntime.jsx(uiCore.FormLabel, { children: "Wallet Address" }),
2269
+ /* @__PURE__ */ jsxRuntime.jsx(uiCore.FormControl, { children: /* @__PURE__ */ jsxRuntime.jsx(
2270
+ uiCore.Input,
2271
+ {
2272
+ placeholder: "Enter your wallet address",
2273
+ className: "font-mono text-sm",
2274
+ ...field
2275
+ }
2276
+ ) }),
2277
+ /* @__PURE__ */ jsxRuntime.jsx(uiCore.FormMessage, {})
2278
+ ] })
2279
+ }
2280
+ ),
2281
+ amount >= 10 && selectedCurrency && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-muted rounded-xl p-4 space-y-2", children: [
2282
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between text-sm", children: [
2283
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground", children: "Amount" }),
2284
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
1811
2285
  "$",
1812
- form.watch("amount_usd")?.toFixed(2),
1813
- " USD"
2286
+ amount.toFixed(2)
1814
2287
  ] })
1815
2288
  ] }),
1816
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between text-xs", children: [
1817
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground", children: "Rate" }),
1818
- /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "font-medium", children: [
1819
- "1 ",
1820
- calculateCryptoAmount.currency,
1821
- " = $",
1822
- calculateCryptoAmount.rate?.toFixed(2)
2289
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between text-sm", children: [
2290
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground", children: "Service fee (1%)" }),
2291
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-destructive", children: [
2292
+ "-$",
2293
+ feeBreakdown.serviceFee.toFixed(2)
1823
2294
  ] })
1824
2295
  ] }),
1825
- calculateCryptoAmount.network && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "border-t pt-3", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [
1826
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-muted-foreground", children: "Network" }),
1827
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm font-medium", children: calculateCryptoAmount.network })
2296
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between text-sm", children: [
2297
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground", children: "Network fee" }),
2298
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-destructive", children: [
2299
+ "-$",
2300
+ feeBreakdown.networkFee.toFixed(2)
2301
+ ] })
2302
+ ] }),
2303
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "border-t pt-2 mt-2", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [
2304
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-medium", children: "You will receive" }),
2305
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-right", children: [
2306
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "font-semibold", children: [
2307
+ "$",
2308
+ feeBreakdown.finalAmount.toFixed(2)
2309
+ ] }),
2310
+ feeBreakdown.cryptoAmount !== null && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1 text-sm text-muted-foreground", children: [
2311
+ /* @__PURE__ */ jsxRuntime.jsx(uiCore.TokenIcon, { symbol: selectedCurrency.value, size: 16 }),
2312
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-mono", children: feeBreakdown.cryptoAmount.toFixed(8) })
2313
+ ] })
2314
+ ] })
1828
2315
  ] }) })
1829
2316
  ] }),
1830
- /* @__PURE__ */ jsxRuntime.jsxs(uiCore.DialogFooter, { children: [
1831
- /* @__PURE__ */ jsxRuntime.jsx(uiCore.Button, { type: "button", variant: "outline", onClick: handleClose, disabled: isSubmitting, children: "Cancel" }),
1832
- /* @__PURE__ */ jsxRuntime.jsx(uiCore.Button, { type: "submit", disabled: isSubmitting || currencyOptions.length === 0, children: isSubmitting ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1833
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.RefreshCw, { className: "h-4 w-4 mr-2 animate-spin" }),
1834
- "Creating..."
1835
- ] }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
1836
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Plus, { className: "h-4 w-4 mr-2" }),
1837
- "Create Payment"
1838
- ] }) })
1839
- ] })
2317
+ /* @__PURE__ */ jsxRuntime.jsxs(uiCore.Alert, { children: [
2318
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.AlertCircle, { className: "h-4 w-4" }),
2319
+ /* @__PURE__ */ jsxRuntime.jsx(uiCore.AlertDescription, { children: "Withdrawal requests require admin approval. Processing may take 24-48 hours." })
2320
+ ] }),
2321
+ error && /* @__PURE__ */ jsxRuntime.jsx(uiCore.Alert, { variant: "destructive", children: /* @__PURE__ */ jsxRuntime.jsx(uiCore.AlertDescription, { children: error }) }),
2322
+ /* @__PURE__ */ jsxRuntime.jsx(
2323
+ uiCore.Button,
2324
+ {
2325
+ type: "submit",
2326
+ size: "lg",
2327
+ className: "w-full h-14 text-lg rounded-xl",
2328
+ disabled: isSubmitting || currencyOptions.length === 0 || insufficientBalance || feeBreakdown.finalAmount <= 0,
2329
+ children: isSubmitting ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2330
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.RefreshCw, { className: "h-5 w-5 mr-2 animate-spin" }),
2331
+ "Submitting..."
2332
+ ] }) : "Request Withdrawal"
2333
+ }
2334
+ )
1840
2335
  ] }) })
1841
2336
  ] }) });
2337
+ }
2338
+ var statusConfig2 = {
2339
+ pending: {
2340
+ icon: lucideReact.Clock,
2341
+ color: "text-yellow-500",
2342
+ bg: "bg-yellow-500/10",
2343
+ label: "Waiting for payment"
2344
+ },
2345
+ confirming: {
2346
+ icon: lucideReact.RefreshCw,
2347
+ color: "text-blue-500",
2348
+ bg: "bg-blue-500/10",
2349
+ label: "Confirming",
2350
+ animate: true
2351
+ },
2352
+ completed: {
2353
+ icon: lucideReact.CheckCircle2,
2354
+ color: "text-green-500",
2355
+ bg: "bg-green-500/10",
2356
+ label: "Completed"
2357
+ },
2358
+ failed: {
2359
+ icon: lucideReact.XCircle,
2360
+ color: "text-red-500",
2361
+ bg: "bg-red-500/10",
2362
+ label: "Failed"
2363
+ },
2364
+ expired: {
2365
+ icon: lucideReact.AlertCircle,
2366
+ color: "text-muted-foreground",
2367
+ bg: "bg-muted",
2368
+ label: "Expired"
2369
+ }
1842
2370
  };
1843
- var PaymentDetailsDialog = () => {
1844
- const [open, setOpen] = react.useState(false);
1845
- const [paymentId, setPaymentId] = react.useState(null);
1846
- const [timeLeft, setTimeLeft] = react.useState("");
1847
- const shouldFetch = open && !!paymentId;
1848
- const { data: payment, isLoading, error, mutate } = usePaymentsPaymentsRetrieve(
1849
- shouldFetch ? paymentId : "",
1850
- apiPayments
2371
+ function PaymentSheet({ paymentId, open, onOpenChange }) {
2372
+ const { getPaymentDetails } = useWallet();
2373
+ const [timeLeft, setTimeLeft] = React2.useState("");
2374
+ const { data: payment, isLoading, error, mutate } = useSWR2__default.default(
2375
+ open && paymentId ? ["payment-details", paymentId] : null,
2376
+ () => getPaymentDetails(paymentId),
2377
+ { refreshInterval: 1e4 }
1851
2378
  );
1852
- react.useEffect(() => {
1853
- const handleOpen = (event) => {
1854
- const customEvent = event;
1855
- setPaymentId(customEvent.detail.id);
1856
- setOpen(true);
1857
- };
1858
- const handleClose2 = () => {
1859
- setOpen(false);
1860
- setPaymentId(null);
1861
- };
1862
- window.addEventListener(PAYMENT_EVENTS.OPEN_PAYMENT_DETAILS_DIALOG, handleOpen);
1863
- window.addEventListener(PAYMENT_EVENTS.CLOSE_DIALOG, handleClose2);
1864
- return () => {
1865
- window.removeEventListener(PAYMENT_EVENTS.OPEN_PAYMENT_DETAILS_DIALOG, handleOpen);
1866
- window.removeEventListener(PAYMENT_EVENTS.CLOSE_DIALOG, handleClose2);
1867
- };
1868
- }, []);
1869
- const handleClose = () => {
1870
- setOpen(false);
1871
- setPaymentId(null);
1872
- };
1873
- react.useEffect(() => {
2379
+ React2.useEffect(() => {
1874
2380
  if (!payment?.expires_at) return;
1875
2381
  const updateTimeLeft = () => {
1876
- const now = moment__default.default();
1877
- const expires = moment__default.default.utc(payment.expires_at);
2382
+ const now = moment2__default.default();
2383
+ const expires = moment2__default.default.utc(payment.expires_at);
1878
2384
  const diff = expires.diff(now);
1879
2385
  if (diff <= 0) {
1880
2386
  setTimeLeft("Expired");
1881
2387
  return;
1882
2388
  }
1883
- const duration = moment__default.default.duration(diff);
2389
+ const duration = moment2__default.default.duration(diff);
1884
2390
  const hours = Math.floor(duration.asHours());
1885
2391
  const minutes = duration.minutes();
1886
2392
  const seconds = duration.seconds();
@@ -1890,713 +2396,172 @@ var PaymentDetailsDialog = () => {
1890
2396
  const interval = setInterval(updateTimeLeft, 1e3);
1891
2397
  return () => clearInterval(interval);
1892
2398
  }, [payment?.expires_at]);
1893
- const getStatusInfo = () => {
1894
- switch (payment?.status?.toLowerCase()) {
1895
- case "pending":
1896
- return { icon: lucideReact.Clock, color: "text-yellow-500", bg: "bg-yellow-500/10" };
1897
- case "completed":
1898
- case "success":
1899
- return { icon: lucideReact.CheckCircle2, color: "text-green-500", bg: "bg-green-500/10" };
1900
- case "failed":
1901
- case "error":
1902
- return { icon: lucideReact.XCircle, color: "text-red-500", bg: "bg-red-500/10" };
1903
- case "expired":
1904
- return { icon: lucideReact.AlertCircle, color: "text-gray-500", bg: "bg-gray-500/10" };
1905
- case "confirming":
1906
- return { icon: lucideReact.RefreshCw, color: "text-blue-500", bg: "bg-blue-500/10" };
1907
- default:
1908
- return { icon: lucideReact.Clock, color: "text-gray-500", bg: "bg-gray-500/10" };
1909
- }
1910
- };
1911
- if (!open) return null;
1912
- if (isLoading) {
1913
- return /* @__PURE__ */ jsxRuntime.jsx(uiCore.Dialog, { open, onOpenChange: (isOpen) => !isOpen && handleClose(), children: /* @__PURE__ */ jsxRuntime.jsxs(uiCore.DialogContent, { className: "sm:max-w-lg", children: [
1914
- /* @__PURE__ */ jsxRuntime.jsxs(uiCore.DialogHeader, { children: [
1915
- /* @__PURE__ */ jsxRuntime.jsx(uiCore.DialogTitle, { children: "Payment Details" }),
1916
- /* @__PURE__ */ jsxRuntime.jsx(uiCore.DialogDescription, { children: "Loading payment information..." })
1917
- ] }),
1918
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-center py-12", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.RefreshCw, { className: "h-8 w-8 animate-spin text-muted-foreground" }) })
1919
- ] }) });
1920
- }
1921
- if (shouldFetch && !isLoading && (error || !payment)) {
1922
- return /* @__PURE__ */ jsxRuntime.jsx(uiCore.Dialog, { open, onOpenChange: (isOpen) => !isOpen && handleClose(), children: /* @__PURE__ */ jsxRuntime.jsxs(uiCore.DialogContent, { className: "sm:max-w-lg", children: [
1923
- /* @__PURE__ */ jsxRuntime.jsxs(uiCore.DialogHeader, { children: [
1924
- /* @__PURE__ */ jsxRuntime.jsx(uiCore.DialogTitle, { children: "Payment Details" }),
1925
- /* @__PURE__ */ jsxRuntime.jsx(uiCore.DialogDescription, { children: "Failed to load payment information" })
2399
+ const status = React2.useMemo(() => {
2400
+ const s = payment?.status?.toLowerCase();
2401
+ if (s === "completed" || s === "success" || s === "finished") return "completed";
2402
+ if (s === "confirming" || s === "partially_paid") return "confirming";
2403
+ if (s === "expired") return "expired";
2404
+ if (s === "failed" || s === "error" || s === "cancelled") return "failed";
2405
+ return "pending";
2406
+ }, [payment?.status]);
2407
+ const config = statusConfig2[status];
2408
+ const StatusIcon = config.icon;
2409
+ const qrCodeUrl = payment?.pay_address ? `https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=${encodeURIComponent(payment.pay_address)}` : null;
2410
+ const isPending = status === "pending";
2411
+ return /* @__PURE__ */ jsxRuntime.jsx(uiCore.ResponsiveSheet, { open, onOpenChange, children: /* @__PURE__ */ jsxRuntime.jsxs(uiCore.ResponsiveSheetContent, { className: "sm:max-w-lg", children: [
2412
+ /* @__PURE__ */ jsxRuntime.jsxs(uiCore.ResponsiveSheetHeader, { children: [
2413
+ /* @__PURE__ */ jsxRuntime.jsx(uiCore.ResponsiveSheetTitle, { children: "Payment Details" }),
2414
+ /* @__PURE__ */ jsxRuntime.jsx(uiCore.ResponsiveSheetDescription, { children: isPending ? "Send cryptocurrency to complete payment" : "Payment information" })
2415
+ ] }),
2416
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "p-4 sm:p-0 sm:mt-4 overflow-y-auto max-h-[70vh]", children: [
2417
+ isLoading && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-6", children: [
2418
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(uiCore.Skeleton, { className: "h-48 w-48 rounded-xl" }) }),
2419
+ /* @__PURE__ */ jsxRuntime.jsx(uiCore.Skeleton, { className: "h-12 w-full" }),
2420
+ /* @__PURE__ */ jsxRuntime.jsx(uiCore.Skeleton, { className: "h-24 w-full" })
1926
2421
  ] }),
1927
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col items-center justify-center py-12 space-y-4", children: [
1928
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.XCircle, { className: "h-12 w-12 text-destructive" }),
1929
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground", children: error ? `Error: ${error}` : "Payment not found" }),
2422
+ error && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col items-center justify-center py-12", children: [
2423
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.XCircle, { className: "h-12 w-12 text-destructive mb-4" }),
2424
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-muted-foreground mb-4", children: "Failed to load payment" }),
1930
2425
  /* @__PURE__ */ jsxRuntime.jsx(uiCore.Button, { onClick: () => mutate(), children: "Try Again" })
1931
- ] })
1932
- ] }) });
1933
- }
1934
- const statusInfo = getStatusInfo();
1935
- const StatusIcon = statusInfo.icon;
1936
- const qrCodeUrl = payment.pay_address ? `https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=${encodeURIComponent(payment.pay_address)}` : null;
1937
- return /* @__PURE__ */ jsxRuntime.jsx(uiCore.Dialog, { open, onOpenChange: (isOpen) => !isOpen && handleClose(), children: /* @__PURE__ */ jsxRuntime.jsxs(uiCore.DialogContent, { className: "sm:max-w-lg", children: [
1938
- /* @__PURE__ */ jsxRuntime.jsxs(uiCore.DialogHeader, { children: [
1939
- /* @__PURE__ */ jsxRuntime.jsx(uiCore.DialogTitle, { children: "Payment Details" }),
1940
- /* @__PURE__ */ jsxRuntime.jsx(uiCore.DialogDescription, { children: "Send cryptocurrency to complete your payment" })
1941
- ] }),
1942
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-6", children: [
1943
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `flex items-center gap-3 p-4 rounded-sm ${statusInfo.bg}`, children: [
1944
- /* @__PURE__ */ jsxRuntime.jsx(StatusIcon, { className: `h-5 w-5 ${statusInfo.color}` }),
1945
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-1", children: [
1946
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "font-semibold capitalize", children: payment.status }),
1947
- payment.status === "pending" && timeLeft && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-sm text-muted-foreground", children: [
1948
- "Expires in ",
1949
- timeLeft
1950
- ] })
1951
- ] })
1952
2426
  ] }),
1953
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-3", children: [
1954
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between p-4 bg-muted rounded-sm", children: [
1955
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-muted-foreground", children: "Amount to send" }),
1956
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
1957
- /* @__PURE__ */ jsxRuntime.jsx(uiCore.TokenIcon, { symbol: String(payment.currency_code || "BTC"), size: 20 }),
1958
- /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "font-mono font-bold text-lg", children: [
1959
- payment.pay_amount || "0.00000000",
1960
- " ",
1961
- payment.currency_code
2427
+ payment && !isLoading && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-6", children: [
2428
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: lib.cn("flex items-center gap-3 p-4 rounded-xl", config.bg), children: [
2429
+ /* @__PURE__ */ jsxRuntime.jsx(StatusIcon, { className: lib.cn("h-6 w-6", config.color, config.animate && "animate-spin") }),
2430
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-1", children: [
2431
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "font-semibold", children: config.label }),
2432
+ isPending && timeLeft && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-sm text-muted-foreground", children: [
2433
+ "Expires in ",
2434
+ timeLeft
1962
2435
  ] })
1963
2436
  ] })
1964
2437
  ] }),
1965
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between px-4", children: [
1966
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-muted-foreground", children: "Equivalent to" }),
1967
- /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "font-semibold text-lg", children: [
1968
- "$",
1969
- parseFloat(payment.amount_usd || "0").toFixed(2),
1970
- " USD"
1971
- ] })
1972
- ] }),
1973
- payment.internal_payment_id && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between px-4", children: [
1974
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-muted-foreground", children: "Payment Order #" }),
1975
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-mono font-medium", children: payment.internal_payment_id })
1976
- ] }),
1977
- payment.currency_network && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between px-4", children: [
1978
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-muted-foreground", children: "Network" }),
1979
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-medium", children: payment.currency_network })
1980
- ] })
1981
- ] }),
1982
- qrCodeUrl && payment.status === "pending" && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-center p-6 bg-white rounded-sm", children: /* @__PURE__ */ jsxRuntime.jsx("img", { src: qrCodeUrl, alt: "Payment QR Code", className: "w-48 h-48" }) }),
1983
- payment.pay_address && payment.status === "pending" && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
1984
- /* @__PURE__ */ jsxRuntime.jsx("label", { className: "text-sm font-medium", children: "Payment Address" }),
1985
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
1986
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 p-3 bg-muted rounded-sm font-mono text-sm break-all", children: payment.pay_address }),
1987
- /* @__PURE__ */ jsxRuntime.jsx(uiCore.CopyButton, { value: payment.pay_address, variant: "outline" })
1988
- ] })
1989
- ] }),
1990
- payment.transaction_hash && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
1991
- /* @__PURE__ */ jsxRuntime.jsx("label", { className: "text-sm font-medium", children: "Transaction Hash" }),
1992
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-3 bg-muted rounded-sm font-mono text-sm break-all", children: payment.transaction_hash })
1993
- ] }),
1994
- payment.payment_url && payment.status === "pending" && /* @__PURE__ */ jsxRuntime.jsxs(
1995
- uiCore.Button,
1996
- {
1997
- variant: "outline",
1998
- className: "w-full",
1999
- onClick: () => window.open(payment.payment_url, "_blank"),
2000
- children: [
2001
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ExternalLink, { className: "h-4 w-4 mr-2" }),
2002
- "Open in Payment Provider"
2003
- ]
2004
- }
2005
- ),
2006
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "pt-4 border-t space-y-2 text-xs text-muted-foreground", children: [
2007
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-between", children: [
2008
- /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Payment ID" }),
2009
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-mono", children: payment.id })
2010
- ] }),
2011
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-between", children: [
2012
- /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Created" }),
2013
- /* @__PURE__ */ jsxRuntime.jsx("span", { children: moment__default.default.utc(payment.created_at).local().format("MMM D, YYYY HH:mm") })
2014
- ] }),
2015
- payment.confirmations_count !== void 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-between", children: [
2016
- /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Confirmations" }),
2017
- /* @__PURE__ */ jsxRuntime.jsx("span", { children: payment.confirmations_count })
2018
- ] })
2019
- ] })
2020
- ] }),
2021
- /* @__PURE__ */ jsxRuntime.jsxs(uiCore.DialogFooter, { children: [
2022
- /* @__PURE__ */ jsxRuntime.jsx(uiCore.Button, { variant: "outline", onClick: handleClose, children: "Close" }),
2023
- /* @__PURE__ */ jsxRuntime.jsxs(uiCore.Button, { onClick: () => mutate(), variant: "ghost", size: "sm", children: [
2024
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.RefreshCw, { className: "h-4 w-4 mr-2" }),
2025
- "Refresh"
2026
- ] })
2027
- ] })
2028
- ] }) });
2029
- };
2030
- var BalanceCard = () => {
2031
- const {
2032
- balance,
2033
- isLoadingBalance,
2034
- refreshBalance
2035
- } = useOverviewContext();
2036
- const formatCurrency = (amount) => {
2037
- if (amount === null || amount === void 0) return "$0.00";
2038
- return new Intl.NumberFormat("en-US", {
2039
- style: "currency",
2040
- currency: "USD",
2041
- minimumFractionDigits: 2
2042
- }).format(amount);
2043
- };
2044
- const formatDate = (dateStr) => {
2045
- if (!dateStr) return "No transactions yet";
2046
- try {
2047
- return moment__default.default.utc(dateStr).local().format("MMM D, YYYY");
2048
- } catch {
2049
- return "Invalid date";
2050
- }
2051
- };
2052
- if (isLoadingBalance) {
2053
- return /* @__PURE__ */ jsxRuntime.jsxs(uiCore.Card, { children: [
2054
- /* @__PURE__ */ jsxRuntime.jsx(uiCore.CardHeader, { children: /* @__PURE__ */ jsxRuntime.jsxs(uiCore.CardTitle, { className: "flex items-center justify-between", children: [
2055
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
2056
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Wallet, { className: "h-5 w-5" }),
2057
- "Account Balance"
2058
- ] }),
2059
- /* @__PURE__ */ jsxRuntime.jsx(uiCore.Skeleton, { className: "h-8 w-20" })
2060
- ] }) }),
2061
- /* @__PURE__ */ jsxRuntime.jsxs(uiCore.CardContent, { className: "space-y-4", children: [
2062
- /* @__PURE__ */ jsxRuntime.jsx(uiCore.Skeleton, { className: "h-10 w-32" }),
2063
- /* @__PURE__ */ jsxRuntime.jsx(uiCore.Skeleton, { className: "h-4 w-48" })
2064
- ] })
2065
- ] });
2066
- }
2067
- const balanceData = balance?.balance || balance;
2068
- const amountUsd = balanceData?.amount_usd ?? 0;
2069
- const totalDeposited = balanceData?.total_deposited ?? 0;
2070
- const totalWithdrawn = balanceData?.total_withdrawn ?? 0;
2071
- const lastTransactionAt = balanceData?.last_transaction_at;
2072
- const isEmpty = amountUsd === 0 && totalDeposited === 0;
2073
- return /* @__PURE__ */ jsxRuntime.jsxs(uiCore.Card, { children: [
2074
- /* @__PURE__ */ jsxRuntime.jsx(uiCore.CardHeader, { children: /* @__PURE__ */ jsxRuntime.jsxs(uiCore.CardTitle, { className: "flex items-center justify-between", children: [
2075
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
2076
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Wallet, { className: "h-5 w-5" }),
2077
- "Account Balance"
2078
- ] }),
2079
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
2080
- /* @__PURE__ */ jsxRuntime.jsx(uiCore.Button, { variant: "ghost", size: "sm", onClick: refreshBalance, children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.RefreshCw, { className: "h-4 w-4" }) }),
2081
- /* @__PURE__ */ jsxRuntime.jsxs(uiCore.Button, { size: "sm", onClick: () => openCreatePaymentDialog(), children: [
2082
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Plus, { className: "h-4 w-4 mr-2" }),
2083
- "Add Funds"
2084
- ] })
2085
- ] })
2086
- ] }) }),
2087
- /* @__PURE__ */ jsxRuntime.jsxs(uiCore.CardContent, { className: "space-y-4", children: [
2088
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
2089
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-4xl font-bold", children: formatCurrency(amountUsd) }),
2090
- /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-sm text-muted-foreground mt-1", children: [
2091
- "Available balance \u2022 Last updated ",
2092
- formatDate(lastTransactionAt)
2093
- ] })
2094
- ] }),
2095
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-2 gap-4 pt-4 border-t", children: [
2096
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
2097
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-muted-foreground", children: "Total Deposited" }),
2098
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-lg font-semibold text-green-600", children: formatCurrency(totalDeposited) })
2099
- ] }),
2100
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
2101
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-muted-foreground", children: "Total Withdrawn" }),
2102
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-lg font-semibold text-red-600", children: formatCurrency(totalWithdrawn) })
2103
- ] })
2104
- ] }),
2105
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
2106
- /* @__PURE__ */ jsxRuntime.jsx(uiCore.Badge, { variant: !isEmpty ? "default" : "secondary", children: !isEmpty ? "Active" : "New Account" }),
2107
- isEmpty && /* @__PURE__ */ jsxRuntime.jsx(uiCore.Badge, { variant: "outline", children: "Empty Balance" })
2108
- ] })
2109
- ] })
2110
- ] });
2111
- };
2112
- var RecentPayments = () => {
2113
- const { payments, isLoadingPayments } = useOverviewContext();
2114
- const formatCurrency = (amount) => {
2115
- if (amount === null || amount === void 0) return "$0.00";
2116
- const numAmount = typeof amount === "string" ? parseFloat(amount) : amount;
2117
- return new Intl.NumberFormat("en-US", {
2118
- style: "currency",
2119
- currency: "USD",
2120
- minimumFractionDigits: 2
2121
- }).format(numAmount);
2122
- };
2123
- const getRelativeTime = (date) => {
2124
- if (!date) return "N/A";
2125
- const m = moment__default.default.utc(date).local();
2126
- const now = moment__default.default();
2127
- const diffInSeconds = now.diff(m, "seconds");
2128
- if (diffInSeconds < 60) return "Just now";
2129
- if (diffInSeconds < 3600) return `${Math.floor(diffInSeconds / 60)}m ago`;
2130
- if (diffInSeconds < 86400) return `${Math.floor(diffInSeconds / 3600)}h ago`;
2131
- return `${Math.floor(diffInSeconds / 86400)}d ago`;
2132
- };
2133
- const getStatusVariant = (status) => {
2134
- switch (status?.toLowerCase()) {
2135
- case "completed":
2136
- case "success":
2137
- return "default";
2138
- case "pending":
2139
- case "confirming":
2140
- return "secondary";
2141
- case "failed":
2142
- case "error":
2143
- case "expired":
2144
- return "destructive";
2145
- default:
2146
- return "outline";
2147
- }
2148
- };
2149
- if (isLoadingPayments) {
2150
- return /* @__PURE__ */ jsxRuntime.jsxs(uiCore.Card, { children: [
2151
- /* @__PURE__ */ jsxRuntime.jsx(uiCore.CardHeader, { children: /* @__PURE__ */ jsxRuntime.jsxs(uiCore.CardTitle, { className: "flex items-center gap-2", children: [
2152
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.History, { className: "h-5 w-5" }),
2153
- "Recent Payments"
2154
- ] }) }),
2155
- /* @__PURE__ */ jsxRuntime.jsx(uiCore.CardContent, { className: "space-y-3", children: Array.from({ length: 5 }).map((_, i) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between p-3 border rounded-sm", children: [
2156
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
2157
- /* @__PURE__ */ jsxRuntime.jsx(uiCore.Skeleton, { className: "h-4 w-32" }),
2158
- /* @__PURE__ */ jsxRuntime.jsx(uiCore.Skeleton, { className: "h-3 w-24" })
2159
- ] }),
2160
- /* @__PURE__ */ jsxRuntime.jsx(uiCore.Skeleton, { className: "h-6 w-16" })
2161
- ] }, i)) })
2162
- ] });
2163
- }
2164
- const recentPaymentsList = payments?.results?.slice(0, 5) || [];
2165
- return /* @__PURE__ */ jsxRuntime.jsxs(uiCore.Card, { children: [
2166
- /* @__PURE__ */ jsxRuntime.jsx(uiCore.CardHeader, { children: /* @__PURE__ */ jsxRuntime.jsxs(uiCore.CardTitle, { className: "flex items-center justify-between", children: [
2167
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
2168
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.History, { className: "h-5 w-5" }),
2169
- "Recent Payments"
2170
- ] }),
2171
- /* @__PURE__ */ jsxRuntime.jsxs(uiCore.Button, { variant: "ghost", size: "sm", children: [
2172
- "View All",
2173
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ExternalLink, { className: "h-4 w-4 ml-2" })
2174
- ] })
2175
- ] }) }),
2176
- /* @__PURE__ */ jsxRuntime.jsx(uiCore.CardContent, { children: recentPaymentsList.length === 0 ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-center py-8 text-muted-foreground", children: [
2177
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.History, { className: "h-12 w-12 mx-auto mb-4 opacity-50" }),
2178
- /* @__PURE__ */ jsxRuntime.jsx("p", { children: "No recent payments" }),
2179
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm mt-2", children: "Create your first payment to get started" })
2180
- ] }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-3", children: recentPaymentsList.map((payment) => /* @__PURE__ */ jsxRuntime.jsxs(
2181
- "div",
2182
- {
2183
- className: "flex items-center justify-between p-3 border rounded-sm hover:bg-accent cursor-pointer transition-colors",
2184
- onClick: () => openPaymentDetailsDialog(String(payment.id)),
2185
- children: [
2186
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-1", children: [
2438
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-muted rounded-xl p-4 space-y-3", children: [
2439
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [
2440
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground", children: "Amount to send" }),
2187
2441
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
2188
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-medium", children: formatCurrency(payment.amount_usd) }),
2189
- /* @__PURE__ */ jsxRuntime.jsx(uiCore.Badge, { variant: getStatusVariant(payment.status), className: "text-xs", children: payment.status })
2190
- ] }),
2191
- /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-sm text-muted-foreground", children: [
2192
- getRelativeTime(payment.created_at),
2193
- " \u2022 ",
2194
- payment.currency_code || "USD"
2442
+ /* @__PURE__ */ jsxRuntime.jsx(uiCore.TokenIcon, { symbol: payment.currency_code, size: 24 }),
2443
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "font-mono font-bold text-lg", children: [
2444
+ payment.pay_amount,
2445
+ " ",
2446
+ payment.currency_code
2447
+ ] })
2195
2448
  ] })
2196
2449
  ] }),
2197
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ExternalLink, { className: "h-4 w-4 text-muted-foreground" })
2198
- ]
2199
- },
2200
- payment.id
2201
- )) }) })
2202
- ] });
2203
- };
2204
- var OverviewView = () => {
2205
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-6", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid gap-6 lg:grid-cols-2", children: [
2206
- /* @__PURE__ */ jsxRuntime.jsx(BalanceCard, {}),
2207
- /* @__PURE__ */ jsxRuntime.jsx(RecentPayments, {})
2208
- ] }) });
2209
- };
2210
- var PaymentsList = () => {
2211
- const pagination = components.useDRFPagination(1, 20);
2212
- const {
2213
- data: payments,
2214
- error,
2215
- isLoading: isLoadingPayments,
2216
- mutate: refreshPayments
2217
- } = usePaymentsPaymentsList(pagination.params, apiPayments);
2218
- const paymentsList = payments?.results || [];
2219
- payments?.count || 0;
2220
- const [searchTerm, setSearchTerm] = react.useState("");
2221
- const [statusFilter, setStatusFilter] = react.useState("all");
2222
- const formatCurrency = (amount) => {
2223
- if (amount === null || amount === void 0) return "$0.00";
2224
- const numAmount = typeof amount === "string" ? parseFloat(amount) : amount;
2225
- return new Intl.NumberFormat("en-US", {
2226
- style: "currency",
2227
- currency: "USD",
2228
- minimumFractionDigits: 2
2229
- }).format(numAmount);
2230
- };
2231
- const getRelativeTime = (date) => {
2232
- if (!date) return "N/A";
2233
- const m = moment__default.default.utc(date).local();
2234
- const now = moment__default.default();
2235
- const diffInSeconds = now.diff(m, "seconds");
2236
- if (diffInSeconds < 60) return "Just now";
2237
- if (diffInSeconds < 3600) return `${Math.floor(diffInSeconds / 60)}m ago`;
2238
- if (diffInSeconds < 86400) return `${Math.floor(diffInSeconds / 3600)}h ago`;
2239
- return `${Math.floor(diffInSeconds / 86400)}d ago`;
2240
- };
2241
- const formatDate = (date) => {
2242
- if (!date) return "N/A";
2243
- return moment__default.default.utc(date).local().format("MMM D, YYYY");
2244
- };
2245
- const getStatusVariant = (status) => {
2246
- switch (status?.toLowerCase()) {
2247
- case "completed":
2248
- case "success":
2249
- return "default";
2250
- case "pending":
2251
- case "confirming":
2252
- return "secondary";
2253
- case "failed":
2254
- case "error":
2255
- case "expired":
2256
- return "destructive";
2257
- default:
2258
- return "outline";
2259
- }
2260
- };
2261
- const handleSearch = (value) => {
2262
- setSearchTerm(value);
2263
- };
2264
- const handleStatusFilter = (status) => {
2265
- setStatusFilter(status);
2266
- };
2267
- const truncateId = (id) => {
2268
- if (!id) return "N/A";
2269
- const str = id.toString();
2270
- return str.length > 8 ? `${str.slice(0, 8)}...` : str;
2271
- };
2272
- const filteredPayments = paymentsList.filter((payment) => {
2273
- const matchesSearch = searchTerm ? payment.id?.toLowerCase().includes(searchTerm.toLowerCase()) || payment.status?.toLowerCase().includes(searchTerm.toLowerCase()) || payment.currency_code?.toLowerCase().includes(searchTerm.toLowerCase()) : true;
2274
- const matchesStatus = statusFilter !== "all" ? payment.status?.toLowerCase() === statusFilter.toLowerCase() : true;
2275
- return matchesSearch && matchesStatus;
2276
- }).map((payment) => ({
2277
- ...payment,
2278
- formattedDate: formatDate(payment.created_at),
2279
- relativeTime: getRelativeTime(payment.created_at),
2280
- truncatedId: truncateId(payment.id)
2281
- }));
2282
- return /* @__PURE__ */ jsxRuntime.jsxs(uiCore.Card, { children: [
2283
- /* @__PURE__ */ jsxRuntime.jsx(uiCore.CardHeader, { children: /* @__PURE__ */ jsxRuntime.jsxs(uiCore.CardTitle, { className: "flex items-center justify-between", children: [
2284
- /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Payment History" }),
2285
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
2286
- /* @__PURE__ */ jsxRuntime.jsxs(uiCore.Button, { variant: "outline", size: "sm", onClick: () => refreshPayments(), disabled: isLoadingPayments, children: [
2287
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.RefreshCw, { className: `h-4 w-4 mr-2 ${isLoadingPayments ? "animate-spin" : ""}` }),
2288
- "Refresh"
2450
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between text-sm", children: [
2451
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground", children: "Equivalent" }),
2452
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "font-semibold", children: [
2453
+ "$",
2454
+ parseFloat(payment.amount_usd).toFixed(2),
2455
+ " USD"
2456
+ ] })
2457
+ ] }),
2458
+ payment.currency_network && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between text-sm pt-2 border-t", children: [
2459
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground", children: "Network" }),
2460
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-medium", children: payment.currency_network })
2461
+ ] })
2289
2462
  ] }),
2290
- /* @__PURE__ */ jsxRuntime.jsxs(uiCore.Button, { size: "sm", onClick: () => openCreatePaymentDialog(), children: [
2291
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Plus, { className: "h-4 w-4 mr-2" }),
2292
- "New Payment"
2293
- ] })
2294
- ] })
2295
- ] }) }),
2296
- /* @__PURE__ */ jsxRuntime.jsxs(uiCore.CardContent, { className: "space-y-4", children: [
2297
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col sm:flex-row gap-4", children: [
2298
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative flex-1", children: [
2299
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Search, { className: "absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground" }),
2300
- /* @__PURE__ */ jsxRuntime.jsx(
2301
- uiCore.Input,
2302
- {
2303
- placeholder: "Search by ID, status, or currency...",
2304
- value: searchTerm,
2305
- onChange: (e) => handleSearch(e.target.value),
2306
- className: "pl-10"
2307
- }
2308
- )
2463
+ qrCodeUrl && isPending && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-center p-6 bg-white rounded-xl", children: /* @__PURE__ */ jsxRuntime.jsx("img", { src: qrCodeUrl, alt: "Payment QR Code", className: "w-48 h-48" }) }),
2464
+ payment.pay_address && isPending && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
2465
+ /* @__PURE__ */ jsxRuntime.jsx("label", { className: "text-sm font-medium", children: "Payment Address" }),
2466
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
2467
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 p-3 bg-muted rounded-xl font-mono text-sm break-all", children: payment.pay_address }),
2468
+ /* @__PURE__ */ jsxRuntime.jsx(uiCore.CopyButton, { value: payment.pay_address, variant: "outline", className: "shrink-0" })
2469
+ ] })
2470
+ ] }),
2471
+ payment.transaction_hash && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
2472
+ /* @__PURE__ */ jsxRuntime.jsx("label", { className: "text-sm font-medium", children: "Transaction Hash" }),
2473
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-3 bg-muted rounded-xl font-mono text-sm break-all", children: payment.transaction_hash })
2309
2474
  ] }),
2310
- /* @__PURE__ */ jsxRuntime.jsxs(uiCore.Select, { value: statusFilter, onValueChange: handleStatusFilter, children: [
2311
- /* @__PURE__ */ jsxRuntime.jsxs(uiCore.SelectTrigger, { className: "w-full sm:w-48", children: [
2312
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Filter, { className: "h-4 w-4 mr-2" }),
2313
- /* @__PURE__ */ jsxRuntime.jsx(uiCore.SelectValue, { placeholder: "Filter by status" })
2475
+ payment.payment_url && isPending && /* @__PURE__ */ jsxRuntime.jsxs(
2476
+ uiCore.Button,
2477
+ {
2478
+ variant: "outline",
2479
+ className: "w-full",
2480
+ onClick: () => window.open(payment.payment_url, "_blank"),
2481
+ children: [
2482
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ExternalLink, { className: "h-4 w-4 mr-2" }),
2483
+ "Open in Payment Provider"
2484
+ ]
2485
+ }
2486
+ ),
2487
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2 text-xs text-muted-foreground pt-4 border-t", children: [
2488
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-between", children: [
2489
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Payment ID" }),
2490
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-mono", children: payment.id })
2314
2491
  ] }),
2315
- /* @__PURE__ */ jsxRuntime.jsxs(uiCore.SelectContent, { children: [
2316
- /* @__PURE__ */ jsxRuntime.jsx(uiCore.SelectItem, { value: "all", children: "All Statuses" }),
2317
- /* @__PURE__ */ jsxRuntime.jsx(uiCore.SelectItem, { value: "completed", children: "Completed" }),
2318
- /* @__PURE__ */ jsxRuntime.jsx(uiCore.SelectItem, { value: "pending", children: "Pending" }),
2319
- /* @__PURE__ */ jsxRuntime.jsx(uiCore.SelectItem, { value: "confirming", children: "Confirming" }),
2320
- /* @__PURE__ */ jsxRuntime.jsx(uiCore.SelectItem, { value: "failed", children: "Failed" }),
2321
- /* @__PURE__ */ jsxRuntime.jsx(uiCore.SelectItem, { value: "expired", children: "Expired" })
2492
+ payment.internal_payment_id && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-between", children: [
2493
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Order #" }),
2494
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-mono", children: payment.internal_payment_id })
2495
+ ] }),
2496
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-between", children: [
2497
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: "Created" }),
2498
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: moment2__default.default.utc(payment.created_at).local().format("MMM D, YYYY HH:mm") })
2322
2499
  ] })
2323
- ] })
2324
- ] }),
2325
- isLoadingPayments ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-3", children: Array.from({ length: 5 }).map((_, i) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between p-4 border rounded-sm", children: [
2326
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
2327
- /* @__PURE__ */ jsxRuntime.jsx(uiCore.Skeleton, { className: "h-4 w-32" }),
2328
- /* @__PURE__ */ jsxRuntime.jsx(uiCore.Skeleton, { className: "h-3 w-24" })
2329
2500
  ] }),
2330
- /* @__PURE__ */ jsxRuntime.jsx(uiCore.Skeleton, { className: "h-6 w-16" })
2331
- ] }, i)) }) : filteredPayments.length === 0 ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-center py-12", children: [
2332
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-16 h-16 mx-auto mb-4 bg-muted rounded-full flex items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Search, { className: "w-8 h-8 text-muted-foreground" }) }),
2333
- /* @__PURE__ */ jsxRuntime.jsx("h3", { className: "text-lg font-semibold mb-2", children: "No Payments Found" }),
2334
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-muted-foreground mb-4", children: searchTerm || statusFilter !== "all" ? "No payments match your current filters" : "You haven't made any payments yet" }),
2335
- /* @__PURE__ */ jsxRuntime.jsxs(uiCore.Button, { onClick: () => openCreatePaymentDialog(), children: [
2336
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Plus, { className: "h-4 w-4 mr-2" }),
2337
- "Create Payment"
2338
- ] })
2339
- ] }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
2340
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-md border", children: /* @__PURE__ */ jsxRuntime.jsxs(uiCore.Table, { children: [
2341
- /* @__PURE__ */ jsxRuntime.jsx(uiCore.TableHeader, { children: /* @__PURE__ */ jsxRuntime.jsxs(uiCore.TableRow, { children: [
2342
- /* @__PURE__ */ jsxRuntime.jsx(uiCore.TableHead, { children: "Date" }),
2343
- /* @__PURE__ */ jsxRuntime.jsx(uiCore.TableHead, { children: "Amount" }),
2344
- /* @__PURE__ */ jsxRuntime.jsx(uiCore.TableHead, { children: "Currency" }),
2345
- /* @__PURE__ */ jsxRuntime.jsx(uiCore.TableHead, { children: "Status" }),
2346
- /* @__PURE__ */ jsxRuntime.jsx(uiCore.TableHead, { children: "Provider" }),
2347
- /* @__PURE__ */ jsxRuntime.jsx(uiCore.TableHead, { children: "Payment ID" }),
2348
- /* @__PURE__ */ jsxRuntime.jsx(uiCore.TableHead, { className: "text-right", children: "Actions" })
2349
- ] }) }),
2350
- /* @__PURE__ */ jsxRuntime.jsx(uiCore.TableBody, { children: filteredPayments.map((payment) => /* @__PURE__ */ jsxRuntime.jsxs(
2351
- uiCore.TableRow,
2352
- {
2353
- className: "cursor-pointer hover:bg-accent",
2354
- onClick: () => openPaymentDetailsDialog(String(payment.id)),
2355
- children: [
2356
- /* @__PURE__ */ jsxRuntime.jsx(uiCore.TableCell, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
2357
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "font-medium", children: payment.formattedDate }),
2358
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-sm text-muted-foreground", children: payment.relativeTime })
2359
- ] }) }),
2360
- /* @__PURE__ */ jsxRuntime.jsx(uiCore.TableCell, { className: "font-mono font-semibold", children: formatCurrency(payment.amount_usd) }),
2361
- /* @__PURE__ */ jsxRuntime.jsx(uiCore.TableCell, { children: /* @__PURE__ */ jsxRuntime.jsx(uiCore.Badge, { variant: "outline", children: payment.currency_code || "USD" }) }),
2362
- /* @__PURE__ */ jsxRuntime.jsx(uiCore.TableCell, { children: /* @__PURE__ */ jsxRuntime.jsx(uiCore.Badge, { variant: getStatusVariant(payment.status), children: payment.status }) }),
2363
- /* @__PURE__ */ jsxRuntime.jsx(uiCore.TableCell, { className: "text-sm text-muted-foreground", children: "NowPayments" }),
2364
- /* @__PURE__ */ jsxRuntime.jsx(uiCore.TableCell, { className: "font-mono text-sm text-muted-foreground", children: payment.truncatedId }),
2365
- /* @__PURE__ */ jsxRuntime.jsx(uiCore.TableCell, { className: "text-right", children: /* @__PURE__ */ jsxRuntime.jsx(
2366
- uiCore.Button,
2367
- {
2368
- variant: "ghost",
2369
- size: "sm",
2370
- onClick: (e) => {
2371
- e.stopPropagation();
2372
- openPaymentDetailsDialog(String(payment.id));
2373
- },
2374
- children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ExternalLink, { className: "h-4 w-4" })
2375
- }
2376
- ) })
2377
- ]
2378
- },
2379
- payment.id
2380
- )) })
2381
- ] }) }),
2382
- /* @__PURE__ */ jsxRuntime.jsx(
2383
- components.StaticPagination,
2501
+ /* @__PURE__ */ jsxRuntime.jsxs(
2502
+ uiCore.Button,
2384
2503
  {
2385
- data: payments,
2386
- onPageChange: pagination.setPage,
2387
- className: "mt-4"
2504
+ variant: "ghost",
2505
+ className: "w-full",
2506
+ onClick: () => mutate(),
2507
+ children: [
2508
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.RefreshCw, { className: "h-4 w-4 mr-2" }),
2509
+ "Refresh Status"
2510
+ ]
2388
2511
  }
2389
2512
  )
2390
2513
  ] })
2391
2514
  ] })
2392
- ] });
2393
- };
2394
- var PaymentsView = () => {
2395
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-6", children: /* @__PURE__ */ jsxRuntime.jsx(PaymentsList, {}) });
2396
- };
2397
- var TransactionsList = () => {
2398
- const {
2399
- transactions,
2400
- isLoadingTransactions,
2401
- refreshTransactions
2402
- } = useOverviewContext();
2403
- const [searchTerm, setSearchTerm] = react.useState("");
2404
- const [typeFilter, setTypeFilter] = react.useState("all");
2405
- const transactionsList = transactions?.results || transactions?.transactions || [];
2406
- const formatCurrency = (amount) => {
2407
- if (amount === null || amount === void 0) return "$0.00";
2408
- return new Intl.NumberFormat("en-US", {
2409
- style: "currency",
2410
- currency: "USD",
2411
- minimumFractionDigits: 2
2412
- }).format(amount);
2413
- };
2414
- const formatDate = (date) => {
2415
- if (!date) return "N/A";
2416
- try {
2417
- return moment__default.default.utc(date).local().format("MMM D, YYYY hh:mm A");
2418
- } catch {
2419
- return "Invalid date";
2420
- }
2421
- };
2422
- const getRelativeTime = (date) => {
2423
- if (!date) return "N/A";
2424
- const m = moment__default.default.utc(date).local();
2425
- const now = moment__default.default();
2426
- const diffInSeconds = now.diff(m, "seconds");
2427
- if (diffInSeconds < 60) return "Just now";
2428
- if (diffInSeconds < 3600) return `${Math.floor(diffInSeconds / 60)}m ago`;
2429
- if (diffInSeconds < 86400) return `${Math.floor(diffInSeconds / 3600)}h ago`;
2430
- return `${Math.floor(diffInSeconds / 86400)}d ago`;
2431
- };
2432
- const getTypeVariant = (type) => {
2433
- switch (type?.toLowerCase()) {
2434
- case "deposit":
2435
- case "credit":
2436
- return "default";
2437
- case "withdrawal":
2438
- case "debit":
2439
- return "destructive";
2440
- default:
2441
- return "outline";
2442
- }
2443
- };
2444
- const getTypeIcon = (type) => {
2445
- const isDeposit = type?.toLowerCase() === "deposit" || type?.toLowerCase() === "credit";
2446
- return isDeposit ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ArrowDownLeft, { className: "h-4 w-4 text-green-600" }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ArrowUpRight, { className: "h-4 w-4 text-red-600" });
2447
- };
2448
- const handleSearch = async (value) => {
2449
- setSearchTerm(value);
2450
- await refreshTransactions();
2451
- };
2452
- const handleTypeFilter = async (type) => {
2453
- setTypeFilter(type);
2454
- await refreshTransactions();
2455
- };
2456
- const truncateId = (id) => {
2457
- if (!id) return "N/A";
2458
- const str = id.toString();
2459
- return str.length > 8 ? `${str.slice(0, 8)}...` : str;
2460
- };
2461
- const filteredTransactions = transactionsList.filter((transaction) => {
2462
- const matchesSearch = searchTerm ? transaction.id?.toString().toLowerCase().includes(searchTerm.toLowerCase()) || transaction.description?.toLowerCase().includes(searchTerm.toLowerCase()) || transaction.type?.toLowerCase().includes(searchTerm.toLowerCase()) : true;
2463
- const matchesType = typeFilter !== "all" ? transaction.type?.toLowerCase() === typeFilter.toLowerCase() : true;
2464
- return matchesSearch && matchesType;
2465
- }).map((transaction) => ({
2466
- ...transaction,
2467
- isDeposit: transaction.type?.toLowerCase() === "deposit" || transaction.type?.toLowerCase() === "credit",
2468
- formattedDate: formatDate(transaction.created_at || transaction.timestamp),
2469
- relativeTime: getRelativeTime(transaction.created_at || transaction.timestamp),
2470
- truncatedRef: truncateId(transaction.reference || transaction.payment_id)
2471
- }));
2472
- if (isLoadingTransactions) {
2473
- return /* @__PURE__ */ jsxRuntime.jsxs(uiCore.Card, { children: [
2474
- /* @__PURE__ */ jsxRuntime.jsx(uiCore.CardHeader, { children: /* @__PURE__ */ jsxRuntime.jsxs(uiCore.CardTitle, { className: "flex items-center gap-2", children: [
2475
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.History, { className: "h-5 w-5" }),
2476
- "Transaction History"
2477
- ] }) }),
2478
- /* @__PURE__ */ jsxRuntime.jsx(uiCore.CardContent, { className: "space-y-3", children: Array.from({ length: 5 }).map((_, i) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between p-4 border rounded-sm", children: [
2479
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
2480
- /* @__PURE__ */ jsxRuntime.jsx(uiCore.Skeleton, { className: "h-4 w-32" }),
2481
- /* @__PURE__ */ jsxRuntime.jsx(uiCore.Skeleton, { className: "h-3 w-24" })
2482
- ] }),
2483
- /* @__PURE__ */ jsxRuntime.jsx(uiCore.Skeleton, { className: "h-6 w-16" })
2484
- ] }, i)) })
2485
- ] });
2486
- }
2487
- return /* @__PURE__ */ jsxRuntime.jsxs(uiCore.Card, { children: [
2488
- /* @__PURE__ */ jsxRuntime.jsx(uiCore.CardHeader, { children: /* @__PURE__ */ jsxRuntime.jsxs(uiCore.CardTitle, { className: "flex items-center justify-between", children: [
2489
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
2490
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.History, { className: "h-5 w-5" }),
2491
- "Transaction History"
2492
- ] }),
2493
- /* @__PURE__ */ jsxRuntime.jsxs(uiCore.Button, { variant: "outline", size: "sm", onClick: refreshTransactions, disabled: isLoadingTransactions, children: [
2494
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.RefreshCw, { className: `h-4 w-4 mr-2 ${isLoadingTransactions ? "animate-spin" : ""}` }),
2495
- "Refresh"
2496
- ] })
2497
- ] }) }),
2498
- /* @__PURE__ */ jsxRuntime.jsxs(uiCore.CardContent, { className: "space-y-4", children: [
2499
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col sm:flex-row gap-4", children: [
2500
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative flex-1", children: [
2501
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Search, { className: "absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground" }),
2502
- /* @__PURE__ */ jsxRuntime.jsx(
2503
- uiCore.Input,
2504
- {
2505
- placeholder: "Search by ID, description, or type...",
2506
- value: searchTerm,
2507
- onChange: (e) => handleSearch(e.target.value),
2508
- className: "pl-10"
2509
- }
2510
- )
2511
- ] }),
2512
- /* @__PURE__ */ jsxRuntime.jsxs(uiCore.Select, { value: typeFilter, onValueChange: handleTypeFilter, children: [
2513
- /* @__PURE__ */ jsxRuntime.jsxs(uiCore.SelectTrigger, { className: "w-full sm:w-48", children: [
2514
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Filter, { className: "h-4 w-4 mr-2" }),
2515
- /* @__PURE__ */ jsxRuntime.jsx(uiCore.SelectValue, { placeholder: "Filter by type" })
2516
- ] }),
2517
- /* @__PURE__ */ jsxRuntime.jsxs(uiCore.SelectContent, { children: [
2518
- /* @__PURE__ */ jsxRuntime.jsx(uiCore.SelectItem, { value: "all", children: "All Types" }),
2519
- /* @__PURE__ */ jsxRuntime.jsx(uiCore.SelectItem, { value: "deposit", children: "Deposits" }),
2520
- /* @__PURE__ */ jsxRuntime.jsx(uiCore.SelectItem, { value: "withdrawal", children: "Withdrawals" })
2521
- ] })
2522
- ] })
2523
- ] }),
2524
- filteredTransactions.length === 0 ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-center py-12", children: [
2525
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-16 h-16 mx-auto mb-4 bg-muted rounded-full flex items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.History, { className: "w-8 h-8 text-muted-foreground" }) }),
2526
- /* @__PURE__ */ jsxRuntime.jsx("h3", { className: "text-lg font-semibold mb-2", children: "No Transactions Found" }),
2527
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-muted-foreground", children: searchTerm || typeFilter !== "all" ? "No transactions match your current filters" : "You don't have any transactions yet" })
2528
- ] }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-md border", children: /* @__PURE__ */ jsxRuntime.jsxs(uiCore.Table, { children: [
2529
- /* @__PURE__ */ jsxRuntime.jsx(uiCore.TableHeader, { children: /* @__PURE__ */ jsxRuntime.jsxs(uiCore.TableRow, { children: [
2530
- /* @__PURE__ */ jsxRuntime.jsx(uiCore.TableHead, { children: "Date & Time" }),
2531
- /* @__PURE__ */ jsxRuntime.jsx(uiCore.TableHead, { children: "Type" }),
2532
- /* @__PURE__ */ jsxRuntime.jsx(uiCore.TableHead, { children: "Amount" }),
2533
- /* @__PURE__ */ jsxRuntime.jsx(uiCore.TableHead, { children: "Balance After" }),
2534
- /* @__PURE__ */ jsxRuntime.jsx(uiCore.TableHead, { children: "Description" }),
2535
- /* @__PURE__ */ jsxRuntime.jsx(uiCore.TableHead, { children: "Reference" })
2536
- ] }) }),
2537
- /* @__PURE__ */ jsxRuntime.jsx(uiCore.TableBody, { children: filteredTransactions.map((transaction, index) => /* @__PURE__ */ jsxRuntime.jsxs(uiCore.TableRow, { children: [
2538
- /* @__PURE__ */ jsxRuntime.jsx(uiCore.TableCell, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
2539
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "font-medium", children: transaction.formattedDate }),
2540
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-sm text-muted-foreground", children: transaction.relativeTime })
2541
- ] }) }),
2542
- /* @__PURE__ */ jsxRuntime.jsx(uiCore.TableCell, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
2543
- getTypeIcon(transaction.type),
2544
- /* @__PURE__ */ jsxRuntime.jsx(uiCore.Badge, { variant: getTypeVariant(transaction.type), children: transaction.type || "Unknown" })
2545
- ] }) }),
2546
- /* @__PURE__ */ jsxRuntime.jsx(uiCore.TableCell, { className: "font-mono font-semibold", children: /* @__PURE__ */ jsxRuntime.jsxs("span", { className: transaction.isDeposit ? "text-green-600" : "text-red-600", children: [
2547
- transaction.isDeposit ? "+" : "-",
2548
- formatCurrency(Math.abs(transaction.amount || transaction.amount_usd || 0))
2549
- ] }) }),
2550
- /* @__PURE__ */ jsxRuntime.jsx(uiCore.TableCell, { className: "font-mono", children: formatCurrency(transaction.balance_after || 0) }),
2551
- /* @__PURE__ */ jsxRuntime.jsx(uiCore.TableCell, { className: "text-sm", children: transaction.description || transaction.note || "No description" }),
2552
- /* @__PURE__ */ jsxRuntime.jsx(uiCore.TableCell, { className: "font-mono text-sm text-muted-foreground", children: transaction.truncatedRef })
2553
- ] }, transaction.id || index)) })
2554
- ] }) })
2555
- ] })
2556
- ] });
2557
- };
2558
- var TransactionsView = () => {
2559
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-6", children: /* @__PURE__ */ jsxRuntime.jsx(TransactionsList, {}) });
2560
- };
2561
- var PaymentsLayout = () => {
2562
- return /* @__PURE__ */ jsxRuntime.jsx(RootPaymentsProvider, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "h-full p-6 space-y-6", children: [
2563
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
2564
- /* @__PURE__ */ jsxRuntime.jsx("h1", { className: "text-3xl font-bold tracking-tight", children: "Payments" }),
2565
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-muted-foreground", children: "Manage your payments, balance, and transaction history" })
2566
- ] }),
2567
- /* @__PURE__ */ jsxRuntime.jsxs(uiCore.Tabs, { defaultValue: "overview", className: "space-y-6", children: [
2568
- /* @__PURE__ */ jsxRuntime.jsxs(uiCore.TabsList, { className: "inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground", children: [
2569
- /* @__PURE__ */ jsxRuntime.jsxs(uiCore.TabsTrigger, { value: "overview", className: "inline-flex items-center gap-2 px-3 py-1.5", children: [
2570
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Wallet, { className: "h-4 w-4" }),
2571
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "hidden sm:inline", children: "Overview" })
2572
- ] }),
2573
- /* @__PURE__ */ jsxRuntime.jsxs(uiCore.TabsTrigger, { value: "payments", className: "inline-flex items-center gap-2 px-3 py-1.5", children: [
2574
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CreditCard, { className: "h-4 w-4" }),
2575
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "hidden sm:inline", children: "Payments" })
2576
- ] }),
2577
- /* @__PURE__ */ jsxRuntime.jsxs(uiCore.TabsTrigger, { value: "transactions", className: "inline-flex items-center gap-2 px-3 py-1.5", children: [
2578
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.History, { className: "h-4 w-4" }),
2579
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "hidden sm:inline", children: "Transactions" })
2580
- ] })
2581
- ] }),
2582
- /* @__PURE__ */ jsxRuntime.jsx(uiCore.TabsContent, { value: "overview", className: "space-y-6", children: /* @__PURE__ */ jsxRuntime.jsx(OverviewProvider, { children: /* @__PURE__ */ jsxRuntime.jsxs(PaymentsProvider, { children: [
2583
- /* @__PURE__ */ jsxRuntime.jsx(OverviewView, {}),
2584
- /* @__PURE__ */ jsxRuntime.jsx(CreatePaymentDialog, {})
2585
- ] }) }) }),
2586
- /* @__PURE__ */ jsxRuntime.jsx(uiCore.TabsContent, { value: "payments", className: "space-y-6", children: /* @__PURE__ */ jsxRuntime.jsxs(PaymentsProvider, { children: [
2587
- /* @__PURE__ */ jsxRuntime.jsx(PaymentsView, {}),
2588
- /* @__PURE__ */ jsxRuntime.jsx(CreatePaymentDialog, {})
2589
- ] }) }),
2590
- /* @__PURE__ */ jsxRuntime.jsx(uiCore.TabsContent, { value: "transactions", className: "space-y-6", children: /* @__PURE__ */ jsxRuntime.jsx(OverviewProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(TransactionsView, {}) }) })
2591
- ] }),
2592
- /* @__PURE__ */ jsxRuntime.jsx(PaymentDetailsDialog, {})
2593
2515
  ] }) });
2594
- };
2516
+ }
2517
+ var ResponsiveSheetContext = React2__namespace.createContext({ isMobile: false });
2518
+ function ResponsiveSheet4({ open, onOpenChange, children }) {
2519
+ const isMobile = uiCore.useIsMobile();
2520
+ if (isMobile) {
2521
+ return /* @__PURE__ */ jsxRuntime.jsx(ResponsiveSheetContext.Provider, { value: { isMobile: true }, children: /* @__PURE__ */ jsxRuntime.jsx(uiCore.Drawer, { open, onOpenChange, children }) });
2522
+ }
2523
+ return /* @__PURE__ */ jsxRuntime.jsx(ResponsiveSheetContext.Provider, { value: { isMobile: false }, children: /* @__PURE__ */ jsxRuntime.jsx(uiCore.Dialog, { open, onOpenChange, children }) });
2524
+ }
2525
+ function ResponsiveSheetContent4({ children, className }) {
2526
+ const { isMobile } = React2__namespace.useContext(ResponsiveSheetContext);
2527
+ if (isMobile) {
2528
+ return /* @__PURE__ */ jsxRuntime.jsx(uiCore.DrawerContent, { className, children });
2529
+ }
2530
+ return /* @__PURE__ */ jsxRuntime.jsx(uiCore.DialogContent, { className, children });
2531
+ }
2532
+ function ResponsiveSheetHeader4({ children, className }) {
2533
+ const { isMobile } = React2__namespace.useContext(ResponsiveSheetContext);
2534
+ if (isMobile) {
2535
+ return /* @__PURE__ */ jsxRuntime.jsx(uiCore.DrawerHeader, { className, children });
2536
+ }
2537
+ return /* @__PURE__ */ jsxRuntime.jsx(uiCore.DialogHeader, { className, children });
2538
+ }
2539
+ function ResponsiveSheetTitle4({ children, className }) {
2540
+ const { isMobile } = React2__namespace.useContext(ResponsiveSheetContext);
2541
+ if (isMobile) {
2542
+ return /* @__PURE__ */ jsxRuntime.jsx(uiCore.DrawerTitle, { className, children });
2543
+ }
2544
+ return /* @__PURE__ */ jsxRuntime.jsx(uiCore.DialogTitle, { className, children });
2545
+ }
2546
+ function ResponsiveSheetDescription4({ children, className }) {
2547
+ const { isMobile } = React2__namespace.useContext(ResponsiveSheetContext);
2548
+ if (isMobile) {
2549
+ return /* @__PURE__ */ jsxRuntime.jsx(uiCore.DrawerDescription, { className, children });
2550
+ }
2551
+ return /* @__PURE__ */ jsxRuntime.jsx(uiCore.DialogDescription, { className, children });
2552
+ }
2553
+ function ResponsiveSheetFooter({ children, className }) {
2554
+ const { isMobile } = React2__namespace.useContext(ResponsiveSheetContext);
2555
+ if (isMobile) {
2556
+ return /* @__PURE__ */ jsxRuntime.jsx(uiCore.DrawerFooter, { className, children });
2557
+ }
2558
+ return /* @__PURE__ */ jsxRuntime.jsx(uiCore.DialogFooter, { className, children });
2559
+ }
2595
2560
 
2596
2561
  // package.json
2597
2562
  var package_default = {
2598
2563
  name: "@djangocfg/ext-payments",
2599
- version: "1.0.13",
2564
+ version: "1.0.17",
2600
2565
  description: "Payments system extension for DjangoCFG",
2601
2566
  keywords: [
2602
2567
  "django",
@@ -2633,11 +2598,6 @@ var package_default = {
2633
2598
  import: "./dist/index.js",
2634
2599
  require: "./dist/index.cjs"
2635
2600
  },
2636
- "./hooks": {
2637
- types: "./dist/hooks.d.ts",
2638
- import: "./dist/hooks.js",
2639
- require: "./dist/hooks.cjs"
2640
- },
2641
2601
  "./config": {
2642
2602
  types: "./dist/config.d.ts",
2643
2603
  import: "./dist/config.js",
@@ -2665,8 +2625,10 @@ var package_default = {
2665
2625
  "p-retry": "^7.0.0",
2666
2626
  react: "^19",
2667
2627
  swr: "^2.3.7",
2668
- zod: "^4.1.13",
2669
- moment: "^2.30.1"
2628
+ zod: "^4.3.4",
2629
+ moment: "^2.30.1",
2630
+ "react-hook-form": "^7.69.0",
2631
+ "@hookform/resolvers": "^5.2.2"
2670
2632
  },
2671
2633
  devDependencies: {
2672
2634
  "@djangocfg/api": "workspace:*",
@@ -2743,6 +2705,10 @@ exports.API = API;
2743
2705
  exports.APIClient = APIClient;
2744
2706
  exports.APIError = APIError;
2745
2707
  exports.APILogger = APILogger;
2708
+ exports.ActivityItem = ActivityItem;
2709
+ exports.ActivityList = ActivityList;
2710
+ exports.AddFundsSheet = AddFundsSheet;
2711
+ exports.BalanceHero = BalanceHero;
2746
2712
  exports.BalanceSchema = BalanceSchema;
2747
2713
  exports.CookieStorageAdapter = CookieStorageAdapter;
2748
2714
  exports.CurrencySchema = CurrencySchema;
@@ -2754,21 +2720,33 @@ exports.Fetchers = fetchers_exports;
2754
2720
  exports.LocalStorageAdapter = LocalStorageAdapter;
2755
2721
  exports.MemoryStorageAdapter = MemoryStorageAdapter;
2756
2722
  exports.NetworkError = NetworkError;
2757
- exports.PAYMENT_EVENTS = PAYMENT_EVENTS;
2758
2723
  exports.PaginatedPaymentListListSchema = PaginatedPaymentListListSchema;
2724
+ exports.PaginatedWithdrawalListListSchema = PaginatedWithdrawalListListSchema;
2725
+ exports.PaymentCreateRequestSchema = PaymentCreateRequestSchema;
2759
2726
  exports.PaymentDetailSchema = PaymentDetailSchema;
2760
2727
  exports.PaymentListSchema = PaymentListSchema;
2761
- exports.PaymentsLayout = PaymentsLayout;
2728
+ exports.PaymentSheet = PaymentSheet;
2762
2729
  exports.REFRESH_TOKEN_KEY = REFRESH_TOKEN_KEY;
2730
+ exports.ResponsiveSheet = ResponsiveSheet4;
2731
+ exports.ResponsiveSheetContent = ResponsiveSheetContent4;
2732
+ exports.ResponsiveSheetDescription = ResponsiveSheetDescription4;
2733
+ exports.ResponsiveSheetFooter = ResponsiveSheetFooter;
2734
+ exports.ResponsiveSheetHeader = ResponsiveSheetHeader4;
2735
+ exports.ResponsiveSheetTitle = ResponsiveSheetTitle4;
2763
2736
  exports.Schemas = schemas_exports;
2764
2737
  exports.TOKEN_KEY = TOKEN_KEY;
2765
2738
  exports.TransactionSchema = TransactionSchema;
2739
+ exports.WithdrawSheet = WithdrawSheet;
2740
+ exports.WithdrawalCreateRequestSchema = WithdrawalCreateRequestSchema;
2741
+ exports.WithdrawalDetailSchema = WithdrawalDetailSchema;
2742
+ exports.WithdrawalListSchema = WithdrawalListSchema;
2766
2743
  exports.apiPayments = apiPayments;
2767
2744
  exports.clearAPITokens = clearAPITokens;
2768
- exports.closePaymentsDialog = closePaymentsDialog;
2769
2745
  exports.configureAPI = configureAPI;
2770
2746
  exports.createPaymentsPaymentsConfirmCreate = createPaymentsPaymentsConfirmCreate;
2771
2747
  exports.createPaymentsPaymentsCreateCreate = createPaymentsPaymentsCreateCreate;
2748
+ exports.createPaymentsWithdrawalsCancelCreate = createPaymentsWithdrawalsCancelCreate;
2749
+ exports.createPaymentsWithdrawalsCreateCreate = createPaymentsWithdrawalsCreateCreate;
2772
2750
  exports.dispatchValidationError = dispatchValidationError;
2773
2751
  exports.extensionConfig = extensionConfig;
2774
2752
  exports.formatZodError = formatZodError;
@@ -2779,10 +2757,10 @@ exports.getPaymentsPaymentsList = getPaymentsPaymentsList;
2779
2757
  exports.getPaymentsPaymentsRetrieve = getPaymentsPaymentsRetrieve;
2780
2758
  exports.getPaymentsPaymentsStatusRetrieve = getPaymentsPaymentsStatusRetrieve;
2781
2759
  exports.getPaymentsTransactionsList = getPaymentsTransactionsList;
2760
+ exports.getPaymentsWithdrawalsList = getPaymentsWithdrawalsList;
2761
+ exports.getPaymentsWithdrawalsRetrieve = getPaymentsWithdrawalsRetrieve;
2782
2762
  exports.isAPIConfigured = isAPIConfigured;
2783
2763
  exports.onValidationError = onValidationError;
2784
- exports.openCreatePaymentDialog = openCreatePaymentDialog;
2785
- exports.openPaymentDetailsDialog = openPaymentDetailsDialog;
2786
2764
  exports.reconfigureAPI = reconfigureAPI;
2787
2765
  exports.resetAPI = resetAPI;
2788
2766
  exports.shouldRetry = shouldRetry;