Oh yeah I forgot the other half
This commit is contained in:
@ -13,11 +13,14 @@ import {
|
||||
UnorderedList,
|
||||
useToast
|
||||
} from "@chakra-ui/react";
|
||||
import { useState } from "react";
|
||||
|
||||
export default function(props: InactivityNoticeProps) {
|
||||
const toast = useToast();
|
||||
const [loading, setLoading] = useState(false)
|
||||
|
||||
async function makeDecision(accepted: boolean) {
|
||||
setLoading(true)
|
||||
const decisionReq = await fetch(`/api/inactivity/${props.id}`, {
|
||||
body: JSON.stringify({ accepted }),
|
||||
headers: {
|
||||
@ -27,6 +30,7 @@ export default function(props: InactivityNoticeProps) {
|
||||
});
|
||||
|
||||
if (!decisionReq.ok) {
|
||||
setLoading(false)
|
||||
toast({
|
||||
description: ((await decisionReq.json()) as { error: string }).error,
|
||||
isClosable: true,
|
||||
@ -44,6 +48,7 @@ export default function(props: InactivityNoticeProps) {
|
||||
title: "Success"
|
||||
});
|
||||
|
||||
setLoading(false)
|
||||
location.reload();
|
||||
}
|
||||
|
||||
@ -103,6 +108,8 @@ export default function(props: InactivityNoticeProps) {
|
||||
<Button
|
||||
colorScheme="red"
|
||||
onClick={async () => await makeDecision(false)}
|
||||
isLoading={loading}
|
||||
loadingText='Processing...'
|
||||
>
|
||||
Deny
|
||||
</Button>
|
||||
@ -110,6 +117,8 @@ export default function(props: InactivityNoticeProps) {
|
||||
colorScheme="blue"
|
||||
ml="8px"
|
||||
onClick={async () => await makeDecision(true)}
|
||||
isLoading={loading}
|
||||
loadingText='Processing...'
|
||||
>
|
||||
Accept
|
||||
</Button>
|
||||
|
Reference in New Issue
Block a user