27 lines
592 B
TypeScript
27 lines
592 B
TypeScript
|
|
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 }
|
||
|
|
}
|
||
|
|
}
|