File tree 3 files changed +35
-56
lines changed
3 files changed +35
-56
lines changed Original file line number Diff line number Diff line change @@ -104,6 +104,7 @@ export const getTable = (
104
104
105
105
export default function KeyValueWidget ( { kpis } : KPIProps ) {
106
106
const [ items , setItems ] = useState < any [ ] > ( [ ] )
107
+ const [ showError , setShowError ] = useState ( false )
107
108
108
109
const RunQuery = ( query_id : string ) => {
109
110
let url = ''
@@ -162,6 +163,7 @@ export default function KeyValueWidget({ kpis }: KPIProps) {
162
163
} )
163
164
} ) . catch ( ( err ) => {
164
165
console . log ( "err" , err )
166
+ setShowError ( true )
165
167
} )
166
168
} )
167
169
@@ -173,12 +175,16 @@ export default function KeyValueWidget({ kpis }: KPIProps) {
173
175
174
176
useEffect ( ( ) => {
175
177
if ( kpis . length > 0 ) {
178
+ setShowError ( false )
176
179
handleKPIs ( )
177
180
}
178
181
} , [ kpis ] )
182
+ const GetItems = ( ) => {
183
+ return items
184
+ }
179
185
return (
180
186
< >
181
- { items . length == 0 || items . length != kpis . length ? (
187
+ { ( items . length == 0 || items . length != kpis . length || showError ) ? (
182
188
< >
183
189
< Alert header = "Error" type = "error" >
184
190
Error fetching fata
@@ -187,9 +193,11 @@ export default function KeyValueWidget({ kpis }: KPIProps) {
187
193
) : (
188
194
< >
189
195
< KeyValuePairs
190
- columns = { kpis . length > 4 ? 4 : kpis . length }
196
+ columns = { kpis . length > 4 ? 4 : kpis . length }
191
197
minColumnWidth = { 250 }
192
- items = { items }
198
+ // @ts -ignore
199
+
200
+ items = { GetItems ( ) }
193
201
/>
194
202
</ >
195
203
) }
Original file line number Diff line number Diff line change @@ -235,19 +235,11 @@ export default function WidgetLayout({
235
235
?. info
236
236
}
237
237
onChange = { ( e : any ) => {
238
- setWidgetProps ( {
239
- ...widgetProps ,
240
- kpis : [
241
- ...( widgetProps ?. kpis ||
242
- [ ] ) ,
243
- {
244
- info : e . detail
245
- . value ,
246
- count_kpi : '' ,
247
- list_kpi : '' ,
248
- } ,
249
- ] ,
250
- } )
238
+ HandleKPIPropChange (
239
+ index ,
240
+ e . detail . value ,
241
+ 'info'
242
+ )
251
243
} }
252
244
/>
253
245
< Input
@@ -257,23 +249,11 @@ export default function WidgetLayout({
257
249
?. count_kpi
258
250
}
259
251
onChange = { ( e : any ) => {
260
- setWidgetProps ( {
261
- ...widgetProps ,
262
- kpis : [
263
- ...( widgetProps ?. kpis ||
264
- [ ] ) ,
265
- {
266
- info : widgetProps
267
- ?. kpis ?. [
268
- index
269
- ] ?. info ,
270
- count_kpi :
271
- e . detail
272
- . value ,
273
- list_kpi : '' ,
274
- } ,
275
- ] ,
276
- } )
252
+ HandleKPIPropChange (
253
+ index ,
254
+ e . detail . value ,
255
+ 'count_kpi'
256
+ )
277
257
} }
278
258
/>
279
259
< Input
@@ -283,28 +263,11 @@ export default function WidgetLayout({
283
263
?. list_kpi
284
264
}
285
265
onChange = { ( e : any ) => {
286
- setWidgetProps ( {
287
- ...widgetProps ,
288
- kpis : [
289
- ...( widgetProps ?. kpis ||
290
- [ ] ) ,
291
- {
292
- info : widgetProps
293
- ?. kpis ?. [
294
- index
295
- ] ?. info ,
296
- count_kpi :
297
- widgetProps
298
- ?. kpis ?. [
299
- index
300
- ]
301
- ?. count_kpi ,
302
- list_kpi :
303
- e . detail
304
- . value ,
305
- } ,
306
- ] ,
307
- } )
266
+ HandleKPIPropChange (
267
+ index ,
268
+ e . detail . value ,
269
+ 'list_kpi'
270
+ )
308
271
} }
309
272
/>
310
273
</ >
Original file line number Diff line number Diff line change @@ -344,9 +344,17 @@ function AIChat({ setOpen }: any) {
344
344
user_clarification_response :answer
345
345
346
346
}
347
+ // @ts -ignore
348
+ const token = JSON . parse ( localStorage . getItem ( 'openg_auth' ) ) . token
349
+
350
+ const config = {
351
+ headers : {
352
+ Authorization : `Bearer ${ token } ` ,
353
+ } ,
354
+ }
347
355
348
356
axios
349
- . post ( `/main/core/api/v4/chatbot/generate-query` , body )
357
+ . post ( `/main/core/api/v4/chatbot/generate-query` , body , config )
350
358
. then ( ( res ) => {
351
359
if ( res ?. data ) {
352
360
const output = res ?. data
You can’t perform that action at this time.
0 commit comments