From 917cc51148b200f0e8f9aebef4d9c60c0a7c5e88 Mon Sep 17 00:00:00 2001 From: Gabriel Almeida Date: Thu, 27 Apr 2023 17:01:51 -0300 Subject: [PATCH] Refactor alertDropDown components Adjust singleAlertComponent's formatting for better readability and add a custom hook to handle click outside functionality in alertDropdown component. --- .../components/singleAlertComponent/index.tsx | 238 +++++++------ .../src/alerts/alertDropDown/index.tsx | 119 +++---- .../alerts/hooks/useOnClickOutside/index.ts | 33 ++ src/frontend/src/modals/exportModal/index.tsx | 332 +++++++++--------- .../components/tabsManagerComponent/index.tsx | 201 ++++++----- src/frontend/src/types/alerts/index.ts | 37 +- 6 files changed, 509 insertions(+), 451 deletions(-) create mode 100644 src/frontend/src/alerts/hooks/useOnClickOutside/index.ts diff --git a/src/frontend/src/alerts/alertDropDown/components/singleAlertComponent/index.tsx b/src/frontend/src/alerts/alertDropDown/components/singleAlertComponent/index.tsx index 576dfb0b8..d9428a34b 100644 --- a/src/frontend/src/alerts/alertDropDown/components/singleAlertComponent/index.tsx +++ b/src/frontend/src/alerts/alertDropDown/components/singleAlertComponent/index.tsx @@ -1,15 +1,23 @@ -import { XCircleIcon, XMarkIcon, InformationCircleIcon, CheckCircleIcon } from "@heroicons/react/24/outline"; +import { + XCircleIcon, + XMarkIcon, + InformationCircleIcon, + CheckCircleIcon, +} from "@heroicons/react/24/outline"; import { Link } from "react-router-dom"; import { Transition } from "@headlessui/react"; import { useState } from "react"; import { SingleAlertComponentType } from "../../../../types/alerts"; -export default function SingleAlert({ dropItem, removeAlert}:SingleAlertComponentType) { - const [show, setShow] = useState(true); - const type = dropItem.type; +export default function SingleAlert({ + dropItem, + removeAlert, +}: SingleAlertComponentType) { + const [show, setShow] = useState(true); + const type = dropItem.type; - return ( - - {type === "error"? -
-
-