From 2fb6ddc5f6ecd7e70f6411a846b4cda40815c81b Mon Sep 17 00:00:00 2001 From: Araozu Date: Mon, 2 Oct 2023 21:00:35 -0500 Subject: [PATCH] [FE] Add spinner to person search --- backend/src/controller/person/mod.rs | 2 -- frontend/src/certs/Search/index.tsx | 14 ++++++++++++-- frontend/src/icons/LoadingIcon.tsx | 15 +++++++++++++++ frontend/src/utils/functions.ts | 4 ++++ 4 files changed, 31 insertions(+), 4 deletions(-) create mode 100644 frontend/src/icons/LoadingIcon.tsx diff --git a/backend/src/controller/person/mod.rs b/backend/src/controller/person/mod.rs index e5a96d7..f857f06 100644 --- a/backend/src/controller/person/mod.rs +++ b/backend/src/controller/person/mod.rs @@ -1,5 +1,3 @@ -use std::fmt::format; - use reqwest::Client; use rocket::http::Status; use rocket::serde::json::Json; diff --git a/frontend/src/certs/Search/index.tsx b/frontend/src/certs/Search/index.tsx index 666e421..c187df4 100644 --- a/frontend/src/certs/Search/index.tsx +++ b/frontend/src/certs/Search/index.tsx @@ -6,8 +6,9 @@ import { XIcon } from "../../icons/XIcon"; import { Person } from "../../types/Person"; import { PersonDisplay } from "./PersonDisplay"; import { PersonRegister } from "./PersonRegister"; -import { backend } from "../../utils/functions"; +import { backend, wait } from "../../utils/functions"; import { JsonResult } from "../../types/JsonResult"; +import { LoadingIcon } from "../../icons/LoadingIcon"; type HTMLButtonEvent = JSX.EventHandlerUnion; @@ -46,10 +47,12 @@ export function Search(props: {setPerson: (p: Person | null) => void}) { /* Get the user data from the DB */ - const search = () => { + const search = async() => { setLoading(true); setError(""); + await wait(1500); + backend.get>(`/api/person/${dni()}`) .then((response) => { if (response.status === 200) { @@ -155,6 +158,13 @@ function InputBox(props: { + + + +