f55b3add80
Co-authored-by: Thomas Way <thomas@6f.io>
26 lines
608 B
TypeScript
26 lines
608 B
TypeScript
import { AppRoute } from '$lib/constants';
|
|
import { redirect } from '@sveltejs/kit';
|
|
import type { PageServerLoad } from './$types';
|
|
|
|
export const load = (async ({ locals: { user, api } }) => {
|
|
if (!user) {
|
|
throw redirect(302, AppRoute.AUTH_LOGIN);
|
|
} else if (!user.isAdmin) {
|
|
throw redirect(302, AppRoute.PHOTOS);
|
|
}
|
|
|
|
try {
|
|
const { data: jobs } = await api.jobApi.getAllJobsStatus();
|
|
|
|
return {
|
|
jobs,
|
|
meta: {
|
|
title: 'Job Status',
|
|
},
|
|
};
|
|
} catch (err) {
|
|
console.error('[jobs] > getAllJobsStatus', err);
|
|
throw err;
|
|
}
|
|
}) satisfies PageServerLoad;
|