From 29ef1e4016a822dafcb46bac8b0b966655b6046c Mon Sep 17 00:00:00 2001 From: Pramod Mahajan Date: Tue, 3 Jun 2025 00:09:33 +0530 Subject: [PATCH] enhance UX for loading and empty states in contact table --- src/pages/Directory/Directory.jsx | 253 ++++++++++++++++-------------- 1 file changed, 137 insertions(+), 116 deletions(-) diff --git a/src/pages/Directory/Directory.jsx b/src/pages/Directory/Directory.jsx index 6b89127a..dc6661de 100644 --- a/src/pages/Directory/Directory.jsx +++ b/src/pages/Directory/Directory.jsx @@ -319,124 +319,145 @@ const handleDeleteContact = async (overrideId = null) => { )} -
- - {!listView && loading &&

Loading...

} - {!listView && !loading && currentItems.length == 0 && ( -

No Matching Contact Found

- )} - {listView ? ( - - {loading && ( - - Loading... - - )} - {!loading && currentItems.length === 0 && ( - - No Matching Contact Found - - )} - {!loading && - currentItems.map((contact) => ( - - ))} - - ) : ( -
- {!loading && currentItems.map((contact, index) => ( -
- -
- ))} -
- )} - - +
+ - {!loading && currentItems < ITEMS_PER_PAGE && ( -
+ )} + + {/* Table view (listView === true) */} + {listView ? ( + + {loading && ( + + Loading... + + )} + + {!loading && contacts?.length === 0 && ( + + No contact found + + )} + + {!loading && currentItems.length === 0 && contacts?.length > 0 && ( + + No matching contact found + + )} + + {!loading && + currentItems.map((contact) => ( + + ))} + + ) : ( +
+ {!loading && + currentItems.map((contact) => ( +
+ +
+ ))} +
+ )} + + {/* Pagination */} + {!loading && + contacts?.length > 0 && + currentItems.length < ITEMS_PER_PAGE && ( + - )} -
+ {index + 1} + + + ))} + +
  • + +
  • + + + )} + + + ); };