Register inactivity notice modal in mod queue
This commit is contained in:
parent
c057d2eb82
commit
a8f64dddec
@ -16,12 +16,13 @@ import {
|
|||||||
useToast,
|
useToast,
|
||||||
VStack,
|
VStack,
|
||||||
} from "@chakra-ui/react";
|
} from "@chakra-ui/react";
|
||||||
import { useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import AppealCard from "../../components/AppealCard.js";
|
import AppealCard from "../../components/AppealCard.js";
|
||||||
import GameAppealCard from "../../components/GameAppealCard.js";
|
import GameAppealCard from "../../components/GameAppealCard.js";
|
||||||
import NewInfractionModal from "../../components/NewInfractionModal.js";
|
import NewInfractionModal from "../../components/NewInfractionModal.js";
|
||||||
import ReportCard from "../../components/ReportCard.js";
|
import ReportCard from "../../components/ReportCard.js";
|
||||||
import { useLoaderData } from "@remix-run/react";
|
import { useLoaderData } from "@remix-run/react";
|
||||||
|
import NewInactivityNotice from "../../components/NewInactivityNotice.js";
|
||||||
|
|
||||||
export async function loader({ context }: { context: RequestContext }) {
|
export async function loader({ context }: { context: RequestContext }) {
|
||||||
const { current_user: currentUser } = context.data;
|
const { current_user: currentUser } = context.data;
|
||||||
@ -31,6 +32,13 @@ export async function loader({ context }: { context: RequestContext }) {
|
|||||||
status: 401,
|
status: 401,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const departments = {
|
||||||
|
DM: 1 << 2,
|
||||||
|
ET: 1 << 3,
|
||||||
|
FM: 1 << 10,
|
||||||
|
WM: 1 << 9,
|
||||||
|
};
|
||||||
|
|
||||||
const newItemPermissions = {
|
const newItemPermissions = {
|
||||||
game_ban: [1 << 5],
|
game_ban: [1 << 5],
|
||||||
inactivity: [1 << 2, 1 << 9, 1 << 10],
|
inactivity: [1 << 2, 1 << 9, 1 << 10],
|
||||||
@ -74,6 +82,9 @@ export async function loader({ context }: { context: RequestContext }) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
departments: Object.entries(departments)
|
||||||
|
.filter((d) => d[1] & currentUser.permissions)
|
||||||
|
.map((arr) => arr[0]),
|
||||||
entry_types: allowedTypes,
|
entry_types: allowedTypes,
|
||||||
item_types: allowedNewItems,
|
item_types: allowedNewItems,
|
||||||
};
|
};
|
||||||
@ -89,7 +100,6 @@ export function meta() {
|
|||||||
|
|
||||||
export default function () {
|
export default function () {
|
||||||
const pageProps = useLoaderData<typeof loader>();
|
const pageProps = useLoaderData<typeof loader>();
|
||||||
const infractionModalDisclosure = useDisclosure();
|
|
||||||
const isDesktop = useBreakpointValue({ base: false, lg: true });
|
const isDesktop = useBreakpointValue({ base: false, lg: true });
|
||||||
const entryTypes = [];
|
const entryTypes = [];
|
||||||
const [entries, setEntries] = useState([] as JSX.Element[]);
|
const [entries, setEntries] = useState([] as JSX.Element[]);
|
||||||
@ -161,16 +171,28 @@ export default function () {
|
|||||||
} = {
|
} = {
|
||||||
game_ban: useDisclosure(),
|
game_ban: useDisclosure(),
|
||||||
inactivity: useDisclosure(),
|
inactivity: useDisclosure(),
|
||||||
infraction: infractionModalDisclosure,
|
infraction: useDisclosure(),
|
||||||
};
|
};
|
||||||
|
|
||||||
console.log();
|
useEffect(() => {
|
||||||
|
const searchParams = new URLSearchParams(location.search);
|
||||||
|
const modal = searchParams.get("modal");
|
||||||
|
|
||||||
|
if (!modal || !pageProps.item_types.find((m) => m.value === modal)) return;
|
||||||
|
|
||||||
|
itemModals[modal].onOpen();
|
||||||
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Container maxW="container.lg">
|
<Container maxW="container.lg">
|
||||||
|
<NewInactivityNotice
|
||||||
|
departments={pageProps.departments}
|
||||||
|
isOpen={itemModals.inactivity.isOpen}
|
||||||
|
onClose={itemModals.inactivity.onClose}
|
||||||
|
/>
|
||||||
<NewInfractionModal
|
<NewInfractionModal
|
||||||
isOpen={infractionModalDisclosure.isOpen}
|
isOpen={itemModals.infraction.isOpen}
|
||||||
onClose={infractionModalDisclosure.onClose}
|
onClose={itemModals.infraction.onClose}
|
||||||
/>
|
/>
|
||||||
<Flex>
|
<Flex>
|
||||||
<VStack w={isDesktop ? "container.md" : "container.lg"}>
|
<VStack w={isDesktop ? "container.md" : "container.lg"}>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user