@djangocfg/layouts 2.0.4 → 2.0.6

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 (64) hide show
  1. package/README.md +138 -20
  2. package/package.json +20 -5
  3. package/src/components/RedirectPage/RedirectPage.tsx +70 -0
  4. package/src/components/RedirectPage/index.ts +7 -0
  5. package/src/components/core/index.ts +10 -0
  6. package/src/components/errors/ErrorLayout.tsx +228 -0
  7. package/src/components/errors/errorConfig.ts +118 -0
  8. package/src/components/errors/index.ts +10 -0
  9. package/src/components/index.ts +13 -5
  10. package/src/contexts/LeadsContext.tsx +156 -0
  11. package/src/contexts/NewsletterContext.tsx +263 -0
  12. package/src/contexts/SupportContext.tsx +256 -0
  13. package/src/contexts/index.ts +59 -0
  14. package/src/contexts/knowbase/ChatContext.tsx +174 -0
  15. package/src/contexts/knowbase/DocumentsContext.tsx +304 -0
  16. package/src/contexts/knowbase/SessionsContext.tsx +174 -0
  17. package/src/contexts/knowbase/index.ts +61 -0
  18. package/src/contexts/payments/BalancesContext.tsx +65 -0
  19. package/src/contexts/payments/CurrenciesContext.tsx +66 -0
  20. package/src/contexts/payments/OverviewContext.tsx +174 -0
  21. package/src/contexts/payments/PaymentsContext.tsx +132 -0
  22. package/src/contexts/payments/README.md +201 -0
  23. package/src/contexts/payments/RootPaymentsContext.tsx +68 -0
  24. package/src/contexts/payments/index.ts +50 -0
  25. package/src/index.ts +8 -0
  26. package/src/layouts/AppLayout/AppLayout.tsx +24 -14
  27. package/src/layouts/PaymentsLayout/PaymentsLayout.tsx +1 -1
  28. package/src/layouts/PaymentsLayout/components/CreatePaymentDialog.tsx +1 -1
  29. package/src/layouts/PaymentsLayout/views/overview/components/BalanceCard.tsx +1 -1
  30. package/src/layouts/PaymentsLayout/views/overview/components/RecentPayments.tsx +1 -1
  31. package/src/layouts/PaymentsLayout/views/transactions/components/TransactionsList.tsx +1 -1
  32. package/src/layouts/ProfileLayout/components/ProfileForm.tsx +1 -1
  33. package/src/layouts/SupportLayout/SupportLayout.tsx +1 -1
  34. package/src/layouts/SupportLayout/components/TicketCard.tsx +1 -1
  35. package/src/layouts/SupportLayout/context/SupportLayoutContext.tsx +1 -1
  36. package/src/layouts/SupportLayout/index.ts +2 -0
  37. package/src/layouts/SupportLayout/types.ts +2 -4
  38. package/src/pages/index.ts +6 -0
  39. package/src/pages/legal/LegalPage.tsx +85 -0
  40. package/src/pages/legal/configs.ts +131 -0
  41. package/src/pages/legal/index.ts +24 -0
  42. package/src/pages/legal/pages.tsx +58 -0
  43. package/src/pages/legal/types.ts +15 -0
  44. package/src/snippets/Chat/ChatWidget.tsx +1 -1
  45. package/src/snippets/Chat/components/SessionList.tsx +1 -1
  46. package/src/snippets/Chat/index.tsx +1 -1
  47. package/src/snippets/Chat/types.ts +7 -5
  48. package/src/snippets/ContactForm/ContactForm.tsx +20 -8
  49. package/src/utils/index.ts +1 -0
  50. package/src/utils/og-image.ts +169 -0
  51. /package/src/components/{JsonLd.tsx → core/JsonLd.tsx} +0 -0
  52. /package/src/components/{LucideIcon.tsx → core/LucideIcon.tsx} +0 -0
  53. /package/src/components/{PageProgress.tsx → core/PageProgress.tsx} +0 -0
  54. /package/src/components/{Suspense.tsx → core/Suspense.tsx} +0 -0
  55. /package/src/components/{ErrorBoundary.tsx → errors/ErrorBoundary.tsx} +0 -0
  56. /package/src/components/{ErrorsTracker → errors/ErrorsTracker}/README.md +0 -0
  57. /package/src/components/{ErrorsTracker → errors/ErrorsTracker}/components/ErrorButtons.tsx +0 -0
  58. /package/src/components/{ErrorsTracker → errors/ErrorsTracker}/components/ErrorToast.tsx +0 -0
  59. /package/src/components/{ErrorsTracker → errors/ErrorsTracker}/hooks.ts +0 -0
  60. /package/src/components/{ErrorsTracker → errors/ErrorsTracker}/index.ts +0 -0
  61. /package/src/components/{ErrorsTracker → errors/ErrorsTracker}/providers/ErrorTrackingProvider.tsx +0 -0
  62. /package/src/components/{ErrorsTracker → errors/ErrorsTracker}/types.ts +0 -0
  63. /package/src/components/{ErrorsTracker → errors/ErrorsTracker}/utils/curl-generator.ts +0 -0
  64. /package/src/components/{ErrorsTracker → errors/ErrorsTracker}/utils/formatters.ts +0 -0
