Stundenaufzeichnung/src/routes/dokumente/+page.server.ts

27 lines
592 B
TypeScript
Raw Normal View History

2025-01-17 13:32:28 +01:00
import { toInt } from "$lib/util"
import { generateRecordPDF } from "$lib/server/PDFGen";
export async function load({ locals }) {
return {
availableMonths: locals.user.get_months()
}
}
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), data.get("soll"));
return { success: true }
}
}