Skip to content

Commit 718b28f

Browse files
committed
hotfix: chatwidget
1 parent b91a7c0 commit 718b28f

6 files changed

Lines changed: 96 additions & 6 deletions

File tree

src/components/chat/ChatWidget.tsx

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,13 @@ interface ChatOption {
135135
onClick?: () => void
136136
}
137137

138-
interface ChatSource {
138+
export interface ChatSource {
139139
article_id: string
140140
title: string
141141
slug: string
142142
similarity: number
143+
flow_slug?: string
144+
flow_id?: string
143145
}
144146

145147
interface ChatMessage {
@@ -270,9 +272,25 @@ export interface ChatWidgetProps {
270272
logoUrl?: string
271273

272274
/**
273-
* Callback when an article source is clicked
275+
* Callback when an article source is clicked.
276+
* Provides the article slug and full source data for flexible routing.
277+
*
278+
* @example
279+
* ```tsx
280+
* // Simple slug-based routing
281+
* onArticleClick={(slug) => router.push(`/help/articles/${slug}`)}
282+
*
283+
* // Using flow context for nested routes
284+
* onArticleClick={(slug, source) => {
285+
* if (source.flow_slug) {
286+
* router.push(`/help/${source.flow_slug}/${slug}`)
287+
* } else {
288+
* router.push(`/help/articles/${slug}`)
289+
* }
290+
* }}
291+
* ```
274292
*/
275-
onArticleClick?: (slug: string) => void
293+
onArticleClick?: (slug: string, source: ChatSource) => void
276294

277295
/**
278296
* Callback when support button is clicked
@@ -482,8 +500,10 @@ export function ChatWidget({
482500
}
483501

484502
const handleSourceClick = (source: ChatSource) => {
485-
onArticleClick?.(source.slug)
486-
setIsOpen(false)
503+
if (onArticleClick) {
504+
onArticleClick(source.slug, source)
505+
setIsOpen(false)
506+
}
487507
}
488508

489509
return (

src/components/chat/index.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,9 @@
22
* Chat Component Exports
33
*/
44

5-
export { ChatWidget, type ChatWidgetProps, type ChatWidgetColors } from './ChatWidget'
5+
export {
6+
ChatWidget,
7+
type ChatWidgetProps,
8+
type ChatWidgetColors,
9+
type ChatSource,
10+
} from './ChatWidget'

src/components/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,4 +102,5 @@ export {
102102
ChatWidget,
103103
type ChatWidgetProps,
104104
type ChatWidgetColors,
105+
type ChatSource,
105106
} from './chat'

src/hooks/index.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,18 @@ export {
3939
export {
4040
useContactForm,
4141
useContactFormSubmit,
42+
// Aliases for consistency with React Native SDK
43+
useContactForm as useForm,
44+
useContactFormSubmit as useFormSubmit,
4245
type UseContactFormOptions,
4346
type UseContactFormResult,
4447
type UseContactFormSubmitOptions,
4548
type UseContactFormSubmitResult,
49+
// Type aliases for consistency with React Native SDK
50+
type UseContactFormOptions as UseFormOptions,
51+
type UseContactFormResult as UseFormResult,
52+
type UseContactFormSubmitOptions as UseFormSubmitOptions,
53+
type UseContactFormSubmitResult as UseFormSubmitResult,
4654
} from './useContactForm'
4755
export {
4856
useBlogPosts,

src/index.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ export {
3434
useSurveySubmit,
3535
useContactForm,
3636
useContactFormSubmit,
37+
// Aliases for consistency with React Native SDK
38+
useForm,
39+
useFormSubmit,
3740
useStatus,
3841
useBlogPosts,
3942
useBlogPost,
@@ -69,6 +72,11 @@ export {
6972
type UseContactFormResult,
7073
type UseContactFormSubmitOptions,
7174
type UseContactFormSubmitResult,
75+
// Type aliases for consistency with React Native SDK
76+
type UseFormOptions,
77+
type UseFormResult,
78+
type UseFormSubmitOptions,
79+
type UseFormSubmitResult,
7280
type UseStatusOptions,
7381
type UseStatusResult,
7482
type UseBlogPostsOptions,
@@ -136,6 +144,7 @@ export {
136144
type BlogPostDetailProps,
137145
type BlogProps,
138146
type ChatWidgetProps,
147+
type ChatSource,
139148
type StatusData,
140149
type StatusComponent,
141150
type StatusIncident,
@@ -209,6 +218,14 @@ export type {
209218
ContactFormFieldValidation,
210219
ContactFormSubmission,
211220
ContactFormSubmitInput,
221+
// Form type aliases (for consistency with React Native SDK)
222+
Form,
223+
FormField,
224+
FormFieldType,
225+
FormFieldValidation,
226+
FormIntegration,
227+
FormSubmission,
228+
FormSubmitInput,
212229
// Status API types
213230
StatusPage,
214231
StatusUpdate as StatusUpdateApi,

src/types/form.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,42 @@ export interface ContactFormSubmitInput {
7878
data: Record<string, string | boolean>
7979
metadata?: Record<string, unknown>
8080
}
81+
82+
// ============================================================================
83+
// Generic Form Aliases (for consistency with React Native SDK)
84+
// ============================================================================
85+
86+
/**
87+
* @alias ContactFormFieldType
88+
*/
89+
export type FormFieldType = ContactFormFieldType
90+
91+
/**
92+
* @alias ContactFormFieldValidation
93+
*/
94+
export type FormFieldValidation = ContactFormFieldValidation
95+
96+
/**
97+
* @alias ContactFormField
98+
*/
99+
export type FormField = ContactFormField
100+
101+
/**
102+
* @alias ContactFormIntegration
103+
*/
104+
export type FormIntegration = ContactFormIntegration
105+
106+
/**
107+
* @alias ContactForm
108+
*/
109+
export type Form = ContactForm
110+
111+
/**
112+
* @alias ContactFormSubmission
113+
*/
114+
export type FormSubmission = ContactFormSubmission
115+
116+
/**
117+
* @alias ContactFormSubmitInput
118+
*/
119+
export type FormSubmitInput = ContactFormSubmitInput

0 commit comments

Comments
 (0)