From fd5ed8aa4f159c8e1c0476915432e0a97a239a91 Mon Sep 17 00:00:00 2001 From: Vidhu Kant Sharma Date: Sat, 1 Oct 2022 19:48:06 +0530 Subject: fixed warning 'component changing controlled input to uncontrolled' while editing shipping addresses --- src/views/manage/clients.js | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'src/views') 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 ( <> - +
- + + + {JSON.stringify(clientToEdit) !== JSON.stringify(new Client()) && +
+ setClientToEdit(new Client())} + editing={true} + callback={updateList}/> +
+ } ); } -- cgit v1.2.3