Fix broken events team page

This commit is contained in:
Regalijan 2024-02-22 12:55:37 -05:00
parent 89ff059176
commit e6aca19d67
Signed by: regalijan
GPG Key ID: 5D4196DA269EF520

View File

@ -26,6 +26,11 @@ import { useLoaderData } from "@remix-run/react";
import { type ReactNode, useState } from "react";
export async function loader({ context }: { context: RequestContext }) {
if (!context.data.current_user)
throw new Response(null, {
status: 401,
});
const now = new Date();
const monthEventList = await context.env.D1.prepare(
"SELECT approved, created_by, day, id, month, pending, type, year FROM events WHERE month = ? AND year = ?;",
@ -40,7 +45,7 @@ export async function loader({ context }: { context: RequestContext }) {
return {
can_approve: Boolean(
[1 << 4, 1 << 12].find((p) => context.data.user.permissions & p),
[1 << 4, 1 << 12].find((p) => context.data.current_user.permissions & p),
),
events: monthEventList.results,
};