diff options
author | MikunoNaka <bokuwakanojogahoshii@yahoo.com> | 2021-08-08 16:11:08 +0530 |
---|---|---|
committer | MikunoNaka <bokuwakanojogahoshii@yahoo.com> | 2021-08-08 16:11:08 +0530 |
commit | 8c906c98b2a2994286731357831ca8005ef0d73f (patch) | |
tree | fd4f7a283e230d149099fe285ae7a56cda237e64 /src/components/Form/People/SelectClientForm.tsx | |
parent | 0f0e5f7408969fcc4473746919bb0e8aaa89947c (diff) |
Added better support for saving client data
Diffstat (limited to 'src/components/Form/People/SelectClientForm.tsx')
-rw-r--r-- | src/components/Form/People/SelectClientForm.tsx | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/components/Form/People/SelectClientForm.tsx b/src/components/Form/People/SelectClientForm.tsx index f91bf41..ca984ca 100644 --- a/src/components/Form/People/SelectClientForm.tsx +++ b/src/components/Form/People/SelectClientForm.tsx @@ -6,7 +6,7 @@ * Copyright (c) 2021 Vidhu Kant Sharma */ -import React, { useState } from "react"; +import React, { Dispatch, SetStateAction } from "react"; import { Person } from "./../../../interfaces"; import "./../Form.scss"; @@ -14,19 +14,19 @@ import ClientInfoDisplay from "../../Display/ClientInfoDisplay"; interface Props { savedPeople: Person[] + selectedClient: Person + setSelectedClient: Dispatch<SetStateAction<Person>> } const SelectClientForm: React.FC<Props> = (props) => { - // TODO: fix the default selectedClient - const [selectedClient, setSelectedClient] = useState<Person>({Name: "", Address: ""}); - 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: Person): string => - `${i.Name} - ${i.Address.slice(0, 20).concat(i.Address.length < 20 ? "" : "")}`; + // TODO: this shit is ugly + `${i.Name} - ${i.BillAddress.AddressLine.slice(0, 20).concat(i.BillAddress.AddressLine.length < 20 ? "" : "")}`; // TODO: if no client found at least clear the display // do this in other components too @@ -35,7 +35,7 @@ const SelectClientForm: React.FC<Props> = (props) => { (props.savedPeople === null || e === registerPrompt) ? alert("coming soon") // toggle registerPersonPrompt visibility : props.savedPeople.some((i) => - e === formatter(i) && setSelectedClient(i)) + e === formatter(i) && props.setSelectedClient(i)) return ( <div className={"documentInfoChild"}> @@ -43,7 +43,7 @@ const SelectClientForm: React.FC<Props> = (props) => { Client Name: <select className={"selectInputBox"} - value={selectedClient.Name} + value={props.selectedClient.Name} onChange={ (event) => { setClientInfo(event.target.value); @@ -59,7 +59,7 @@ const SelectClientForm: React.FC<Props> = (props) => { </select> </label> - <ClientInfoDisplay client={selectedClient}/> + <ClientInfoDisplay client={props.selectedClient}/> </div> ) } |