Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Set and handle open property on inactivity notices
  • Loading branch information
regalijan committed Oct 20, 2023
1 parent 3cc44ba commit 4adae3a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
10 changes: 10 additions & 0 deletions functions/api/inactivity/[id].ts
Expand Up @@ -62,6 +62,16 @@ export async function onRequestPost(context: RequestContext) {

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(
`inactivity_${context.params.id as string}`,
JSON.stringify(requestedNotice),
Expand Down
1 change: 1 addition & 0 deletions functions/api/inactivity/new.ts
Expand Up @@ -24,6 +24,7 @@ export async function onRequestPost(context: RequestContext) {
created_at: Date.now(),
departments,
end,
open: true,
reason,
start,
user: {
Expand Down

0 comments on commit 4adae3a

Please sign in to comment.