import { toInt } from "$lib/util" import { generateRecordPDF } from "$lib/server/PDFGen"; export async function load({ locals }) { return { availableMonths: locals.user.get_months(), availableQuarters: locals.user.get_quarters() } } export const actions = { create_pdf: async ({ locals, request }) => { const data = await request.formData(); let month = toInt(data.get("month") ?? ""); let year = toInt(data.get("year") ?? ""); if (isNaN(year) || isNaN(month) || month > 12) { return fail(400, {}); } generateRecordPDF(locals.user, new Date(year, month - 1)); return { success: true } } }