From fef1d5cadb68c16fb6c8bda2c586dec95d3e7a25 Mon Sep 17 00:00:00 2001 From: Jonas Honecker Date: Fri, 5 Jul 2024 13:25:22 +0200 Subject: [PATCH] Refactoring: use one status instead of two for visuals about request status --- frontend/src/components/forms/SearchForm.tsx | 10 +++++----- frontend/src/components/navbars/MainNavBar.tsx | 8 ++++---- frontend/src/components/pages/MainPage.tsx | 5 ++--- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/frontend/src/components/forms/SearchForm.tsx b/frontend/src/components/forms/SearchForm.tsx index 878a2d1..69d6ac7 100644 --- a/frontend/src/components/forms/SearchForm.tsx +++ b/frontend/src/components/forms/SearchForm.tsx @@ -8,24 +8,24 @@ import { SnackbarConfig } from "../../types/Config.ts"; type SearchFormProps = { setSearchResults: Dispatch>; setSnackbarConfig: Dispatch>; - setLoadingTickets: Dispatch>; + setPendingRequest: Dispatch>; }; export default function SearchForm({ setSearchResults, setSnackbarConfig, - setLoadingTickets, + setPendingRequest, }: Readonly) { function searchTickets(event: FormEvent) { event.preventDefault(); - setLoadingTickets(true); + setPendingRequest(true); getAllTickets(searchText) .then((response) => { - setLoadingTickets(false); + setPendingRequest(false); setSearchResults(response.data); }) .catch((error) => { - setLoadingTickets(false); + setPendingRequest(false); setSnackbarConfig({ open: true, severity: "error", diff --git a/frontend/src/components/navbars/MainNavBar.tsx b/frontend/src/components/navbars/MainNavBar.tsx index 3a7a09f..6295bbb 100644 --- a/frontend/src/components/navbars/MainNavBar.tsx +++ b/frontend/src/components/navbars/MainNavBar.tsx @@ -9,13 +9,13 @@ import { SidepanelConfig } from "../../types/Config.ts"; type NavBarProps = { user: User | null | undefined; setSidepanelConfig: Dispatch>; - loadingTickets: boolean; + pendingRequest: boolean; }; export default function MainNavBar({ user, setSidepanelConfig, - loadingTickets, + pendingRequest, }: Readonly) { return ( @@ -26,8 +26,8 @@ export default function MainNavBar({ {user && } - {loadingTickets && ( - + {pendingRequest && ( + diff --git a/frontend/src/components/pages/MainPage.tsx b/frontend/src/components/pages/MainPage.tsx index fd6279c..299bbf7 100644 --- a/frontend/src/components/pages/MainPage.tsx +++ b/frontend/src/components/pages/MainPage.tsx @@ -32,7 +32,6 @@ export default function MainPage({ message: "Initial value", }); const [confirmDeletion, setConfirmDeletion] = useState(false); - const [loadingTickets, setLoadingTickets] = useState(false); const [pendingRequest, setPendingRequest] = useState(false); return ( @@ -40,14 +39,14 @@ export default function MainPage({