From 92b6da1d37da9232f1f40ac2526b189289049534 Mon Sep 17 00:00:00 2001 From: MikunoNaka Date: Mon, 13 Sep 2021 17:25:51 +0530 Subject: created new new address component for unlimited addresses --- src/components/Form/People/RegisterPersonForm.tsx | 132 +++------------------- 1 file changed, 17 insertions(+), 115 deletions(-) (limited to 'src/components/Form/People') diff --git a/src/components/Form/People/RegisterPersonForm.tsx b/src/components/Form/People/RegisterPersonForm.tsx index 3fc8b32..9c8752d 100644 --- a/src/components/Form/People/RegisterPersonForm.tsx +++ b/src/components/Form/People/RegisterPersonForm.tsx @@ -7,9 +7,10 @@ */ import React, { useState } from "react"; -import "./../Form.scss"; -import { Person } from "./../../../interfaces" +import NewAddressPane from "./../Address/NewAddressPane" +import { Person, Address } from "./../../../Interfaces/interfaces" import axios from "axios"; +import "./../Form.scss"; interface props { setVisibility: any // this component's visibility @@ -23,12 +24,13 @@ const RegisterPersonForm: React.FC = (props) => { const [shipToBillAddress, setShipToBillAddress] = useState(true); - const [newPersonBillAddressLine, setNewPersonBillAddressLine] = useState(""); - const [newPersonBillCity, setNewPersonBillCity] = useState(""); - const [newPersonBillState, setNewPersonBillState] = useState(""); - const [newPersonBillPINCode, setNewPersonBillPINCode] = useState(""); - const [newPersonBillCountry, setNewPersonBillCountry] = useState(""); - + const [newPersonBillAddress, setNewPersonBillAddress] = useState
({ + AddressLine: "", + City: "", + State: "", + PINCode: "", + Country: "" + }) const hideSelf = () => props.setVisibility(false); @@ -43,26 +45,15 @@ const RegisterPersonForm: React.FC = (props) => { Phone: newPersonPhone, Email: newPersonEmail, - BillAddress: { - AddressLine: newPersonBillAddressLine, - City: newPersonBillCity, - State: newPersonBillState, - PINCode: newPersonBillPINCode, - Country: newPersonBillCountry - }, - - // currently same as BillAddress - ShipAddress: { - AddressLine: newPersonBillAddressLine, - City: newPersonBillCity, - State: newPersonBillState, - PINCode: newPersonBillPINCode, - Country: newPersonBillCountry - }, + BillAddress: newPersonBillAddress, + ShipAddress: shipToBillAddress + ? newPersonBillAddress + // TODO: use shipping address(es) instead + : newPersonBillAddress, } // TODO: show confirmation before being invisible - // TODO: Implement override protection + // TODO: Implement overwrite protection axios.post("/api/people/register", newClient) .then((res) => { console.log(res); @@ -111,96 +102,7 @@ const RegisterPersonForm: React.FC = (props) => { -
-

Billing Address

- - - - - - - - - - -
- - {shipToBillAddress || // TODO: Make it store different data - // TODO: maybe move it to its own prop -
-

Shipping Address

- - - - - - - - - - -
- } +