@@ -0,0 +1,174 @@
1
+ 'use client';
2
+
3
+ import React, { createContext, useContext, type ReactNode } from 'react';
4
+ import { SWRConfig } from 'swr';
5
+ import { api } from '@djangocfg/api';
6
+ import {
7
+ usePaymentsBalanceRetrieve,
8
+ usePaymentsPaymentsList,
9
+ usePaymentsTransactionsList,
10
+ useCreatePaymentsPaymentsCreateCreate,
11
+ } from '@djangocfg/api';
12
+ import type { API } from '@djangocfg/api';
13
+ import type {
14
+ PaginatedPaymentListList,
15
+ PaymentList,
16
+ } from '@djangocfg/api';
17
+
18
+ // ─────────────────────────────────────────────────────────────────────────
19
+ // Context Type
20
+ // ─────────────────────────────────────────────────────────────────────────
21
+
22
+ export interface OverviewContextValue {
23
+ // Balance data
24
+ balance: any | undefined;
25
+ isLoadingBalance: boolean;
26
+ balanceError: Error | undefined;
27
+ refreshBalance: () => Promise<void>;
28
+
29
+ // Payments data
30
+ payments: PaginatedPaymentListList | undefined;
31
+ isLoadingPayments: boolean;
32
+ paymentsError: Error | undefined;
33
+ refreshPayments: () => Promise<void>;
34
+
35
+ // Transactions data
36
+ transactions: any | undefined;
37
+ isLoadingTransactions: boolean;
38
+ transactionsError: Error | undefined;
39
+ refreshTransactions: () => Promise<void>;
40
+
41
+ // Payment operations
42
+ createPayment: () => Promise<PaymentList>;
43
+
44
+ // Loading states
45
+ isLoadingOverview: boolean;
46
+ overviewError: Error | undefined;
47
+
48
+ // Operations
49
+ refreshOverview: () => Promise<void>;
50
+ }
51
+
52
+ // ─────────────────────────────────────────────────────────────────────────
53
+ // Context
54
+ // ─────────────────────────────────────────────────────────────────────────
55
+
56
+ const OverviewContext = createContext<OverviewContextValue | undefined>(undefined);
57
+
58
+ // ─────────────────────────────────────────────────────────────────────────
59
+ // Provider
60
+ // ─────────────────────────────────────────────────────────────────────────
61
+
62
+ export function OverviewProvider({ children }: { children: ReactNode }) {
63
+ // SWR config for overview data - disable auto-revalidation
64
+ const swrConfig = {
65
+ revalidateOnFocus: false,
66
+ revalidateOnReconnect: false,
67
+ revalidateIfStale: false,
68
+ };
69
+
70
+ // Balance
71
+ const {
72
+ data: balance,
73
+ error: balanceError,
74
+ isLoading: isLoadingBalance,
75
+ mutate: mutateBalance,
76
+ } = usePaymentsBalanceRetrieve(api as unknown as API);
77
+
78
+ // Payments list
79
+ const {
80
+ data: payments,
81
+ error: paymentsError,
82
+ isLoading: isLoadingPayments,
83
+ mutate: mutatePayments,
84
+ } = usePaymentsPaymentsList({}, api as unknown as API);
85
+
86
+ // Transactions
87
+ const {
88
+ data: transactions,
89
+ error: transactionsError,
90
+ isLoading: isLoadingTransactions,
91
+ mutate: mutateTransactions,
92
+ } = usePaymentsTransactionsList({}, api as unknown as API);
93
+
94
+ // Payment mutations
95
+ const createPaymentMutation = useCreatePaymentsPaymentsCreateCreate();
96
+
97
+ const isLoadingOverview = isLoadingBalance || isLoadingPayments || isLoadingTransactions;
98
+ const overviewError = balanceError || paymentsError || transactionsError;
99
+
100
+ const refreshBalance = async () => {
101
+ await mutateBalance();
102
+ };
103
+
104
+ const refreshPayments = async () => {
105
+ await mutatePayments();
106
+ };
107
+
108
+ const refreshTransactions = async () => {
109
+ await mutateTransactions();
110
+ };
111
+
112
+ const refreshOverview = async () => {
113
+ await Promise.all([
114
+ mutateBalance(),
115
+ mutatePayments(),
116
+ mutateTransactions(),
117
+ ]);
118
+ };
119
+
120
+ // Create payment
121
+ const createPayment = async (): Promise<PaymentList> => {
122
+ const result = await createPaymentMutation(api as unknown as API);
123
+ // Refresh overview data to show new payment
124
+ await refreshOverview();
125
+ return result as PaymentList;
126
+ };
127
+
128
+ const value: OverviewContextValue = {
129
+ balance,
130
+ isLoadingBalance,
131
+ balanceError,
132
+ refreshBalance,
133
+ payments,
134
+ isLoadingPayments,
135
+ paymentsError,
136
+ refreshPayments,
137
+ transactions,
138
+ isLoadingTransactions,
139
+ transactionsError,
140
+ refreshTransactions,
141
+ createPayment,
142
+ isLoadingOverview,
143
+ overviewError,
144
+ refreshOverview,
145
+ };
146
+
147
+ return (
148
+ <SWRConfig value={swrConfig}>
149
+ <OverviewContext.Provider value={value}>{children}</OverviewContext.Provider>
150
+ </SWRConfig>
151
+ );
152
+ }
153
+
154
+ // ─────────────────────────────────────────────────────────────────────────
155
+ // Hook
156
+ // ─────────────────────────────────────────────────────────────────────────
157
+
158
+ export function useOverviewContext(): OverviewContextValue {
159
+ const context = useContext(OverviewContext);
160
+ if (!context) {
161
+ throw new Error('useOverviewContext must be used within OverviewProvider');
162
+ }
163
+ return context;
164
+ }
165
+
166
+ // ─────────────────────────────────────────────────────────────────────────
167
+ // Re-export types
168
+ // ─────────────────────────────────────────────────────────────────────────
169
+
170
+ export type {
171
+ PaginatedPaymentListList,
172
+ PaymentList,
173
+ };
174
+
@@ -0,0 +1,132 @@
1
+ 'use client';
2
+
3
+ import React, { createContext, useContext, type ReactNode } from 'react';
4
+ import { api } from '@djangocfg/api';
5
+ import {
6
+ usePaymentsPaymentsList,
7
+ usePaymentsPaymentsRetrieve,
8
+ useCreatePaymentsPaymentsCreateCreate,
9
+ useCreatePaymentsPaymentsConfirmCreate,
10
+ usePaymentsPaymentsStatusRetrieve,
11
+ } from '@djangocfg/api';
12
+ import { getPaymentsPaymentsRetrieve } from '@djangocfg/api/cfg/generated/fetchers';
13
+ import { APILogger } from '@djangocfg/api';
14
+ import type { API } from '@djangocfg/api';
15
+ import type {
16
+ PaginatedPaymentListList,
17
+ PaymentDetail,
18
+ PaymentList,
19
+ } from '@djangocfg/api';
20
+
21
+ // ─────────────────────────────────────────────────────────────────────────
22
+ // Context Type
23
+ // ─────────────────────────────────────────────────────────────────────────
24
+
25
+ export interface PaymentsContextValue {
26
+ // List
27
+ payments: PaginatedPaymentListList | undefined;
28
+ isLoadingPayments: boolean;
29
+ paymentsError: Error | undefined;
30
+ refreshPayments: () => Promise<void>;
31
+
32
+ // Operations
33
+ getPayment: (id: string) => Promise<PaymentDetail | undefined>;
34
+ createPayment: () => Promise<PaymentList>;
35
+ confirmPayment: (id: string) => Promise<PaymentList>;
36
+ checkPaymentStatus: (id: string) => Promise<PaymentList | undefined>;
37
+ }
38
+
39
+ // ─────────────────────────────────────────────────────────────────────────
40
+ // Context
41
+ // ─────────────────────────────────────────────────────────────────────────
42
+
43
+ const PaymentsContext = createContext<PaymentsContextValue | undefined>(undefined);
44
+
45
+ // ─────────────────────────────────────────────────────────────────────────
46
+ // Provider
47
+ // ─────────────────────────────────────────────────────────────────────────
48
+
49
+ export function PaymentsProvider({ children }: { children: ReactNode }) {
50
+ // List payments (first page only for count)
51
+ const {
52
+ data: payments,
53
+ error: paymentsError,
54
+ isLoading: isLoadingPayments,
55
+ mutate: mutatePayments,
56
+ } = usePaymentsPaymentsList({ page: 1, page_size: 1 }, api as unknown as API);
57
+
58
+ const refreshPayments = async () => {
59
+ await mutatePayments();
60
+ };
61
+
62
+ // Mutations
63
+ const createPaymentMutation = useCreatePaymentsPaymentsCreateCreate();
64
+ const confirmPaymentMutation = useCreatePaymentsPaymentsConfirmCreate();
65
+
66
+ // Get single payment
67
+ const getPayment = async (id: string): Promise<PaymentDetail | undefined> => {
68
+ try {
69
+ const result = await getPaymentsPaymentsRetrieve(id, api as unknown as API);
70
+ return result;
71
+ } catch (error) {
72
+ new APILogger().error('Failed to retrieve payment:', error);
73
+ return undefined;
74
+ }
75
+ };
76
+
77
+ // Create payment
78
+ const createPayment = async (): Promise<PaymentList> => {
79
+ const result = await createPaymentMutation(api as unknown as API);
80
+ await refreshPayments();
81
+ return result as PaymentList;
82
+ };
83
+
84
+ // Confirm payment (user clicked "I paid")
85
+ const confirmPayment = async (id: string): Promise<PaymentList> => {
86
+ const result = await confirmPaymentMutation(id, api as unknown as API);
87
+ await refreshPayments();
88
+ return result as PaymentList;
89
+ };
90
+
91
+ // Check payment status
92
+ const checkPaymentStatus = async (id: string): Promise<PaymentList | undefined> => {
93
+ const { data } = usePaymentsPaymentsStatusRetrieve(id, api as unknown as API);
94
+ return data;
95
+ };
96
+
97
+ const value: PaymentsContextValue = {
98
+ payments,
99
+ isLoadingPayments,
100
+ paymentsError,
101
+ refreshPayments,
102
+ getPayment,
103
+ createPayment,
104
+ confirmPayment,
105
+ checkPaymentStatus,
106
+ };
107
+
108
+ return <PaymentsContext.Provider value={value}>{children}</PaymentsContext.Provider>;
109
+ }
110
+
111
+ // ─────────────────────────────────────────────────────────────────────────
112
+ // Hook
113
+ // ─────────────────────────────────────────────────────────────────────────
114
+
115
+ export function usePaymentsContext(): PaymentsContextValue {
116
+ const context = useContext(PaymentsContext);
117
+ if (!context) {
118
+ throw new Error('usePaymentsContext must be used within PaymentsProvider');
119
+ }
120
+ return context;
121
+ }
122
+
123
+ // ─────────────────────────────────────────────────────────────────────────
124
+ // Re-export types
125
+ // ─────────────────────────────────────────────────────────────────────────
126
+
127
+ export type {
128
+ PaginatedPaymentListList,
129
+ PaymentDetail,
130
+ PaymentList,
131
+ };
132
+
@@ -0,0 +1,201 @@
1
+ # Payments Contexts
2
+
3
+ Декомпозированные контексты для модуля Payments.
4
+
5
+ ## Структура
6
+
7
+ ### PaymentsContext
8
+ **Файл:** `PaymentsContext.tsx`
9
+ **Назначение:** Управление платежами
10
+
11
+ **API:**
12
+ - `payments: PaginatedPaymentListList` - список платежей (пагинированный)
13
+ - `isLoadingPayments: boolean` - статус загрузки
14
+ - `refreshPayments()` - обновить список
15
+ - `getPayment(id)` - получить конкретный платеж
16
+ - `createPayment(data)` - создать платеж
17
+ - `cancelPayment(id, data)` - отменить платеж
18
+ - `checkPaymentStatus(id, data)` - проверить статус платежа
19
+
20
+ **Использование:**
21
+ ```tsx
22
+ import { PaymentsProvider, usePaymentsContext } from '@djangocfg/layouts/contexts';
23
+
24
+ function PaymentsList() {
25
+ const { payments, isLoadingPayments, refreshPayments } = usePaymentsContext();
26
+ // ...
27
+ }
28
+ ```
29
+
30
+ ---
31
+
32
+ ### BalancesContext
33
+ **Файл:** `BalancesContext.tsx`
34
+ **Назначение:** Управление балансами пользователей (read-only)
35
+
36
+ **API:**
37
+ - `balances: PaginatedUserBalanceList` - список балансов
38
+ - `isLoadingBalances: boolean` - статус загрузки
39
+ - `refreshBalances()` - обновить список
40
+ - `getBalance(id)` - получить конкретный баланс
41
+ - `getBalanceSummary()` - получить сводку по балансу
42
+
43
+ **Использование:**
44
+ ```tsx
45
+ import { BalancesProvider, useBalancesContext } from '@djangocfg/layouts/contexts';
46
+
47
+ function Balance() {
48
+ const { balances, getBalanceSummary } = useBalancesContext();
49
+ // ...
50
+ }
51
+ ```
52
+
53
+ ---
54
+
55
+ ### CurrenciesContext
56
+ **Файл:** `CurrenciesContext.tsx`
57
+ **Назначение:** Управление валютами и курсами обмена (read-only)
58
+
59
+ **API:**
60
+ - `currencies: PaginatedCurrencyListList` - список валют
61
+ - `isLoadingCurrencies: boolean` - статус загрузки
62
+ - `refreshCurrencies()` - обновить список
63
+ - `getCurrency(id)` - получить конкретную валюту
64
+ - `getCurrencyRates(baseCurrency, currencies)` - получить курсы обмена
65
+
66
+ **Использование:**
67
+ ```tsx
68
+ import { CurrenciesProvider, useCurrenciesContext } from '@djangocfg/layouts/contexts';
69
+
70
+ function CurrencySelector() {
71
+ const { currencies, getCurrencyRates } = useCurrenciesContext();
72
+ // ...
73
+ }
74
+ ```
75
+
76
+ ---
77
+
78
+ ### ApiKeysContext
79
+ **Файл:** `ApiKeysContext.tsx`
80
+ **Назначение:** Управление API ключами
81
+
82
+ **API:**
83
+ - `apiKeys: PaginatedAPIKeyListList` - список API ключей
84
+ - `isLoadingApiKeys: boolean` - статус загрузки
85
+ - `refreshApiKeys()` - обновить список
86
+ - `getApiKey(id)` - получить конкретный ключ
87
+ - `createApiKey(data)` - создать ключ
88
+ - `deleteApiKey(id)` - удалить ключ
89
+
90
+ **Использование:**
91
+ ```tsx
92
+ import { ApiKeysProvider, useApiKeysContext } from '@djangocfg/layouts/contexts';
93
+
94
+ function ApiKeysList() {
95
+ const { apiKeys, createApiKey, deleteApiKey } = useApiKeysContext();
96
+ // ...
97
+ }
98
+ ```
99
+
100
+ ---
101
+
102
+ ### OverviewContext
103
+ **Файл:** `OverviewContext.tsx`
104
+ **Назначение:** Дашборд и метрики платежной системы (read-only)
105
+
106
+ **API:**
107
+ - `overview: PaymentsDashboardOverview` - общий обзор
108
+ - `metrics: PaymentsMetrics` - метрики
109
+ - `balanceOverview: BalanceOverview` - обзор баланса
110
+ - `apiKeysOverview: APIKeysOverview` - обзор API ключей
111
+ - `subscriptionOverview: SubscriptionOverview` - обзор подписок
112
+ - `chartData: PaymentsChartResponse` - данные для графиков
113
+ - `recentPayments: PaginatedRecentPaymentList` - последние платежи
114
+ - `recentTransactions: PaginatedRecentTransactionList` - последние транзакции
115
+ - `isLoadingOverview: boolean` - статус загрузки
116
+ - `refreshOverview()` - обновить все данные
117
+
118
+ **Использование:**
119
+ ```tsx
120
+ import { OverviewProvider, useOverviewContext } from '@djangocfg/layouts/contexts';
121
+
122
+ function Dashboard() {
123
+ const { overview, metrics, chartData } = useOverviewContext();
124
+ // ...
125
+ }
126
+ ```
127
+
128
+ ---
129
+
130
+ ## Композиция провайдеров
131
+
132
+ Если нужно использовать несколько контекстов:
133
+
134
+ ```tsx
135
+ import {
136
+ PaymentsProvider,
137
+ BalancesProvider,
138
+ OverviewProvider
139
+ } from '@djangocfg/layouts/contexts';
140
+
141
+ function PaymentsDashboard() {
142
+ return (
143
+ <OverviewProvider>
144
+ <PaymentsProvider>
145
+ <BalancesProvider>
146
+ <YourComponent />
147
+ </BalancesProvider>
148
+ </PaymentsProvider>
149
+ </OverviewProvider>
150
+ );
151
+ }
152
+ ```
153
+
154
+ ---
155
+
156
+ ## Миграция со старого PaymentsContext
157
+
158
+ **Было:**
159
+ ```tsx
160
+ import { PaymentsProvider, usePaymentsContext } from '@djangocfg/layouts/contexts';
161
+
162
+ const { payments, balances, apiKeys } = usePaymentsContext();
163
+ ```
164
+
165
+ **Стало:**
166
+ ```tsx
167
+ import {
168
+ PaymentsProvider, usePaymentsContext,
169
+ BalancesProvider, useBalancesContext,
170
+ ApiKeysProvider, useApiKeysContext
171
+ } from '@djangocfg/layouts/contexts';
172
+
173
+ // В разных компонентах или комбинируя:
174
+ const { payments } = usePaymentsContext();
175
+ const { balances } = useBalancesContext();
176
+ const { apiKeys } = useApiKeysContext();
177
+ ```
178
+
179
+ ---
180
+
181
+ ## Преимущества декомпозиции
182
+
183
+ 1. **Модульность** - каждый контекст отвечает за свою область
184
+ 2. **Производительность** - меньше ненужных ре-рендеров
185
+ 3. **Гибкость** - можно использовать только нужные контексты
186
+ 4. **Читаемость** - явное разделение зон ответственности
187
+ 5. **Масштабируемость** - проще добавлять новую функциональность
188
+
189
+ ---
190
+
191
+ ## Не включенные сущности
192
+
193
+ В текущей декомпозиции **не включены** (могут быть добавлены позже):
194
+ - `SubscriptionsContext` - управление подписками (CRUD)
195
+ - `TransactionsContext` - история транзакций (read-only)
196
+ - `TariffsContext` - тарифные планы (read-only)
197
+ - `NetworksContext` - блокчейн сети (read-only)
198
+ - `AdminContext` - админ-функции (для админки)
199
+
200
+ Эти сущности можно добавить по мере необходимости, следуя той же структуре.
201
+
@@ -0,0 +1,68 @@
1
+ 'use client';
2
+
3
+ import React, { createContext, useContext, type ReactNode } from 'react';
4
+ import { api } from '@djangocfg/api';
5
+ import {
6
+ usePaymentsCurrenciesList,
7
+ } from '@djangocfg/api';
8
+ import type { API } from '@djangocfg/api';
9
+
10
+ // ─────────────────────────────────────────────────────────────────────────
11
+ // Context Type
12
+ // ─────────────────────────────────────────────────────────────────────────
13
+
14
+ export interface RootPaymentsContextValue {
15
+ // Currencies - simplified to single endpoint
16
+ currencies: any | undefined;
17
+ isLoadingCurrencies: boolean;
18
+ currenciesError: Error | undefined;
19
+ refreshCurrencies: () => Promise<void>;
20
+ }
21
+
22
+ // ─────────────────────────────────────────────────────────────────────────
23
+ // Context
24
+ // ─────────────────────────────────────────────────────────────────────────
25
+
26
+ const RootPaymentsContext = createContext<RootPaymentsContextValue | undefined>(undefined);
27
+
28
+ // ─────────────────────────────────────────────────────────────────────────
29
+ // Provider
30
+ // ─────────────────────────────────────────────────────────────────────────
31
+
32
+ export function RootPaymentsProvider({ children }: { children: ReactNode }) {
33
+ // Get currencies list from /cfg/payments/currencies/
34
+ // In v2.0, this returns all currencies with network info embedded
35
+ const {
36
+ data: currencies,
37
+ error: currenciesError,
38
+ isLoading: isLoadingCurrencies,
39
+ mutate: mutateCurrencies,
40
+ } = usePaymentsCurrenciesList(api as unknown as API);
41
+
42
+ const refreshCurrencies = async () => {
43
+ await mutateCurrencies();
44
+ };
45
+
46
+ const value: RootPaymentsContextValue = {
47
+ currencies,
48
+ isLoadingCurrencies,
49
+ currenciesError,
50
+ refreshCurrencies,
51
+ };
52
+
53
+ return (
54
+ <RootPaymentsContext.Provider value={value}>{children}</RootPaymentsContext.Provider>
55
+ );
56
+ }
57
+
58
+ // ─────────────────────────────────────────────────────────────────────────
59
+ // Hook
60
+ // ─────────────────────────────────────────────────────────────────────────
61
+
62
+ export function useRootPaymentsContext(): RootPaymentsContextValue {
63
+ const context = useContext(RootPaymentsContext);
64
+ if (!context) {
65
+ throw new Error('useRootPaymentsContext must be used within RootPaymentsProvider');
66
+ }
67
+ return context;
68
+ }
@@ -0,0 +1,50 @@
1
+ // Payments
2
+ export {
3
+ PaymentsProvider,
4
+ usePaymentsContext
5
+ } from './PaymentsContext';
6
+ export type {
7
+ PaymentsContextValue,
8
+ PaginatedPaymentListList,
9
+ PaymentDetail,
10
+ PaymentList,
11
+ } from './PaymentsContext';
12
+
13
+ // Balances
14
+ export {
15
+ BalancesProvider,
16
+ useBalancesContext
17
+ } from './BalancesContext';
18
+ export type {
19
+ BalancesContextValue,
20
+ } from './BalancesContext';
21
+
22
+ // Currencies
23
+ export {
24
+ CurrenciesProvider,
25
+ useCurrenciesContext
26
+ } from './CurrenciesContext';
27
+ export type {
28
+ CurrenciesContextValue,
29
+ } from './CurrenciesContext';
30
+
31
+ // Overview
32
+ export {
33
+ OverviewProvider,
34
+ useOverviewContext
35
+ } from './OverviewContext';
36
+ export type {
37
+ OverviewContextValue,
38
+ PaginatedPaymentListList as OverviewPaginatedPaymentListList,
39
+ PaymentList as OverviewPaymentList,
40
+ } from './OverviewContext';
41
+
42
+ // Root Payments (Global)
43
+ export {
44
+ RootPaymentsProvider,
45
+ useRootPaymentsContext
46
+ } from './RootPaymentsContext';
47
+ export type {
48
+ RootPaymentsContextValue,
49
+ } from './RootPaymentsContext';
50
+
package/src/index.ts CHANGED
@@ -37,3 +37,11 @@ export * from './snippets';
37
37
  // Components (includes ErrorTrackingProvider)
38
38
  export * from './components';
39
39
 
40
+ // Utils
41
+ export * from './utils';
42
+
43
+ // Pages
44
+ export * from './pages';
45
+
46
+ // Contexts (API contexts for data management)
47
+ export * from './contexts';