- Add Superforms + Zod 4 for all admin form validation - Replace address isDefault with three separate boolean defaults (Mailing, Billing, Shipping) - Update profiles page with three-checkbox address form and toast improvements - Convert all admin page server actions to pass request directly to crud - Export superFormErrorsToFieldErrors helper for profiles server actions - Regenerate Prisma client for new schema fields
28 lines
813 B
TypeScript
28 lines
813 B
TypeScript
import type { PageServerLoad } from './$types';
|
|
import { error } from '@sveltejs/kit';
|
|
import { prisma } from '$lib/db';
|
|
import { canAccessAdmin } from '$lib/svelte-admin/roles';
|
|
|
|
export const load: PageServerLoad = async ({ params, parent }) => {
|
|
const parentData = typeof parent === 'function' ? await parent() : {};
|
|
const userRoleId = (parentData as { userRoleId?: number }).userRoleId ?? null;
|
|
if (userRoleId != null && !canAccessAdmin(userRoleId)) {
|
|
throw error(403, 'not authorized');
|
|
}
|
|
|
|
const proclamation = await prisma.proclamation.findUnique({
|
|
where: { id: params.id },
|
|
include: {
|
|
solfeggioFrequency: true,
|
|
category: { include: { parent: true } },
|
|
subscriptionLevel: true
|
|
}
|
|
});
|
|
|
|
if (!proclamation) {
|
|
throw error(404, 'Proclamation not found');
|
|
}
|
|
|
|
return { proclamation };
|
|
};
|