From 61ce554e05ce610051431a1347784c01fcb61727 Mon Sep 17 00:00:00 2001 From: Pramod Mahajan Date: Sun, 18 May 2025 16:57:06 +0530 Subject: [PATCH] prevent to reset form before calling api. --- src/pages/Directory/Directory.jsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/pages/Directory/Directory.jsx b/src/pages/Directory/Directory.jsx index f389167c..e7396339 100644 --- a/src/pages/Directory/Directory.jsx +++ b/src/pages/Directory/Directory.jsx @@ -23,13 +23,14 @@ const Directory = () => { const contacts_cache = getCachedData("contacts") || []; if (selectedContact) { - setSelectedContact(null); + response = await DirectoryRepository.UpdateContact(data.id, data); updatedContacts = contacts_cache.map((contact) => contact.id === data.id ? response.data : contact ); showToast("Contact updated successfully", "success"); - setIsOpenModal(false); + setIsOpenModal( false ); + setSelectedContact(null); } else { response = await DirectoryRepository.CreateContact(data); updatedContacts = [...contacts_cache, response.data];