aboutsummaryrefslogtreecommitdiff
path: root/src/views
diff options
context:
space:
mode:
authorVidhu Kant Sharma <vidhukant@vidhukant.xyz>2022-10-01 19:48:06 +0530
committerVidhu Kant Sharma <vidhukant@vidhukant.xyz>2022-10-01 19:48:06 +0530
commitfd5ed8aa4f159c8e1c0476915432e0a97a239a91 (patch)
tree42d3563472d9032c27f4e3a87dff85ec19362a94 /src/views
parente4dbf70d561aa3ed79379ffdb98661cb3f215fe9 (diff)
fixed warning 'component changing controlled input to uncontrolled' while editing shipping addresses
Diffstat (limited to 'src/views')
-rw-r--r--src/views/manage/clients.js25
1 files changed, 22 insertions, 3 deletions
diff --git a/src/views/manage/clients.js b/src/views/manage/clients.js
index 9d2209b..8445d80 100644
--- a/src/views/manage/clients.js
+++ b/src/views/manage/clients.js
@@ -22,11 +22,12 @@
import { useState, useEffect } from 'react';
import './scss/management-page.scss';
-import { getAllClients } from '../../classes/client';
+import { Client, getAllClients } from '../../classes/client';
import ClientEditor from './../../components/editors/client-editor';
import ClientTable from './../../components/tables/client-table';
const ManageClientsPage = () => {
+ const [clientToEdit, setClientToEdit] = useState(new Client());
const [allClients, setAllClients] = useState([]);
// TODO: handle error
const updateList = () =>
@@ -38,9 +39,27 @@ const ManageClientsPage = () => {
return (
<>
- <ClientEditor heading={"Add New Client"} successCallback={updateList}/>
+ <ClientEditor
+ heading={"Add New Client"}
+ client={new Client()}
+ successCallback={updateList}/>
<hr/>
- <ClientTable refresh={updateList} clients={allClients}/>
+ <ClientTable
+ refresh={updateList}
+ clients={allClients}
+ setClientToEdit={setClientToEdit}/>
+
+ {JSON.stringify(clientToEdit) !== JSON.stringify(new Client()) &&
+ <div className={"floating-wrapper"}>
+ <ClientEditor
+ className={"floating-window"}
+ heading={`Edit ${clientToEdit.Name ? clientToEdit.Name : 'Client'}:`}
+ client={clientToEdit}
+ hide={() => setClientToEdit(new Client())}
+ editing={true}
+ callback={updateList}/>
+ </div>
+ }
</>
);
}