@djangocfg/layouts 2.1.10 → 2.1.14

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 (105) hide show
  1. package/README.md +53 -161
  2. package/package.json +6 -6
  3. package/src/components/RedirectPage/RedirectPage.tsx +1 -1
  4. package/src/index.ts +0 -6
  5. package/src/layouts/AppLayout/AppLayout.tsx +1 -1
  6. package/src/layouts/AppLayout/BaseApp.tsx +1 -1
  7. package/src/layouts/AuthLayout/AuthContext.tsx +1 -1
  8. package/src/layouts/AuthLayout/OAuthCallback.tsx +1 -1
  9. package/src/layouts/AuthLayout/OAuthProviders.tsx +1 -1
  10. package/src/layouts/PrivateLayout/PrivateLayout.tsx +1 -1
  11. package/src/layouts/PrivateLayout/components/PrivateHeader.tsx +1 -1
  12. package/src/layouts/ProfileLayout/components/AvatarSection.tsx +2 -2
  13. package/src/layouts/PublicLayout/components/PublicMobileDrawer.tsx +1 -1
  14. package/src/layouts/PublicLayout/components/PublicNavigation.tsx +1 -1
  15. package/src/layouts/_components/UserMenu.tsx +1 -1
  16. package/src/layouts/index.ts +0 -2
  17. package/src/snippets/Analytics/useAnalytics.ts +1 -1
  18. package/src/snippets/index.ts +0 -3
  19. package/src/auth/README.md +0 -962
  20. package/src/auth/context/AccountsContext.tsx +0 -240
  21. package/src/auth/context/AuthContext.tsx +0 -604
  22. package/src/auth/context/index.ts +0 -4
  23. package/src/auth/context/types.ts +0 -68
  24. package/src/auth/hooks/index.ts +0 -17
  25. package/src/auth/hooks/useAuthForm.ts +0 -332
  26. package/src/auth/hooks/useAuthGuard.ts +0 -25
  27. package/src/auth/hooks/useAuthRedirect.ts +0 -51
  28. package/src/auth/hooks/useAutoAuth.ts +0 -49
  29. package/src/auth/hooks/useGithubAuth.ts +0 -184
  30. package/src/auth/hooks/useLocalStorage.ts +0 -214
  31. package/src/auth/hooks/useProfileCache.ts +0 -146
  32. package/src/auth/hooks/useSessionStorage.ts +0 -189
  33. package/src/auth/index.ts +0 -10
  34. package/src/auth/middlewares/index.ts +0 -1
  35. package/src/auth/middlewares/proxy.ts +0 -32
  36. package/src/auth/server.ts +0 -6
  37. package/src/auth/utils/errors.ts +0 -34
  38. package/src/auth/utils/index.ts +0 -2
  39. package/src/auth/utils/validation.ts +0 -14
  40. package/src/contexts/LeadsContext.tsx +0 -156
  41. package/src/contexts/NewsletterContext.tsx +0 -263
  42. package/src/contexts/SupportContext.tsx +0 -256
  43. package/src/contexts/index.ts +0 -59
  44. package/src/contexts/knowbase/ChatContext.tsx +0 -174
  45. package/src/contexts/knowbase/DocumentsContext.tsx +0 -304
  46. package/src/contexts/knowbase/SessionsContext.tsx +0 -174
  47. package/src/contexts/knowbase/index.ts +0 -61
  48. package/src/contexts/payments/BalancesContext.tsx +0 -65
  49. package/src/contexts/payments/CurrenciesContext.tsx +0 -66
  50. package/src/contexts/payments/OverviewContext.tsx +0 -174
  51. package/src/contexts/payments/PaymentsContext.tsx +0 -132
  52. package/src/contexts/payments/README.md +0 -201
  53. package/src/contexts/payments/RootPaymentsContext.tsx +0 -68
  54. package/src/contexts/payments/index.ts +0 -50
  55. package/src/layouts/PaymentsLayout/PaymentsLayout.tsx +0 -92
  56. package/src/layouts/PaymentsLayout/components/CreatePaymentDialog.tsx +0 -291
  57. package/src/layouts/PaymentsLayout/components/PaymentDetailsDialog.tsx +0 -290
  58. package/src/layouts/PaymentsLayout/components/index.ts +0 -2
  59. package/src/layouts/PaymentsLayout/events.ts +0 -47
  60. package/src/layouts/PaymentsLayout/index.ts +0 -16
  61. package/src/layouts/PaymentsLayout/types.ts +0 -6
  62. package/src/layouts/PaymentsLayout/views/overview/components/BalanceCard.tsx +0 -128
  63. package/src/layouts/PaymentsLayout/views/overview/components/RecentPayments.tsx +0 -142
  64. package/src/layouts/PaymentsLayout/views/overview/components/index.ts +0 -2
  65. package/src/layouts/PaymentsLayout/views/overview/index.tsx +0 -20
  66. package/src/layouts/PaymentsLayout/views/payments/components/PaymentsList.tsx +0 -276
  67. package/src/layouts/PaymentsLayout/views/payments/components/index.ts +0 -1
  68. package/src/layouts/PaymentsLayout/views/payments/index.tsx +0 -17
  69. package/src/layouts/PaymentsLayout/views/transactions/components/TransactionsList.tsx +0 -273
  70. package/src/layouts/PaymentsLayout/views/transactions/components/index.ts +0 -1
  71. package/src/layouts/PaymentsLayout/views/transactions/index.tsx +0 -17
  72. package/src/layouts/SupportLayout/README.md +0 -91
  73. package/src/layouts/SupportLayout/SupportLayout.tsx +0 -179
  74. package/src/layouts/SupportLayout/components/CreateTicketDialog.tsx +0 -155
  75. package/src/layouts/SupportLayout/components/MessageInput.tsx +0 -92
  76. package/src/layouts/SupportLayout/components/MessageList.tsx +0 -314
  77. package/src/layouts/SupportLayout/components/TicketCard.tsx +0 -96
  78. package/src/layouts/SupportLayout/components/TicketList.tsx +0 -153
  79. package/src/layouts/SupportLayout/components/index.ts +0 -6
  80. package/src/layouts/SupportLayout/context/SupportLayoutContext.tsx +0 -263
  81. package/src/layouts/SupportLayout/context/index.ts +0 -2
  82. package/src/layouts/SupportLayout/events.ts +0 -33
  83. package/src/layouts/SupportLayout/hooks/index.ts +0 -2
  84. package/src/layouts/SupportLayout/hooks/useInfiniteMessages.ts +0 -119
  85. package/src/layouts/SupportLayout/hooks/useInfiniteTickets.ts +0 -92
  86. package/src/layouts/SupportLayout/index.ts +0 -8
  87. package/src/layouts/SupportLayout/types.ts +0 -21
  88. package/src/snippets/Chat/ChatUIContext.tsx +0 -110
  89. package/src/snippets/Chat/ChatWidget.tsx +0 -476
  90. package/src/snippets/Chat/README.md +0 -122
  91. package/src/snippets/Chat/components/MessageInput.tsx +0 -124
  92. package/src/snippets/Chat/components/MessageList.tsx +0 -169
  93. package/src/snippets/Chat/components/SessionList.tsx +0 -192
  94. package/src/snippets/Chat/components/index.ts +0 -9
  95. package/src/snippets/Chat/hooks/index.ts +0 -6
  96. package/src/snippets/Chat/hooks/useInfiniteSessions.ts +0 -82
  97. package/src/snippets/Chat/index.tsx +0 -45
  98. package/src/snippets/Chat/types.ts +0 -80
  99. package/src/snippets/ContactForm/ContactForm.tsx +0 -346
  100. package/src/snippets/ContactForm/ContactFormProvider.tsx +0 -153
  101. package/src/snippets/ContactForm/ContactInfo.tsx +0 -114
  102. package/src/snippets/ContactForm/ContactPage.tsx +0 -131
  103. package/src/snippets/ContactForm/dynamic.tsx +0 -55
  104. package/src/snippets/ContactForm/index.ts +0 -34
  105. package/src/snippets/ContactForm/types.ts +0 -110
