Skip to content

Commit 35f3f1e

Browse files
fix(web): align audit pages with raw API responses and unified token key
Consume the raw response shape returned by the backend (matching the api-client contract) instead of a { success, data } envelope, and read the veridion_access_token key so auth is shared across pages.
1 parent 043196c commit 35f3f1e

3 files changed

Lines changed: 14 additions & 22 deletions

File tree

apps/web/src/app/dashboard/audits/[id]/page.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,8 @@ export default function AuditDetailPage() {
6767
setLoading(true);
6868
setError(null);
6969
try {
70-
const json = await apiGet<{ success: boolean; data: AuditData }>(`/api/v1/audits/${auditId}`);
71-
if (!json.success || !json.data) {
72-
throw new Error('Failed to load audit');
73-
}
74-
setAudit(json.data);
70+
const json = await apiGet<AuditData>(`/api/v1/audits/${auditId}`);
71+
setAudit(json);
7572
} catch (err) {
7673
setError(err instanceof Error ? err.message : 'Failed to load audit');
7774
} finally {

apps/web/src/app/dashboard/audits/page.tsx

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,15 @@ interface AuditItem {
1919
};
2020
}
2121

22-
interface ApiResponse {
23-
success: boolean;
24-
data: {
25-
data: AuditItem[];
26-
meta: {
27-
total: number;
28-
page: number;
29-
limit: number;
30-
totalPages: number;
31-
hasNextPage: boolean;
32-
hasPreviousPage: boolean;
33-
};
22+
interface AuditsResponse {
23+
data: AuditItem[];
24+
meta: {
25+
total: number;
26+
page: number;
27+
limit: number;
28+
totalPages: number;
29+
hasNextPage: boolean;
30+
hasPreviousPage: boolean;
3431
};
3532
}
3633

@@ -63,10 +60,8 @@ export default function AuditsPage() {
6360
const params = new URLSearchParams({ limit: '50', sortOrder: 'desc' });
6461
if (statusFilter) params.set('status', statusFilter);
6562

66-
const json = await apiGet<ApiResponse>(`/api/v1/audits?${params.toString()}`);
67-
if (json.success && json.data) {
68-
setAudits(json.data.data);
69-
}
63+
const json = await apiGet<AuditsResponse>(`/api/v1/audits?${params.toString()}`);
64+
setAudits(json.data);
7065
} catch (err) {
7166
setError(err instanceof Error ? err.message : 'Failed to load audits');
7267
} finally {

apps/web/src/lib/api-helpers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export function getAuthToken(): string | null {
22
if (typeof window === 'undefined') return null;
3-
return localStorage.getItem('accessToken');
3+
return localStorage.getItem('veridion_access_token');
44
}
55

66
export function getApiBaseUrl(): string {

0 commit comments

Comments
 (0)