From 090c190b211430f4a2fe68e679057c45edbd2324 Mon Sep 17 00:00:00 2001 From: regalijan Date: Thu, 19 Oct 2023 16:49:07 -0400 Subject: [PATCH] Create first part of updateQueue function --- pages/mod-queue.page.tsx | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/pages/mod-queue.page.tsx b/pages/mod-queue.page.tsx index b6da992..a145910 100644 --- a/pages/mod-queue.page.tsx +++ b/pages/mod-queue.page.tsx @@ -4,6 +4,7 @@ import { Flex, Select, useBreakpointValue, + useToast, VStack, } from "@chakra-ui/react"; import { useEffect, useState } from "react"; @@ -15,11 +16,23 @@ export function Page(pageProps: { [p: string]: any }) { for (const type of pageProps.entry_types) entryTypes.push() - useEffect(() => { - (async function () { - const queueRequest = await fetch("/api/mod-queue") - })(); - }, []); + async function updateQueue(queue_type: string, include_closed: boolean = false): Promise { + const queueReq = await fetch(`/api/mod-queue/list?type=${queue_type}&includeClosed=${include_closed}`); + + if (!queueReq.ok) { + const errorData: { error: string } = await queueReq.json(); + + useToast()({ + description: errorData.error, + duration: 10000, + isClosable: true, + status: "error", + title: "Failed to load queue", + }); + + return; + } + } return (