@djangocfg/ext-payments 1.0.14 → 1.0.19

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 (76) hide show
  1. package/dist/config.cjs +5 -8
  2. package/dist/config.js +5 -8
  3. package/dist/index.cjs +1906 -1043
  4. package/dist/index.d.cts +644 -59
  5. package/dist/index.d.ts +644 -59
  6. package/dist/index.js +1886 -1040
  7. package/package.json +13 -16
  8. package/src/WalletPage.tsx +100 -0
  9. package/src/api/generated/ext_payments/CLAUDE.md +10 -4
  10. package/src/api/generated/ext_payments/_utils/fetchers/ext_payments__payments.ts +268 -5
  11. package/src/api/generated/ext_payments/_utils/hooks/ext_payments__payments.ts +102 -3
  12. package/src/api/generated/ext_payments/_utils/schemas/Balance.schema.ts +1 -1
  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/PaymentCreateResponse.schema.ts +22 -0
  16. package/src/api/generated/ext_payments/_utils/schemas/PaymentDetail.schema.ts +3 -3
  17. package/src/api/generated/ext_payments/_utils/schemas/PaymentList.schema.ts +2 -2
  18. package/src/api/generated/ext_payments/_utils/schemas/Transaction.schema.ts +1 -1
  19. package/src/api/generated/ext_payments/_utils/schemas/WithdrawalCancelResponse.schema.ts +22 -0
  20. package/src/api/generated/ext_payments/_utils/schemas/WithdrawalCreateRequest.schema.ts +21 -0
  21. package/src/api/generated/ext_payments/_utils/schemas/WithdrawalCreateResponse.schema.ts +22 -0
  22. package/src/api/generated/ext_payments/_utils/schemas/WithdrawalDetail.schema.ts +42 -0
  23. package/src/api/generated/ext_payments/_utils/schemas/WithdrawalList.schema.ts +29 -0
  24. package/src/api/generated/ext_payments/_utils/schemas/index.ts +8 -0
  25. package/src/api/generated/ext_payments/client.ts +1 -1
  26. package/src/api/generated/ext_payments/enums.ts +36 -0
  27. package/src/api/generated/ext_payments/ext_payments__payments/client.ts +104 -6
  28. package/src/api/generated/ext_payments/ext_payments__payments/models.ts +168 -8
  29. package/src/api/generated/ext_payments/index.ts +1 -1
  30. package/src/api/generated/ext_payments/schema.json +752 -42
  31. package/src/components/ActivityItem.tsx +118 -0
  32. package/src/components/ActivityList.tsx +93 -0
  33. package/src/components/AddFundsSheet.tsx +342 -0
  34. package/src/components/BalanceHero.tsx +102 -0
  35. package/src/components/CurrencyCombobox.tsx +49 -0
  36. package/src/components/PaymentSheet.tsx +352 -0
  37. package/src/components/WithdrawSheet.tsx +355 -0
  38. package/src/components/WithdrawalSheet.tsx +332 -0
  39. package/src/components/index.ts +11 -0
  40. package/src/config.ts +1 -0
  41. package/src/contexts/WalletContext.tsx +356 -0
  42. package/src/contexts/index.ts +13 -42
  43. package/src/contexts/types.ts +43 -37
  44. package/src/hooks/index.ts +3 -20
  45. package/src/hooks/useCurrencyOptions.ts +79 -0
  46. package/src/hooks/useEstimate.ts +113 -0
  47. package/src/hooks/useWithdrawalEstimate.ts +117 -0
  48. package/src/index.ts +9 -18
  49. package/src/types/index.ts +78 -0
  50. package/src/utils/errors.ts +36 -0
  51. package/src/utils/format.ts +65 -0
  52. package/src/utils/index.ts +3 -0
  53. package/src/contexts/BalancesContext.tsx +0 -63
  54. package/src/contexts/CurrenciesContext.tsx +0 -64
  55. package/src/contexts/OverviewContext.tsx +0 -173
  56. package/src/contexts/PaymentsContext.tsx +0 -122
  57. package/src/contexts/PaymentsExtensionProvider.tsx +0 -56
  58. package/src/contexts/README.md +0 -201
  59. package/src/contexts/RootPaymentsContext.tsx +0 -66
  60. package/src/layouts/PaymentsLayout/PaymentsLayout.tsx +0 -90
  61. package/src/layouts/PaymentsLayout/components/CreatePaymentDialog.tsx +0 -274
  62. package/src/layouts/PaymentsLayout/components/PaymentDetailsDialog.tsx +0 -287
  63. package/src/layouts/PaymentsLayout/components/index.ts +0 -2
  64. package/src/layouts/PaymentsLayout/events.ts +0 -47
  65. package/src/layouts/PaymentsLayout/index.ts +0 -16
  66. package/src/layouts/PaymentsLayout/types.ts +0 -6
  67. package/src/layouts/PaymentsLayout/views/overview/components/BalanceCard.tsx +0 -121
  68. package/src/layouts/PaymentsLayout/views/overview/components/RecentPayments.tsx +0 -139
  69. package/src/layouts/PaymentsLayout/views/overview/components/index.ts +0 -2
  70. package/src/layouts/PaymentsLayout/views/overview/index.tsx +0 -21
  71. package/src/layouts/PaymentsLayout/views/payments/components/PaymentsList.tsx +0 -279
  72. package/src/layouts/PaymentsLayout/views/payments/components/index.ts +0 -1
  73. package/src/layouts/PaymentsLayout/views/payments/index.tsx +0 -18
  74. package/src/layouts/PaymentsLayout/views/transactions/components/TransactionsList.tsx +0 -260
  75. package/src/layouts/PaymentsLayout/views/transactions/components/index.ts +0 -1
  76. package/src/layouts/PaymentsLayout/views/transactions/index.tsx +0 -18
