Make submission method for inactivity notice decisions
This commit is contained in:
parent
1b89ffaebd
commit
6cb8833b1a
@ -11,10 +11,41 @@ import {
|
|||||||
Stack,
|
Stack,
|
||||||
StackDivider,
|
StackDivider,
|
||||||
Text,
|
Text,
|
||||||
UnorderedList
|
UnorderedList,
|
||||||
|
useToast
|
||||||
} from "@chakra-ui/react";
|
} from "@chakra-ui/react";
|
||||||
|
|
||||||
export default function(props: InactivityNoticeProps) {
|
export default function(props: InactivityNoticeProps) {
|
||||||
|
const toast = useToast();
|
||||||
|
|
||||||
|
async function makeDecision(accepted: boolean) {
|
||||||
|
const decisionReq = await fetch(`\`/api/inactivity/${props.id}`, {
|
||||||
|
body: JSON.stringify({ accepted }),
|
||||||
|
headers: {
|
||||||
|
"content-type": "application/json"
|
||||||
|
},
|
||||||
|
method: "POST"
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!decisionReq.ok) {
|
||||||
|
toast({
|
||||||
|
description: (await decisionReq.json() as { error: string }).error,
|
||||||
|
isClosable: true,
|
||||||
|
status: "error",
|
||||||
|
title: "Oops"
|
||||||
|
});
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
toast({
|
||||||
|
description: `Inactivity notice ${accepted ? "accepted" : "denied"}.`,
|
||||||
|
isClosable: true,
|
||||||
|
status: "success",
|
||||||
|
title: "Success"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
const Approved = () => <Icon fill="currentColor" height="16" viewBox="0 0 16 16" width="16">
|
const Approved = () => <Icon fill="currentColor" height="16" viewBox="0 0 16 16" width="16">
|
||||||
<path
|
<path
|
||||||
d="M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0zm-3.97-3.03a.75.75 0 0 0-1.08.022L7.477 9.417 5.384 7.323a.75.75 0 0 0-1.06 1.06L6.97 11.03a.75.75 0 0 0 1.079-.02l3.992-4.99a.75.75 0 0 0-.01-1.05z" />
|
d="M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0zm-3.97-3.03a.75.75 0 0 0-1.08.022L7.477 9.417 5.384 7.323a.75.75 0 0 0-1.06 1.06L6.97 11.03a.75.75 0 0 0 1.079-.02l3.992-4.99a.75.75 0 0 0-.01-1.05z" />
|
||||||
@ -57,8 +88,8 @@ export default function(props: InactivityNoticeProps) {
|
|||||||
</CardBody>
|
</CardBody>
|
||||||
<CardFooter pb="4px">
|
<CardFooter pb="4px">
|
||||||
<Box>
|
<Box>
|
||||||
<Button colorScheme="red">Deny</Button>
|
<Button colorScheme="red" onClick={async () => await makeDecision(false)}>Deny</Button>
|
||||||
<Button colorScheme="blue" ml="8px">
|
<Button colorScheme="blue" ml="8px" onClick={async () => await makeDecision(true)}>
|
||||||
Accept
|
Accept
|
||||||
</Button>
|
</Button>
|
||||||
</Box>
|
</Box>
|
||||||
|
1
index.d.ts
vendored
1
index.d.ts
vendored
@ -50,6 +50,7 @@ declare global {
|
|||||||
}[];
|
}[];
|
||||||
departments: string[];
|
departments: string[];
|
||||||
end: string;
|
end: string;
|
||||||
|
id: string;
|
||||||
reason: string;
|
reason: string;
|
||||||
start: string;
|
start: string;
|
||||||
user: {
|
user: {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user