From ea88466fda6c719caa9daae5ea4698565fa84426 Mon Sep 17 00:00:00 2001 From: MikunoNaka Date: Tue, 15 Jun 2021 12:25:46 +0530 Subject: fixed some errors in SelectClientForm --- src/components/Form/People/SelectClientForm.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'src/components/Form/People') diff --git a/src/components/Form/People/SelectClientForm.js b/src/components/Form/People/SelectClientForm.js index 4c1e056..49aa4ed 100644 --- a/src/components/Form/People/SelectClientForm.js +++ b/src/components/Form/People/SelectClientForm.js @@ -12,33 +12,35 @@ import "./../Form.scss"; import ClientInfoDisplay from "../../Display/ClientInfoDisplay"; const SelectClientForm = (props) => { - const [clientName, setClientName] = useState(); const [selectedClient, setSelectedClient] = useState({}); const enterValuePrompt = "start typing here"; const registerPrompt = "add new"; + // TODO: make it use email if no address found, shorten the name too + // in short, make formatter flexible const formatter = (i) => { return `${i.Name} - ${i.Address.slice(0, 20).concat(i.Address.length < 20 ? "" : "")}`; } + // TODO: if no client found at least clear the display + // do this in other components too // check the client name value and do stuff accordingly - const setClientInfo = (clientName) => - (props.savedPeople === null || clientName === registerPrompt) + const setClientInfo = (e) => + (props.savedPeople === null || e === registerPrompt) ? alert("coming soon") // toggle registerPersonPrompt visibility - : props.savedPeople.some((i) => - clientName === formatter(i) && setSelectedClient(i)) - + : props.savedPeople.some((i) => + e === formatter(i) && setSelectedClient(i)) + return (