From b24097d633708390dca188ac1160e040bf9afa8b Mon Sep 17 00:00:00 2001 From: Kenneth Chen Date: Sat, 22 Apr 2023 15:02:18 -0400 Subject: [PATCH 1/2] Simplify org menu search logic --- client/src/components/LoginModal/index.tsx | 26 ++++------------------ 1 file changed, 4 insertions(+), 22 deletions(-) diff --git a/client/src/components/LoginModal/index.tsx b/client/src/components/LoginModal/index.tsx index 6fcb096a..4476e194 100644 --- a/client/src/components/LoginModal/index.tsx +++ b/client/src/components/LoginModal/index.tsx @@ -21,26 +21,7 @@ const LoginModal = () => { })(); }, []); - useEffect(() => { - console.log(selectedOrg); - }, [selectedOrg]); - - function searchOrg(value: string) { - if (orgs.length > 0) { - const find = orgs.find((i: any) => - query.localeCompare(i.name, undefined, { sensitivity: 'accent' }) - ); - if (find) { - setSelectedOrg(find.name); - setQuery(find.name); - } else { - setQuery(value); - } - } - } - function onLogin() { - console.log(pwd); if (selectedOrg) { fetch('/api/auth/login', { method: 'POST', @@ -56,6 +37,7 @@ const LoginModal = () => { }); } } + const filteredOrgs = query === '' ? orgs @@ -72,7 +54,7 @@ const LoginModal = () => { className="w-[50px] my-6" src="/images/projectpeach.png" alt="Project Peach Logo" - > + />

Organization Login

@@ -86,7 +68,7 @@ const LoginModal = () => {
searchOrg(event.target.value)} + onChange={(event) => setQuery(event.target.value)} placeholder="select your organization" className="border-0 pl-3 py-1 rounded-xs bg-transparent flex-grow focus:bg-slate-50 focus:ring-inset focus:ring-[1px] ring-offset-0 " /> @@ -141,7 +123,7 @@ const LoginModal = () => { onChange={(event) => setPwd(event.target.value)} className="input w-full px-4 py-2" placeholder="Organization password" - > + />