@@ -18,7 +18,7 @@ import { getValidator } from "../utils/getValidator";
18
18
/**
19
19
* Plugin hook that handles all the core logic.
20
20
*
21
- * @param pluginConfig Configurations for the plugin.
21
+ * @param pluginConfig configurations for the plugin
22
22
*/
23
23
const useRcbPlugin = ( pluginConfig ?: PluginConfig ) => {
24
24
const { showToast } = useToasts ( ) ;
@@ -45,7 +45,7 @@ const useRcbPlugin = (pluginConfig?: PluginConfig) => {
45
45
getBotId ( ) ,
46
46
getFlow ( ) ,
47
47
"validateTextInput"
48
- ) ;
48
+ ) ;
49
49
if ( ! validator ) {
50
50
return ;
51
51
}
@@ -85,51 +85,49 @@ const useRcbPlugin = (pluginConfig?: PluginConfig) => {
85
85
setNumPluginToasts ( ( prev ) => prev + 1 ) ;
86
86
} ;
87
87
88
- /**
89
- * Handles the user uploading a file event.
90
- *
91
- * @param event Event emitted when user uploads a file.
92
- */
93
- // useRcbPlugin.ts
94
-
95
88
const handleUserUploadFile = ( event : Event ) : void => {
96
89
const rcbEvent = event as RcbUserUploadFileEvent ;
97
90
const file : File | undefined = rcbEvent . data ?. files ?. [ 0 ] ;
98
-
91
+
99
92
if ( ! file ) {
100
- console . error ( "No file uploaded." ) ;
101
- event . preventDefault ( ) ;
102
- return ;
93
+ console . error ( "No file uploaded." ) ;
94
+ event . preventDefault ( ) ;
95
+ return ;
103
96
}
104
-
97
+
105
98
const validator = getValidator < File > (
106
- rcbEvent ,
107
- getBotId ( ) ,
108
- getFlow ( ) ,
109
- "validateFileInput"
99
+ rcbEvent ,
100
+ getBotId ( ) ,
101
+ getFlow ( ) ,
102
+ "validateFileInput"
110
103
) ;
111
-
104
+
112
105
if ( ! validator ) {
113
- console . error ( "Validator not found for file input." ) ;
114
- return ;
106
+ console . error ( "Validator not found for file input." ) ;
107
+ return ;
115
108
}
116
-
109
+
117
110
const validationResult = validator ( file ) ;
118
-
111
+
119
112
if ( ! validationResult . success ) {
120
- console . error ( "Validation failed:" , validationResult ) ;
121
- if ( validationResult . promptContent ) {
122
- showToast ( validationResult . promptContent , validationResult . promptDuration ?? 3000 ) ;
123
- }
124
- event . preventDefault ( ) ;
125
- return ;
113
+ console . error ( "Validation failed:" , validationResult ) ;
114
+ if ( validationResult . promptContent ) {
115
+ showToast (
116
+ validationResult . promptContent ,
117
+ validationResult . promptDuration ?? 3000
118
+ ) ;
119
+ }
120
+ event . preventDefault ( ) ;
121
+ return ;
126
122
}
127
-
123
+
128
124
console . log ( "Validation successful:" , validationResult ) ;
129
125
} ;
130
126
131
127
/**
132
128
* Handles the dismiss toast event.
129
+ *
130
+ * @param event Event emitted when toast is dismissed.
133
131
*/
134
132
const handleDismissToast = ( ) : void => {
135
133
setNumPluginToasts ( ( prev ) => prev - 1 ) ;
0 commit comments