Fix toasts and actually close on submit on inactivity notice modal
This commit is contained in:
parent
3dfa0ce86d
commit
4fa6cc2c99
@ -12,16 +12,18 @@ import {
|
|||||||
Text,
|
Text,
|
||||||
Textarea,
|
Textarea,
|
||||||
useToast,
|
useToast,
|
||||||
VStack,
|
VStack
|
||||||
} from "@chakra-ui/react";
|
} from "@chakra-ui/react";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
|
|
||||||
export default function (props: {
|
export default function(props: {
|
||||||
departments: string[];
|
departments: string[];
|
||||||
isOpen: boolean;
|
isOpen: boolean;
|
||||||
onClose: () => void;
|
onClose: () => void;
|
||||||
}) {
|
}) {
|
||||||
const [departments, setDepartments] = useState([] as string[]);
|
const [departments, setDepartments] = useState([] as string[]);
|
||||||
|
const toast = useToast();
|
||||||
|
|
||||||
function reset() {
|
function reset() {
|
||||||
(document.getElementById("start") as HTMLInputElement).value = "";
|
(document.getElementById("start") as HTMLInputElement).value = "";
|
||||||
(document.getElementById("end") as HTMLInputElement).value = "";
|
(document.getElementById("end") as HTMLInputElement).value = "";
|
||||||
@ -43,30 +45,35 @@ export default function (props: {
|
|||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
end,
|
end,
|
||||||
reason,
|
reason,
|
||||||
start,
|
start
|
||||||
}),
|
}),
|
||||||
headers: {
|
headers: {
|
||||||
"content-type": "application/json",
|
"content-type": "application/json"
|
||||||
},
|
},
|
||||||
method: "POST",
|
method: "POST"
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!inactivityPost.ok)
|
if (!inactivityPost.ok) {
|
||||||
return useToast()({
|
toast({
|
||||||
description: ((await inactivityPost.json()) as { error: string }).error,
|
description: ((await inactivityPost.json()) as { error: string }).error,
|
||||||
duration: 10000,
|
duration: 10000,
|
||||||
isClosable: true,
|
isClosable: true,
|
||||||
status: "error",
|
status: "error",
|
||||||
title: "Error",
|
title: "Error"
|
||||||
});
|
});
|
||||||
|
|
||||||
useToast()({
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
toast({
|
||||||
description: "Your inactivity notice has been created",
|
description: "Your inactivity notice has been created",
|
||||||
duration: 10000,
|
duration: 10000,
|
||||||
isClosable: true,
|
isClosable: true,
|
||||||
status: "success",
|
status: "success",
|
||||||
title: "Success",
|
title: "Success"
|
||||||
});
|
});
|
||||||
|
|
||||||
|
props.onClose();
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
Loading…
x
Reference in New Issue
Block a user