Set and handle open property on inactivity notices

This commit is contained in:
regalijan 2023-10-20 13:32:03 -04:00
parent 3cc44bab83
commit 4adae3af51
Signed by: regalijan
GPG Key ID: 5D4196DA269EF520
2 changed files with 11 additions and 0 deletions

View File

@ -62,6 +62,16 @@ export async function onRequestPost(context: RequestContext) {
requestedNotice.decisions = decisions; requestedNotice.decisions = decisions;
if (Object.values(decisions).length === requestedNotice.departments.length) {
requestedNotice.open = false;
await context.env.D1.prepare(
"UPDATE inactivity_notices SET open = 0 WHERE id = ?;",
)
.bind(context.params.id)
.run();
}
await context.env.DATA.put( await context.env.DATA.put(
`inactivity_${context.params.id as string}`, `inactivity_${context.params.id as string}`,
JSON.stringify(requestedNotice), JSON.stringify(requestedNotice),

View File

@ -24,6 +24,7 @@ export async function onRequestPost(context: RequestContext) {
created_at: Date.now(), created_at: Date.now(),
departments, departments,
end, end,
open: true,
reason, reason,
start, start,
user: { user: {