Fix broken events team page
This commit is contained in:
parent
89ff059176
commit
e6aca19d67
@ -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,
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user