Display inactivity notices in the mod queue
This commit is contained in:
parent
17bca653cf
commit
0b5e82bfcc
@ -16,7 +16,7 @@ import {
|
|||||||
useToast,
|
useToast,
|
||||||
VStack,
|
VStack,
|
||||||
} from "@chakra-ui/react";
|
} from "@chakra-ui/react";
|
||||||
import { useEffect, useState } from "react";
|
import { type ReactElement, 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 NewGameBan from "../../components/NewGameBan.js";
|
import NewGameBan from "../../components/NewGameBan.js";
|
||||||
@ -24,6 +24,7 @@ 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";
|
import NewInactivityNotice from "../../components/NewInactivityNotice.js";
|
||||||
|
import InactivityNoticeCard from "../../components/InactivityNoticeCard.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;
|
||||||
@ -108,23 +109,23 @@ export default function () {
|
|||||||
const pageProps = useLoaderData<typeof loader>();
|
const pageProps = useLoaderData<typeof loader>();
|
||||||
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 ReactElement[]);
|
||||||
const [before, setBefore] = useState(0);
|
const [before, setBefore] = useState(Date.now());
|
||||||
|
|
||||||
for (const type of pageProps.entry_types)
|
for (const type of pageProps.entry_types)
|
||||||
entryTypes.push(
|
entryTypes.push(
|
||||||
<option key={type.value} value={type.value}>
|
<option key={type.value} value={type.value}>
|
||||||
{type.name}
|
{type.name}
|
||||||
</option>
|
</option>,
|
||||||
);
|
);
|
||||||
|
|
||||||
async function updateQueue(
|
async function updateQueue(
|
||||||
queue_type: string,
|
queue_type: string,
|
||||||
before = Date.now(),
|
before: number,
|
||||||
show_closed = false
|
show_closed = false,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const queueReq = await fetch(
|
const queueReq = await fetch(
|
||||||
`/api/mod-queue/list?before=${before}&showClosed=${show_closed}&type=${queue_type}`
|
`/api/mod-queue/list?before=${before}&showClosed=${show_closed}&type=${queue_type}`,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!queueReq.ok) {
|
if (!queueReq.ok) {
|
||||||
@ -148,7 +149,11 @@ export default function () {
|
|||||||
const entryData: { [k: string]: any }[] = await queueReq.json();
|
const entryData: { [k: string]: any }[] = await queueReq.json();
|
||||||
const newEntries = [...entries];
|
const newEntries = [...entries];
|
||||||
|
|
||||||
if (itemId && itemType && ["appeal", "gma", "report"].includes(itemType)) {
|
if (
|
||||||
|
itemId &&
|
||||||
|
itemType &&
|
||||||
|
["appeal", "gma", "inactivity", "report"].includes(itemType)
|
||||||
|
) {
|
||||||
const itemReq = await fetch(`/api/mod-queue/${itemType}/${itemId}`);
|
const itemReq = await fetch(`/api/mod-queue/${itemType}/${itemId}`);
|
||||||
|
|
||||||
if (!itemReq.ok) {
|
if (!itemReq.ok) {
|
||||||
@ -180,6 +185,13 @@ export default function () {
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case "inactivity":
|
||||||
|
newEntries.push(
|
||||||
|
<InactivityNoticeCard {...(entry as InactivityNoticeProps)} />,
|
||||||
|
);
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
case "report":
|
case "report":
|
||||||
newEntries.push(<ReportCard {...(entry as ReportCardProps)} />);
|
newEntries.push(<ReportCard {...(entry as ReportCardProps)} />);
|
||||||
|
|
||||||
@ -206,7 +218,7 @@ export default function () {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
(async function () {
|
(async function () {
|
||||||
await updateQueue(pageProps.entry_types[0].value);
|
await updateQueue(pageProps.entry_types[0].value, before);
|
||||||
})();
|
})();
|
||||||
|
|
||||||
const searchParams = new URLSearchParams(location.search);
|
const searchParams = new URLSearchParams(location.search);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user