@djangocfg/ext-payments 1.0.6 → 1.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config.cjs +3 -2
- package/dist/config.js +3 -2
- package/dist/hooks.cjs +559 -543
- package/dist/hooks.js +558 -543
- package/dist/index.cjs +559 -543
- package/dist/index.d.cts +0 -97
- package/dist/index.d.ts +0 -97
- package/dist/index.js +558 -543
- package/package.json +9 -8
- package/src/api/generated/ext_payments/CLAUDE.md +76 -0
- package/src/api/generated/ext_payments/_utils/fetchers/ext_payments__payments.ts +1 -8
- package/src/api/generated/ext_payments/_utils/fetchers/index.ts +1 -8
- package/src/api/generated/ext_payments/_utils/hooks/ext_payments__payments.ts +1 -8
- package/src/api/generated/ext_payments/_utils/hooks/index.ts +1 -8
- package/src/api/generated/ext_payments/_utils/schemas/index.ts +1 -8
- package/src/api/generated/ext_payments/api-instance.ts +1 -8
- package/src/api/generated/ext_payments/enums.ts +1 -8
- package/src/api/generated/ext_payments/errors.ts +1 -8
- package/src/api/generated/ext_payments/ext_payments__payments/index.ts +1 -8
- package/src/api/generated/ext_payments/ext_payments__payments/models.ts +1 -8
- package/src/api/generated/ext_payments/http.ts +1 -8
- package/src/api/generated/ext_payments/index.ts +1 -8
- package/src/api/generated/ext_payments/logger.ts +1 -8
- package/src/api/generated/ext_payments/retry.ts +1 -8
- package/src/api/generated/ext_payments/storage.ts +1 -8
- package/src/api/generated/ext_payments/validation-events.ts +1 -8
- package/src/api/index.ts +2 -1
- package/src/config.ts +1 -0
- package/src/contexts/BalancesContext.tsx +2 -1
- package/src/contexts/CurrenciesContext.tsx +2 -1
- package/src/contexts/OverviewContext.tsx +5 -5
- package/src/contexts/PaymentsContext.tsx +6 -5
- package/src/contexts/PaymentsExtensionProvider.tsx +3 -2
- package/src/contexts/RootPaymentsContext.tsx +2 -1
- package/src/layouts/PaymentsLayout/PaymentsLayout.tsx +5 -7
- package/src/layouts/PaymentsLayout/components/CreatePaymentDialog.tsx +10 -27
- package/src/layouts/PaymentsLayout/components/PaymentDetailsDialog.tsx +15 -18
- package/src/layouts/PaymentsLayout/views/overview/components/BalanceCard.tsx +6 -13
- package/src/layouts/PaymentsLayout/views/overview/components/RecentPayments.tsx +8 -11
- package/src/layouts/PaymentsLayout/views/overview/index.tsx +1 -0
- package/src/layouts/PaymentsLayout/views/payments/components/PaymentsList.tsx +43 -42
- package/src/layouts/PaymentsLayout/views/payments/index.tsx +1 -0
- package/src/layouts/PaymentsLayout/views/transactions/components/TransactionsList.tsx +71 -84
- package/src/layouts/PaymentsLayout/views/transactions/index.tsx +1 -0
|
@@ -5,31 +5,16 @@
|
|
|
5
5
|
|
|
6
6
|
'use client';
|
|
7
7
|
|
|
8
|
+
import { ExternalLink, Filter, Plus, RefreshCw, Search } from 'lucide-react';
|
|
9
|
+
import moment from 'moment';
|
|
8
10
|
import React, { useState } from 'react';
|
|
11
|
+
|
|
9
12
|
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
CardTitle,
|
|
14
|
-
Table,
|
|
15
|
-
TableBody,
|
|
16
|
-
TableCell,
|
|
17
|
-
TableHead,
|
|
18
|
-
TableHeader,
|
|
19
|
-
TableRow,
|
|
20
|
-
Button,
|
|
21
|
-
Badge,
|
|
22
|
-
Input,
|
|
23
|
-
Select,
|
|
24
|
-
SelectContent,
|
|
25
|
-
SelectItem,
|
|
26
|
-
SelectTrigger,
|
|
27
|
-
SelectValue,
|
|
28
|
-
Skeleton,
|
|
29
|
-
useDRFPagination,
|
|
30
|
-
StaticPagination,
|
|
13
|
+
Badge, Button, Card, CardContent, CardHeader, CardTitle, Input, Select, SelectContent,
|
|
14
|
+
SelectItem, SelectTrigger, SelectValue, Skeleton, StaticPagination, Table, TableBody, TableCell,
|
|
15
|
+
TableHead, TableHeader, TableRow, useDRFPagination
|
|
31
16
|
} from '@djangocfg/ui-nextjs';
|
|
32
|
-
|
|
17
|
+
|
|
33
18
|
import { apiPayments } from '../../../../../api';
|
|
34
19
|
import { usePaymentsPaymentsList } from '../../../../../api/generated/ext_payments/_utils/hooks';
|
|
35
20
|
import { openCreatePaymentDialog, openPaymentDetailsDialog } from '../../../events';
|
|
@@ -65,9 +50,9 @@ export const PaymentsList: React.FC = () => {
|
|
|
65
50
|
const getRelativeTime = (date: string | null | undefined): string => {
|
|
66
51
|
if (!date) return 'N/A';
|
|
67
52
|
|
|
68
|
-
const
|
|
69
|
-
const
|
|
70
|
-
const diffInSeconds =
|
|
53
|
+
const m = moment.utc(date).local();
|
|
54
|
+
const now = moment();
|
|
55
|
+
const diffInSeconds = now.diff(m, 'seconds');
|
|
71
56
|
|
|
72
57
|
if (diffInSeconds < 60) return 'Just now';
|
|
73
58
|
if (diffInSeconds < 3600) return `${Math.floor(diffInSeconds / 60)}m ago`;
|
|
@@ -75,6 +60,11 @@ export const PaymentsList: React.FC = () => {
|
|
|
75
60
|
return `${Math.floor(diffInSeconds / 86400)}d ago`;
|
|
76
61
|
};
|
|
77
62
|
|
|
63
|
+
const formatDate = (date: string | null | undefined): string => {
|
|
64
|
+
if (!date) return 'N/A';
|
|
65
|
+
return moment.utc(date).local().format('MMM D, YYYY');
|
|
66
|
+
};
|
|
67
|
+
|
|
78
68
|
const getStatusVariant = (
|
|
79
69
|
status: string | null | undefined
|
|
80
70
|
): 'default' | 'destructive' | 'outline' | 'secondary' => {
|
|
@@ -104,21 +94,34 @@ export const PaymentsList: React.FC = () => {
|
|
|
104
94
|
// Client-side filtering only
|
|
105
95
|
};
|
|
106
96
|
|
|
97
|
+
// Helper to truncate ID
|
|
98
|
+
const truncateId = (id: string | number | null | undefined): string => {
|
|
99
|
+
if (!id) return 'N/A';
|
|
100
|
+
const str = id.toString();
|
|
101
|
+
return str.length > 8 ? `${str.slice(0, 8)}...` : str;
|
|
102
|
+
};
|
|
107
103
|
|
|
108
|
-
// Filter
|
|
109
|
-
const filteredPayments = paymentsList
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
payment.
|
|
113
|
-
|
|
114
|
-
|
|
104
|
+
// Filter and prepare payments with pre-computed fields
|
|
105
|
+
const filteredPayments = paymentsList
|
|
106
|
+
.filter((payment) => {
|
|
107
|
+
const matchesSearch = searchTerm
|
|
108
|
+
? payment.id?.toLowerCase().includes(searchTerm.toLowerCase()) ||
|
|
109
|
+
payment.status?.toLowerCase().includes(searchTerm.toLowerCase()) ||
|
|
110
|
+
payment.currency_code?.toLowerCase().includes(searchTerm.toLowerCase())
|
|
111
|
+
: true;
|
|
115
112
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
113
|
+
const matchesStatus = statusFilter !== 'all'
|
|
114
|
+
? payment.status?.toLowerCase() === statusFilter.toLowerCase()
|
|
115
|
+
: true;
|
|
119
116
|
|
|
120
|
-
|
|
121
|
-
|
|
117
|
+
return matchesSearch && matchesStatus;
|
|
118
|
+
})
|
|
119
|
+
.map((payment) => ({
|
|
120
|
+
...payment,
|
|
121
|
+
formattedDate: formatDate(payment.created_at),
|
|
122
|
+
relativeTime: getRelativeTime(payment.created_at),
|
|
123
|
+
truncatedId: truncateId(payment.id),
|
|
124
|
+
}));
|
|
122
125
|
|
|
123
126
|
return (
|
|
124
127
|
<Card>
|
|
@@ -221,12 +224,10 @@ export const PaymentsList: React.FC = () => {
|
|
|
221
224
|
<TableCell>
|
|
222
225
|
<div>
|
|
223
226
|
<div className="font-medium">
|
|
224
|
-
{payment.
|
|
225
|
-
? new Date(payment.created_at).toLocaleDateString()
|
|
226
|
-
: 'N/A'}
|
|
227
|
+
{payment.formattedDate}
|
|
227
228
|
</div>
|
|
228
229
|
<div className="text-sm text-muted-foreground">
|
|
229
|
-
{
|
|
230
|
+
{payment.relativeTime}
|
|
230
231
|
</div>
|
|
231
232
|
</div>
|
|
232
233
|
</TableCell>
|
|
@@ -243,7 +244,7 @@ export const PaymentsList: React.FC = () => {
|
|
|
243
244
|
NowPayments
|
|
244
245
|
</TableCell>
|
|
245
246
|
<TableCell className="font-mono text-sm text-muted-foreground">
|
|
246
|
-
{payment.
|
|
247
|
+
{payment.truncatedId}
|
|
247
248
|
</TableCell>
|
|
248
249
|
<TableCell className="text-right">
|
|
249
250
|
<Button
|
|
@@ -5,29 +5,16 @@
|
|
|
5
5
|
|
|
6
6
|
'use client';
|
|
7
7
|
|
|
8
|
+
import { ArrowDownLeft, ArrowUpRight, Filter, History, RefreshCw, Search } from 'lucide-react';
|
|
9
|
+
import moment from 'moment';
|
|
8
10
|
import React, { useState } from 'react';
|
|
11
|
+
|
|
9
12
|
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
CardTitle,
|
|
14
|
-
Table,
|
|
15
|
-
TableBody,
|
|
16
|
-
TableCell,
|
|
17
|
-
TableHead,
|
|
18
|
-
TableHeader,
|
|
19
|
-
TableRow,
|
|
20
|
-
Button,
|
|
21
|
-
Badge,
|
|
22
|
-
Input,
|
|
23
|
-
Select,
|
|
24
|
-
SelectContent,
|
|
25
|
-
SelectItem,
|
|
26
|
-
SelectTrigger,
|
|
27
|
-
SelectValue,
|
|
28
|
-
Skeleton,
|
|
13
|
+
Badge, Button, Card, CardContent, CardHeader, CardTitle, Input, Select, SelectContent,
|
|
14
|
+
SelectItem, SelectTrigger, SelectValue, Skeleton, Table, TableBody, TableCell, TableHead,
|
|
15
|
+
TableHeader, TableRow
|
|
29
16
|
} from '@djangocfg/ui-nextjs';
|
|
30
|
-
|
|
17
|
+
|
|
31
18
|
import { useOverviewContext } from '../../../../../contexts';
|
|
32
19
|
|
|
33
20
|
export const TransactionsList: React.FC = () => {
|
|
@@ -55,13 +42,7 @@ export const TransactionsList: React.FC = () => {
|
|
|
55
42
|
const formatDate = (date: string | null | undefined): string => {
|
|
56
43
|
if (!date) return 'N/A';
|
|
57
44
|
try {
|
|
58
|
-
return
|
|
59
|
-
year: 'numeric',
|
|
60
|
-
month: 'short',
|
|
61
|
-
day: 'numeric',
|
|
62
|
-
hour: '2-digit',
|
|
63
|
-
minute: '2-digit',
|
|
64
|
-
});
|
|
45
|
+
return moment.utc(date).local().format('MMM D, YYYY hh:mm A');
|
|
65
46
|
} catch {
|
|
66
47
|
return 'Invalid date';
|
|
67
48
|
}
|
|
@@ -70,9 +51,9 @@ export const TransactionsList: React.FC = () => {
|
|
|
70
51
|
const getRelativeTime = (date: string | null | undefined): string => {
|
|
71
52
|
if (!date) return 'N/A';
|
|
72
53
|
|
|
73
|
-
const
|
|
74
|
-
const
|
|
75
|
-
const diffInSeconds =
|
|
54
|
+
const m = moment.utc(date).local();
|
|
55
|
+
const now = moment();
|
|
56
|
+
const diffInSeconds = now.diff(m, 'seconds');
|
|
76
57
|
|
|
77
58
|
if (diffInSeconds < 60) return 'Just now';
|
|
78
59
|
if (diffInSeconds < 3600) return `${Math.floor(diffInSeconds / 60)}m ago`;
|
|
@@ -114,20 +95,35 @@ export const TransactionsList: React.FC = () => {
|
|
|
114
95
|
await refreshTransactions();
|
|
115
96
|
};
|
|
116
97
|
|
|
117
|
-
//
|
|
118
|
-
const
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
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;
|
|
124
113
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
114
|
+
const matchesType = typeFilter !== 'all'
|
|
115
|
+
? transaction.type?.toLowerCase() === typeFilter.toLowerCase()
|
|
116
|
+
: true;
|
|
128
117
|
|
|
129
|
-
|
|
130
|
-
|
|
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
|
+
}));
|
|
131
127
|
|
|
132
128
|
if (isLoadingTransactions) {
|
|
133
129
|
return (
|
|
@@ -221,48 +217,39 @@ export const TransactionsList: React.FC = () => {
|
|
|
221
217
|
</TableRow>
|
|
222
218
|
</TableHeader>
|
|
223
219
|
<TableBody>
|
|
224
|
-
{filteredTransactions.map((transaction: any, index: number) =>
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
<div>
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
</TableCell>
|
|
258
|
-
<TableCell className="font-mono text-sm text-muted-foreground">
|
|
259
|
-
{transaction.reference || transaction.payment_id
|
|
260
|
-
? `${(transaction.reference || transaction.payment_id).toString().slice(0, 8)}...`
|
|
261
|
-
: 'N/A'}
|
|
262
|
-
</TableCell>
|
|
263
|
-
</TableRow>
|
|
264
|
-
);
|
|
265
|
-
})}
|
|
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
|
+
))}
|
|
266
253
|
</TableBody>
|
|
267
254
|
</Table>
|
|
268
255
|
</div>
|