@djangocfg/layouts 2.0.5 → 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.
- package/package.json +10 -5
- package/src/contexts/LeadsContext.tsx +156 -0
- package/src/contexts/NewsletterContext.tsx +263 -0
- package/src/contexts/SupportContext.tsx +256 -0
- package/src/contexts/index.ts +59 -0
- package/src/contexts/knowbase/ChatContext.tsx +174 -0
- package/src/contexts/knowbase/DocumentsContext.tsx +304 -0
- package/src/contexts/knowbase/SessionsContext.tsx +174 -0
- package/src/contexts/knowbase/index.ts +61 -0
- package/src/contexts/payments/BalancesContext.tsx +65 -0
- package/src/contexts/payments/CurrenciesContext.tsx +66 -0
- package/src/contexts/payments/OverviewContext.tsx +174 -0
- package/src/contexts/payments/PaymentsContext.tsx +132 -0
- package/src/contexts/payments/README.md +201 -0
- package/src/contexts/payments/RootPaymentsContext.tsx +68 -0
- package/src/contexts/payments/index.ts +50 -0
- package/src/index.ts +4 -1
- package/src/layouts/AppLayout/AppLayout.tsx +20 -10
- package/src/layouts/PaymentsLayout/PaymentsLayout.tsx +1 -1
- package/src/layouts/PaymentsLayout/components/CreatePaymentDialog.tsx +1 -1
- package/src/layouts/PaymentsLayout/views/overview/components/BalanceCard.tsx +1 -1
- package/src/layouts/PaymentsLayout/views/overview/components/RecentPayments.tsx +1 -1
- package/src/layouts/PaymentsLayout/views/transactions/components/TransactionsList.tsx +1 -1
- package/src/layouts/ProfileLayout/components/ProfileForm.tsx +1 -1
- package/src/layouts/SupportLayout/SupportLayout.tsx +1 -1
- package/src/layouts/SupportLayout/components/TicketCard.tsx +1 -1
- package/src/layouts/SupportLayout/context/SupportLayoutContext.tsx +1 -1
- package/src/layouts/SupportLayout/index.ts +2 -0
- package/src/layouts/SupportLayout/types.ts +2 -4
- package/src/snippets/Chat/ChatWidget.tsx +1 -1
- package/src/snippets/Chat/components/SessionList.tsx +1 -1
- package/src/snippets/Chat/index.tsx +1 -1
- package/src/snippets/Chat/types.ts +7 -5
- package/src/snippets/ContactForm/ContactForm.tsx +20 -8
|
@@ -34,7 +34,7 @@ import { Plus, RefreshCw } from 'lucide-react';
|
|
|
34
34
|
import { useForm } from 'react-hook-form';
|
|
35
35
|
import { zodResolver } from '@hookform/resolvers/zod';
|
|
36
36
|
import { z } from 'zod';
|
|
37
|
-
import { usePaymentsContext, useRootPaymentsContext } from '@djangocfg/
|
|
37
|
+
import { usePaymentsContext, useRootPaymentsContext } from '@djangocfg/layouts/contexts';
|
|
38
38
|
import { PAYMENT_EVENTS, closePaymentsDialog } from '../events';
|
|
39
39
|
import { openPaymentDetailsDialog } from '../events';
|
|
40
40
|
import { paymentsLogger } from '../../../utils/logger';
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
Skeleton,
|
|
17
17
|
} from '@djangocfg/ui';
|
|
18
18
|
import { Wallet, RefreshCw, Plus } from 'lucide-react';
|
|
19
|
-
import { useOverviewContext } from '@djangocfg/
|
|
19
|
+
import { useOverviewContext } from '@djangocfg/layouts/contexts';
|
|
20
20
|
import { openCreatePaymentDialog } from '../../../events';
|
|
21
21
|
|
|
22
22
|
export const BalanceCard: React.FC = () => {
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
Skeleton,
|
|
17
17
|
} from '@djangocfg/ui';
|
|
18
18
|
import { History, ExternalLink } from 'lucide-react';
|
|
19
|
-
import { useOverviewContext } from '@djangocfg/
|
|
19
|
+
import { useOverviewContext } from '@djangocfg/layouts/contexts';
|
|
20
20
|
import { openPaymentDetailsDialog } from '../../../events';
|
|
21
21
|
|
|
22
22
|
export const RecentPayments: React.FC = () => {
|
|
@@ -28,7 +28,7 @@ import {
|
|
|
28
28
|
Skeleton,
|
|
29
29
|
} from '@djangocfg/ui';
|
|
30
30
|
import { History, Search, Filter, RefreshCw, ArrowUpRight, ArrowDownLeft } from 'lucide-react';
|
|
31
|
-
import { useOverviewContext } from '@djangocfg/
|
|
31
|
+
import { useOverviewContext } from '@djangocfg/layouts/contexts';
|
|
32
32
|
|
|
33
33
|
export const TransactionsList: React.FC = () => {
|
|
34
34
|
const {
|
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
useAccountsContext,
|
|
24
24
|
PatchedUserProfileUpdateRequestSchema,
|
|
25
25
|
type PatchedUserProfileUpdateRequest
|
|
26
|
-
} from '
|
|
26
|
+
} from '../../../auth/context';
|
|
27
27
|
import { useAuth } from '../../../auth';
|
|
28
28
|
|
|
29
29
|
export const ProfileForm = () => {
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
'use client';
|
|
8
8
|
|
|
9
9
|
import React from 'react';
|
|
10
|
-
import { SupportProvider } from '@djangocfg/
|
|
10
|
+
import { SupportProvider } from '@djangocfg/layouts/contexts';
|
|
11
11
|
import { SupportLayoutProvider, useSupportLayoutContext } from './context';
|
|
12
12
|
import {
|
|
13
13
|
TicketList,
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
import React from 'react';
|
|
9
9
|
import { Badge, Card, CardContent, cn } from '@djangocfg/ui';
|
|
10
10
|
import { Clock, MessageSquare } from 'lucide-react';
|
|
11
|
-
import type { Ticket } from '@djangocfg/
|
|
11
|
+
import type { Ticket } from '@djangocfg/layouts/contexts';
|
|
12
12
|
|
|
13
13
|
interface TicketCardProps {
|
|
14
14
|
ticket: Ticket;
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
'use client';
|
|
7
7
|
|
|
8
8
|
import React, { createContext, useCallback, useContext, useEffect, useState, type ReactNode } from 'react';
|
|
9
|
-
import { useSupportContext, type Ticket } from '@djangocfg/
|
|
9
|
+
import { useSupportContext, type Ticket } from '@djangocfg/layouts/contexts';
|
|
10
10
|
import { CfgSupportTypes } from '@djangocfg/api';
|
|
11
11
|
import { supportLogger } from '../../../utils/logger';
|
|
12
12
|
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export * from './SupportLayout';
|
|
2
2
|
export * from './context';
|
|
3
3
|
export * from './events';
|
|
4
|
+
// types.ts only contains UI-specific types (SupportUIState, TicketFormData)
|
|
5
|
+
// Ticket and Message are exported from @djangocfg/layouts/contexts
|
|
4
6
|
export * from './types';
|
|
5
7
|
export * from './components';
|
|
6
8
|
|
|
@@ -3,10 +3,8 @@
|
|
|
3
3
|
* Types for SupportLayout - combines API types with UI state
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
// Re-export API types
|
|
9
|
-
export type { Ticket, Message };
|
|
6
|
+
// Note: Ticket and Message types are exported from @djangocfg/layouts/contexts
|
|
7
|
+
// Import them directly: import type { Ticket, Message } from '@djangocfg/layouts/contexts';
|
|
10
8
|
|
|
11
9
|
// UI State
|
|
12
10
|
export interface SupportUIState {
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
Plus,
|
|
18
18
|
List,
|
|
19
19
|
} from 'lucide-react';
|
|
20
|
-
import { useKnowbaseChatContext, useKnowbaseSessionsContext, type ChatSource } from '@djangocfg/
|
|
20
|
+
import { useKnowbaseChatContext, useKnowbaseSessionsContext, type ChatSource } from '@djangocfg/layouts/contexts';
|
|
21
21
|
import { Enums } from '@djangocfg/api/cfg/generated';
|
|
22
22
|
import { chatLogger } from '../../utils/logger';
|
|
23
23
|
import { useChatUI } from './ChatUIContext';
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
Badge,
|
|
18
18
|
} from '@djangocfg/ui';
|
|
19
19
|
import { MessageSquare, Clock, Archive, Trash2, Loader2 } from 'lucide-react';
|
|
20
|
-
import { useKnowbaseSessionsContext } from '@djangocfg/
|
|
20
|
+
import { useKnowbaseSessionsContext } from '@djangocfg/layouts/contexts';
|
|
21
21
|
import { useInfiniteSessions } from '../hooks/useInfiniteSessions';
|
|
22
22
|
import type { SessionListProps } from '../types';
|
|
23
23
|
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
'use client';
|
|
8
8
|
|
|
9
9
|
import React from 'react';
|
|
10
|
-
import { KnowbaseChatProvider, KnowbaseSessionsProvider } from '@djangocfg/
|
|
10
|
+
import { KnowbaseChatProvider, KnowbaseSessionsProvider } from '@djangocfg/layouts/contexts';
|
|
11
11
|
import { ChatUIProvider } from './ChatUIContext';
|
|
12
12
|
import { ChatWidget } from './ChatWidget';
|
|
13
13
|
import type { ChatWidgetProps } from './types';
|
|
@@ -3,7 +3,13 @@
|
|
|
3
3
|
* Type definitions for RAG-powered chat widget
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
// Import types from Schemas namespace - explicitly exported and works reliably
|
|
7
|
+
// Types are available via Schemas namespace even when direct exports have issues
|
|
8
|
+
import type { Schemas } from '@djangocfg/api';
|
|
9
|
+
|
|
10
|
+
// Extract types from Schemas namespace
|
|
11
|
+
export type ChatMessage = Schemas.ChatMessage;
|
|
12
|
+
export type ChatSource = Schemas.ChatSource;
|
|
7
13
|
|
|
8
14
|
// ─────────────────────────────────────────────────────────────────────────
|
|
9
15
|
// Extended Message Type (for UI with sources)
|
|
@@ -70,9 +76,5 @@ export interface SessionListProps {
|
|
|
70
76
|
className?: string;
|
|
71
77
|
}
|
|
72
78
|
|
|
73
|
-
// ─────────────────────────────────────────────────────────────────────────
|
|
74
|
-
// Re-export types from API
|
|
75
|
-
// ─────────────────────────────────────────────────────────────────────────
|
|
76
79
|
|
|
77
|
-
export type { ChatSource, ChatMessage } from '@djangocfg/api/cfg/contexts';
|
|
78
80
|
|
|
@@ -145,20 +145,32 @@ function ContactFormInner({
|
|
|
145
145
|
|
|
146
146
|
// Watch form values and save to localStorage
|
|
147
147
|
const watchedValues = useWatch({ control: form.control });
|
|
148
|
+
const prevDraftRef = React.useRef<FormDraft>(draft);
|
|
148
149
|
|
|
149
150
|
useEffect(() => {
|
|
150
151
|
// Only save to localStorage after hydration to avoid unnecessary writes
|
|
151
152
|
if (!isHydrated) return;
|
|
152
153
|
|
|
153
154
|
const { name, email, company, subject, message } = watchedValues;
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
155
|
+
const newDraft: FormDraft = {
|
|
156
|
+
name: name || '',
|
|
157
|
+
email: email || '',
|
|
158
|
+
company: company || '',
|
|
159
|
+
subject: subject || '',
|
|
160
|
+
message: message || '',
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
// Only update if draft actually changed to prevent infinite loop
|
|
164
|
+
const hasChanges =
|
|
165
|
+
prevDraftRef.current.name !== newDraft.name ||
|
|
166
|
+
prevDraftRef.current.email !== newDraft.email ||
|
|
167
|
+
prevDraftRef.current.company !== newDraft.company ||
|
|
168
|
+
prevDraftRef.current.subject !== newDraft.subject ||
|
|
169
|
+
prevDraftRef.current.message !== newDraft.message;
|
|
170
|
+
|
|
171
|
+
if (hasChanges && (name || email || company || subject || message)) {
|
|
172
|
+
prevDraftRef.current = newDraft;
|
|
173
|
+
setDraft(newDraft);
|
|
162
174
|
}
|
|
163
175
|
}, [watchedValues, setDraft, isHydrated]);
|
|
164
176
|
|