Files
data-entry-app/frontend/src/routes/client-access/+page.ts
T

31 lines
700 B
TypeScript
Raw Normal View History

import { api } from '$lib/api';
import { hasStoredAdminSession, hasStoredClientSession } from '$lib/session';
2026-04-25 22:51:36 +12:00
function emptyPayload() {
return {
clients: [],
exportPreview: {
generated_at: '',
client_rows: [],
user_rows: [],
feature_rows: [],
permission_rows: [],
audit_rows: [],
clients: []
}
};
}
export async function load({ fetch }) {
if (!hasStoredAdminSession() && !hasStoredClientSession()) {
return emptyPayload();
}
try {
const [clients, exportPreview] = await Promise.all([api.clientAccess(fetch), api.clientAccessExport(fetch)]);
return { clients, exportPreview };
} catch {
return emptyPayload();
}
2026-04-25 22:51:36 +12:00
}