@@ -18,7 +18,7 @@ import { getValidator } from "../utils/getValidator";
1818/**
1919 * Plugin hook that handles all the core logic.
2020 *
21- * @param pluginConfig Configurations for the plugin.
21+ * @param pluginConfig configurations for the plugin
2222 */
2323const useRcbPlugin = ( pluginConfig ?: PluginConfig ) => {
2424 const { showToast } = useToasts ( ) ;
@@ -45,7 +45,7 @@ const useRcbPlugin = (pluginConfig?: PluginConfig) => {
4545 getBotId ( ) ,
4646 getFlow ( ) ,
4747 "validateTextInput"
48- ) ;
48+ ) ;
4949 if ( ! validator ) {
5050 return ;
5151 }
@@ -85,51 +85,49 @@ const useRcbPlugin = (pluginConfig?: PluginConfig) => {
8585 setNumPluginToasts ( ( prev ) => prev + 1 ) ;
8686 } ;
8787
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-
9588 const handleUserUploadFile = ( event : Event ) : void => {
9689 const rcbEvent = event as RcbUserUploadFileEvent ;
9790 const file : File | undefined = rcbEvent . data ?. files ?. [ 0 ] ;
98-
91+
9992 if ( ! file ) {
100- console . error ( "No file uploaded." ) ;
101- event . preventDefault ( ) ;
102- return ;
93+ console . error ( "No file uploaded." ) ;
94+ event . preventDefault ( ) ;
95+ return ;
10396 }
104-
97+
10598 const validator = getValidator < File > (
106- rcbEvent ,
107- getBotId ( ) ,
108- getFlow ( ) ,
109- "validateFileInput"
99+ rcbEvent ,
100+ getBotId ( ) ,
101+ getFlow ( ) ,
102+ "validateFileInput"
110103 ) ;
111-
104+
112105 if ( ! validator ) {
113- console . error ( "Validator not found for file input." ) ;
114- return ;
106+ console . error ( "Validator not found for file input." ) ;
107+ return ;
115108 }
116-
109+
117110 const validationResult = validator ( file ) ;
118-
111+
119112 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 ;
126122 }
127-
123+
128124 console . log ( "Validation successful:" , validationResult ) ;
129125 } ;
130126
131127 /**
132128 * Handles the dismiss toast event.
129+ *
130+ * @param event Event emitted when toast is dismissed.
133131 */
134132 const handleDismissToast = ( ) : void => {
135133 setNumPluginToasts ( ( prev ) => prev - 1 ) ;
0 commit comments