From 50a0f0240d7fef133eb5acc1bea2b1168b08e9db Mon Sep 17 00:00:00 2001 From: Factiven Date: Sun, 24 Dec 2023 13:03:54 +0700 Subject: migrate to typescript --- components/shared/bugReport.js | 194 ----------------------------------------- 1 file changed, 194 deletions(-) delete mode 100644 components/shared/bugReport.js (limited to 'components/shared/bugReport.js') diff --git a/components/shared/bugReport.js b/components/shared/bugReport.js deleted file mode 100644 index f6bd9f1..0000000 --- a/components/shared/bugReport.js +++ /dev/null @@ -1,194 +0,0 @@ -import { Fragment, useState } from "react"; -import { Dialog, Listbox, Transition } from "@headlessui/react"; -import { CheckIcon, ChevronDownIcon } from "@heroicons/react/20/solid"; -import { toast } from "sonner"; - -const severityOptions = [ - { id: 1, name: "Low" }, - { id: 2, name: "Medium" }, - { id: 3, name: "High" }, - { id: 4, name: "Critical" }, -]; - -const BugReportForm = ({ isOpen, setIsOpen }) => { - const [bugDescription, setBugDescription] = useState(""); - const [severity, setSeverity] = useState(severityOptions[0]); - - function closeModal() { - setIsOpen(false); - setBugDescription(""); - setSeverity(severityOptions[0]); - } - - const handleSubmit = async (e) => { - e.preventDefault(); - - const bugReport = { - desc: bugDescription, - severity: severity.name, - url: window.location.href, - createdAt: new Date().toISOString(), - }; - - try { - const res = await fetch("/api/v2/admin/bug-report", { - method: "POST", - headers: { - "Content-Type": "application/json", - }, - body: JSON.stringify({ - data: bugReport, - }), - }); - - const json = await res.json(); - toast.success(json.message); - closeModal(); - } catch (err) { - console.log(err); - toast.error("Something went wrong: " + err.message); - } - }; - - return ( - <> - - - -
- - -
-
- - -
-

- Report a Bug -

-
-
-
- - -
- -
- - - - {severity.name} - - - - - - - {severityOptions.map((person, personIdx) => ( - - `relative cursor-default select-none py-2 pl-10 pr-4 ${ - active - ? "bg-secondary/50 text-white" - : "text-gray-400" - }` - } - value={person} - > - {({ selected }) => ( - <> - - {person.name} - - {selected ? ( - - - ) : null} - - )} - - ))} - - -
-
-
-
- -
-
-
-
-
-
-
-
-
- - ); -}; - -export default BugReportForm; -- cgit v1.2.3