@@ -1,201 +0,0 @@
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
-
@@ -1,68 +0,0 @@
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
- }
@@ -1,50 +0,0 @@
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
-
@@ -1,92 +0,0 @@
1
- // @ts-nocheck
2
- /**
3
- * Payments Layout (v2.0 - Simplified)
4
- *
5
- * Simplified layout with 3 tabs: Overview, Payments, Transactions
6
- * Removed: API Keys, Tariffs (deprecated in v2.0)
7
- */
8
-
9
- 'use client';
10
-
11
- import React from 'react';
12
- import {
13
- PaymentsProvider,
14
- OverviewProvider,
15
- RootPaymentsProvider,
16
- } from '@djangocfg/layouts/contexts';
17
- import { Tabs, TabsContent, TabsList, TabsTrigger } from '@djangocfg/ui-nextjs';
18
- import { Wallet, CreditCard, History } from 'lucide-react';
19
- import { OverviewView } from './views/overview';
20
- import { PaymentsView } from './views/payments';
21
- import { TransactionsView } from './views/transactions';
22
- import { CreatePaymentDialog, PaymentDetailsDialog } from './components';
23
-
24
- // ─────────────────────────────────────────────────────────────────────────
25
- // Payments Layout
26
- // ─────────────────────────────────────────────────────────────────────────
27
-
28
- export interface PaymentsLayoutProps {
29
- children?: React.ReactNode;
30
- }
31
-
32
- export const PaymentsLayout: React.FC<PaymentsLayoutProps> = () => {
33
- return (
34
- <RootPaymentsProvider>
35
- <div className="h-full p-6 space-y-6">
36
- {/* Page Header */}
37
- <div>
38
- <h1 className="text-3xl font-bold tracking-tight">Payments</h1>
39
- <p className="text-muted-foreground">
40
- Manage your payments, balance, and transaction history
41
- </p>
42
- </div>
43
-
44
- {/* Main Content with Tabs */}
45
- <Tabs defaultValue="overview" className="space-y-6">
46
- <TabsList className="inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground">
47
- <TabsTrigger value="overview" className="inline-flex items-center gap-2 px-3 py-1.5">
48
- <Wallet className="h-4 w-4" />
49
- <span className="hidden sm:inline">Overview</span>
50
- </TabsTrigger>
51
- <TabsTrigger value="payments" className="inline-flex items-center gap-2 px-3 py-1.5">
52
- <CreditCard className="h-4 w-4" />
53
- <span className="hidden sm:inline">Payments</span>
54
- </TabsTrigger>
55
- <TabsTrigger value="transactions" className="inline-flex items-center gap-2 px-3 py-1.5">
56
- <History className="h-4 w-4" />
57
- <span className="hidden sm:inline">Transactions</span>
58
- </TabsTrigger>
59
- </TabsList>
60
-
61
- {/* Overview Tab - Balance + Recent Payments */}
62
- <TabsContent value="overview" className="space-y-6">
63
- <OverviewProvider>
64
- <PaymentsProvider>
65
- <OverviewView />
66
- <CreatePaymentDialog />
67
- </PaymentsProvider>
68
- </OverviewProvider>
69
- </TabsContent>
70
-
71
- {/* Payments Tab - Full Payment List */}
72
- <TabsContent value="payments" className="space-y-6">
73
- <PaymentsProvider>
74
- <PaymentsView />
75
- <CreatePaymentDialog />
76
- </PaymentsProvider>
77
- </TabsContent>
78
-
79
- {/* Transactions Tab - Transaction History */}
80
- <TabsContent value="transactions" className="space-y-6">
81
- <OverviewProvider>
82
- <TransactionsView />
83
- </OverviewProvider>
84
- </TabsContent>
85
- </Tabs>
86
-
87
- {/* Global Payment Details Dialog */}
88
- <PaymentDetailsDialog />
89
- </div>
90
- </RootPaymentsProvider>
91
- );
92
- };