@@ -14,12 +14,8 @@ interface Citation {
1414}
1515
1616interface ApiChatResponse {
17- success : boolean ;
18- data : {
19- message : string ;
20- citations : Citation [ ] ;
21- } ;
22- message ?: string ;
17+ message : string ;
18+ citations : Citation [ ] ;
2319}
2420
2521export default function AiChatPage ( ) {
@@ -52,18 +48,15 @@ export default function AiChatPage() {
5248 }
5349
5450 const json = ( await res . json ( ) ) as {
55- success : boolean ;
56- data ?: {
57- data ?: Array < {
58- id : string ;
59- status : string ;
60- securityScore : number | null ;
61- project ?: { name : string } ;
62- } > ;
63- } ;
51+ data ?: Array < {
52+ id : string ;
53+ status : string ;
54+ securityScore : number | null ;
55+ project ?: { name : string } ;
56+ } > ;
6457 } ;
65- if ( json . success && json . data ?. data ) {
66- const auditOptions : AuditOption [ ] = json . data . data . map ( ( audit ) => ( {
58+ if ( json . data ) {
59+ const auditOptions : AuditOption [ ] = json . data . map ( ( audit ) => ( {
6760 id : audit . id ,
6861 name : audit . project ?. name ?? `Audit ${ audit . id . slice ( 0 , 8 ) } ` ,
6962 status : audit . status ,
@@ -199,15 +192,11 @@ export default function AiChatPage() {
199192
200193 const json = ( await res . json ( ) ) as ApiChatResponse ;
201194
202- if ( ! json . success || ! json . data ) {
203- throw new Error ( json . message ?? 'Unexpected API response' ) ;
204- }
205-
206195 const aiMsg : ChatMessage = {
207196 id : ( Date . now ( ) + 1 ) . toString ( ) ,
208197 role : 'assistant' ,
209- content : json . data . message ,
210- citations : json . data . citations ,
198+ content : json . message ,
199+ citations : json . citations ,
211200 timestamp : new Date ( ) ,
212201 } ;
213202
@@ -291,7 +280,7 @@ export default function AiChatPage() {
291280
292281function getAuthToken ( ) : string | null {
293282 if ( typeof window === 'undefined' ) return null ;
294- return localStorage . getItem ( 'accessToken ' ) ;
283+ return localStorage . getItem ( 'veridion_access_token ' ) ;
295284}
296285
297286function getApiBaseUrl ( ) : string {
0 commit comments