@@ -1,260 +0,0 @@
1
- /**
2
- * Transactions List Component (v2.0 - Simplified)
3
- * Display transaction history with balance changes
4
- */
5
-
6
- 'use client';
7
-
8
- import { ArrowDownLeft, ArrowUpRight, Filter, History, RefreshCw, Search } from 'lucide-react';
9
- import moment from 'moment';
10
- import React, { useState } from 'react';
11
-
12
- import {
13
- Badge, Button, Card, CardContent, CardHeader, CardTitle, Input, Select, SelectContent,
14
- SelectItem, SelectTrigger, SelectValue, Skeleton, Table, TableBody, TableCell, TableHead,
15
- TableHeader, TableRow
16
- } from '@djangocfg/ui-core';
17
-
18
- import { useOverviewContext } from '../../../../../contexts';
19
-
20
- export const TransactionsList: React.FC = () => {
21
- const {
22
- transactions,
23
- isLoadingTransactions,
24
- refreshTransactions,
25
- } = useOverviewContext();
26
-
27
- const [searchTerm, setSearchTerm] = useState('');
28
- const [typeFilter, setTypeFilter] = useState<string>('all');
29
-
30
- // Extract transactions array from response (handle different possible structures)
31
- const transactionsList = transactions?.results || transactions?.transactions || [];
32
-
33
- const formatCurrency = (amount?: number | null) => {
34
- if (amount === null || amount === undefined) return '$0.00';
35
- return new Intl.NumberFormat('en-US', {
36
- style: 'currency',
37
- currency: 'USD',
38
- minimumFractionDigits: 2,
39
- }).format(amount);
40
- };
41
-
42
- const formatDate = (date: string | null | undefined): string => {
43
- if (!date) return 'N/A';
44
- try {
45
- return moment.utc(date).local().format('MMM D, YYYY hh:mm A');
46
- } catch {
47
- return 'Invalid date';
48
- }
49
- };
50
-
51
- const getRelativeTime = (date: string | null | undefined): string => {
52
- if (!date) return 'N/A';
53
-
54
- const m = moment.utc(date).local();
55
- const now = moment();
56
- const diffInSeconds = now.diff(m, 'seconds');
57
-
58
- if (diffInSeconds < 60) return 'Just now';
59
- if (diffInSeconds < 3600) return `${Math.floor(diffInSeconds / 60)}m ago`;
60
- if (diffInSeconds < 86400) return `${Math.floor(diffInSeconds / 3600)}h ago`;
61
- return `${Math.floor(diffInSeconds / 86400)}d ago`;
62
- };
63
-
64
- const getTypeVariant = (
65
- type: string | null | undefined
66
- ): 'default' | 'destructive' | 'outline' | 'secondary' => {
67
- switch (type?.toLowerCase()) {
68
- case 'deposit':
69
- case 'credit':
70
- return 'default';
71
- case 'withdrawal':
72
- case 'debit':
73
- return 'destructive';
74
- default:
75
- return 'outline';
76
- }
77
- };
78
-
79
- const getTypeIcon = (type: string | null | undefined) => {
80
- const isDeposit = type?.toLowerCase() === 'deposit' || type?.toLowerCase() === 'credit';
81
- return isDeposit ? (
82
- <ArrowDownLeft className="h-4 w-4 text-green-600" />
83
- ) : (
84
- <ArrowUpRight className="h-4 w-4 text-red-600" />
85
- );
86
- };
87
-
88
- const handleSearch = async (value: string) => {
89
- setSearchTerm(value);
90
- await refreshTransactions();
91
- };
92
-
93
- const handleTypeFilter = async (type: string) => {
94
- setTypeFilter(type);
95
- await refreshTransactions();
96
- };
97
-
98
- // Helper to truncate ID
99
- const truncateId = (id: string | number | null | undefined): string => {
100
- if (!id) return 'N/A';
101
- const str = id.toString();
102
- return str.length > 8 ? `${str.slice(0, 8)}...` : str;
103
- };
104
-
105
- // Filter and prepare transactions
106
- const filteredTransactions = transactionsList
107
- .filter((transaction: any) => {
108
- const matchesSearch = searchTerm
109
- ? transaction.id?.toString().toLowerCase().includes(searchTerm.toLowerCase()) ||
110
- transaction.description?.toLowerCase().includes(searchTerm.toLowerCase()) ||
111
- transaction.type?.toLowerCase().includes(searchTerm.toLowerCase())
112
- : true;
113
-
114
- const matchesType = typeFilter !== 'all'
115
- ? transaction.type?.toLowerCase() === typeFilter.toLowerCase()
116
- : true;
117
-
118
- return matchesSearch && matchesType;
119
- })
120
- .map((transaction: any) => ({
121
- ...transaction,
122
- isDeposit: transaction.type?.toLowerCase() === 'deposit' || transaction.type?.toLowerCase() === 'credit',
123
- formattedDate: formatDate(transaction.created_at || transaction.timestamp),
124
- relativeTime: getRelativeTime(transaction.created_at || transaction.timestamp),
125
- truncatedRef: truncateId(transaction.reference || transaction.payment_id),
126
- }));
127
-
128
- if (isLoadingTransactions) {
129
- return (
130
- <Card>
131
- <CardHeader>
132
- <CardTitle className="flex items-center gap-2">
133
- <History className="h-5 w-5" />
134
- Transaction History
135
- </CardTitle>
136
- </CardHeader>
137
- <CardContent className="space-y-3">
138
- {Array.from({ length: 5 }).map((_, i) => (
139
- <div key={i} className="flex items-center justify-between p-4 border rounded-sm">
140
- <div className="space-y-2">
141
- <Skeleton className="h-4 w-32" />
142
- <Skeleton className="h-3 w-24" />
143
- </div>
144
- <Skeleton className="h-6 w-16" />
145
- </div>
146
- ))}
147
- </CardContent>
148
- </Card>
149
- );
150
- }
151
-
152
- return (
153
- <Card>
154
- <CardHeader>
155
- <CardTitle className="flex items-center justify-between">
156
- <div className="flex items-center gap-2">
157
- <History className="h-5 w-5" />
158
- Transaction History
159
- </div>
160
- <Button variant="outline" size="sm" onClick={refreshTransactions} disabled={isLoadingTransactions}>
161
- <RefreshCw className={`h-4 w-4 mr-2 ${isLoadingTransactions ? 'animate-spin' : ''}`} />
162
- Refresh
163
- </Button>
164
- </CardTitle>
165
- </CardHeader>
166
-
167
- <CardContent className="space-y-4">
168
- {/* Filters */}
169
- <div className="flex flex-col sm:flex-row gap-4">
170
- <div className="relative flex-1">
171
- <Search className="absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground" />
172
- <Input
173
- placeholder="Search by ID, description, or type..."
174
- value={searchTerm}
175
- onChange={(e) => handleSearch(e.target.value)}
176
- className="pl-10"
177
- />
178
- </div>
179
-
180
- <Select value={typeFilter} onValueChange={handleTypeFilter}>
181
- <SelectTrigger className="w-full sm:w-48">
182
- <Filter className="h-4 w-4 mr-2" />
183
- <SelectValue placeholder="Filter by type" />
184
- </SelectTrigger>
185
- <SelectContent>
186
- <SelectItem value="all">All Types</SelectItem>
187
- <SelectItem value="deposit">Deposits</SelectItem>
188
- <SelectItem value="withdrawal">Withdrawals</SelectItem>
189
- </SelectContent>
190
- </Select>
191
- </div>
192
-
193
- {/* Transactions Table */}
194
- {filteredTransactions.length === 0 ? (
195
- <div className="text-center py-12">
196
- <div className="w-16 h-16 mx-auto mb-4 bg-muted rounded-full flex items-center justify-center">
197
- <History className="w-8 h-8 text-muted-foreground" />
198
- </div>
199
- <h3 className="text-lg font-semibold mb-2">No Transactions Found</h3>
200
- <p className="text-muted-foreground">
201
- {searchTerm || typeFilter !== 'all'
202
- ? 'No transactions match your current filters'
203
- : "You don't have any transactions yet"}
204
- </p>
205
- </div>
206
- ) : (
207
- <div className="rounded-md border">
208
- <Table>
209
- <TableHeader>
210
- <TableRow>
211
- <TableHead>Date & Time</TableHead>
212
- <TableHead>Type</TableHead>
213
- <TableHead>Amount</TableHead>
214
- <TableHead>Balance After</TableHead>
215
- <TableHead>Description</TableHead>
216
- <TableHead>Reference</TableHead>
217
- </TableRow>
218
- </TableHeader>
219
- <TableBody>
220
- {filteredTransactions.map((transaction: any, index: number) => (
221
- <TableRow key={transaction.id || index}>
222
- <TableCell>
223
- <div>
224
- <div className="font-medium">{transaction.formattedDate}</div>
225
- <div className="text-sm text-muted-foreground">{transaction.relativeTime}</div>
226
- </div>
227
- </TableCell>
228
- <TableCell>
229
- <div className="flex items-center gap-2">
230
- {getTypeIcon(transaction.type)}
231
- <Badge variant={getTypeVariant(transaction.type)}>
232
- {transaction.type || 'Unknown'}
233
- </Badge>
234
- </div>
235
- </TableCell>
236
- <TableCell className="font-mono font-semibold">
237
- <span className={transaction.isDeposit ? 'text-green-600' : 'text-red-600'}>
238
- {transaction.isDeposit ? '+' : '-'}
239
- {formatCurrency(Math.abs(transaction.amount || transaction.amount_usd || 0))}
240
- </span>
241
- </TableCell>
242
- <TableCell className="font-mono">
243
- {formatCurrency(transaction.balance_after || 0)}
244
- </TableCell>
245
- <TableCell className="text-sm">
246
- {transaction.description || transaction.note || 'No description'}
247
- </TableCell>
248
- <TableCell className="font-mono text-sm text-muted-foreground">
249
- {transaction.truncatedRef}
250
- </TableCell>
251
- </TableRow>
252
- ))}
253
- </TableBody>
254
- </Table>
255
- </div>
256
- )}
257
- </CardContent>
258
- </Card>
259
- );
260
- };
@@ -1 +0,0 @@
1
- export { TransactionsList } from './TransactionsList';
@@ -1,18 +0,0 @@
1
- /**
2
- * Transactions View (v2.0 - Simplified)
3
- * View transaction history and balance changes
4
- */
5
-
6
- 'use client';
7
-
8
- import React from 'react';
9
-
10
- import { TransactionsList } from './components';
11
-
12
- export const TransactionsView: React.FC = () => {
13
- return (
14
- <div className="space-y-6">
15
- <TransactionsList />
16
- </div>
17
- );
18
- };