From e66ce11cd57f5c999b2e57b92d8bfb6835c1a709 Mon Sep 17 00:00:00 2001 From: pramod mahajan Date: Wed, 3 Sep 2025 16:40:20 +0530 Subject: [PATCH] changes tage reponse and changed confirm modal format --- src/components/Directory/ManageBucket.jsx | 99 +++++++-------- .../Directory/NoteCardDirectoryEditable.jsx | 71 +++++------ src/components/Documents/DocumentsList.jsx | 27 ++-- src/components/Employee/EmployeeList.jsx | 2 +- src/components/Expenses/ExpenseList.jsx | 35 ++---- .../Project/Infrastructure/WorkItem.jsx | 36 ++---- src/components/Project/Teams.jsx | 29 ++--- src/components/common/TagInput.jsx | 57 +++++---- src/pages/Directory/Directory.jsx | 58 ++++----- src/pages/employee/EmployeeList.jsx | 116 +++++++++--------- 10 files changed, 246 insertions(+), 284 deletions(-) diff --git a/src/components/Directory/ManageBucket.jsx b/src/components/Directory/ManageBucket.jsx index 58344a15..5cbd89c4 100644 --- a/src/components/Directory/ManageBucket.jsx +++ b/src/components/Directory/ManageBucket.jsx @@ -198,23 +198,14 @@ const ManageBucket = () => { return ( <> {deleteBucket && ( -
- setDeleteBucket(null)} - /> -
+ setDeleteBucket(null)} + /> )}
@@ -237,8 +228,9 @@ const ManageBucket = () => { onChange={(e) => setSearchTerm(e.target.value)} /> refetch()} /> @@ -247,8 +239,9 @@ const ManageBucket = () => {
)} - {!loading && buckets.length > 0 && sortedBucktesList.length === 0 && ( -
-
- No matching buckets found. + {!loading && + buckets.length > 0 && + sortedBucktesList.length === 0 && ( +
+
+ No matching buckets found. +
-
- )} + )} {!loading && sortedBucktesList.map((bucket) => (
@@ -305,29 +300,29 @@ const ManageBucket = () => { {(DirManager || DirAdmin || bucket?.createdBy?.id === - profile?.employeeInfo?.id) && ( -
- { - select_bucket(bucket); - setAction_bucket(true); - const initialSelectedEmployees = employeesList - .filter((emp) => - bucket.employeeIds?.includes( - emp.employeeId - ) + profile?.employeeInfo?.id) && ( +
+ { + select_bucket(bucket); + setAction_bucket(true); + const initialSelectedEmployees = employeesList + .filter((emp) => + bucket.employeeIds?.includes( + emp.employeeId ) - .map((emp) => ({ ...emp, isActive: true })); - setSelectEmployee(initialSelectedEmployees); - }} - > - setDeleteBucket(bucket?.id)} - > -
- )} + ) + .map((emp) => ({ ...emp, isActive: true })); + setSelectEmployee(initialSelectedEmployees); + }} + >
+ setDeleteBucket(bucket?.id)} + > +
+ )}
Contacts:{" "} diff --git a/src/components/Directory/NoteCardDirectoryEditable.jsx b/src/components/Directory/NoteCardDirectoryEditable.jsx index 5ccfefdf..abf33314 100644 --- a/src/components/Directory/NoteCardDirectoryEditable.jsx +++ b/src/components/Directory/NoteCardDirectoryEditable.jsx @@ -33,7 +33,10 @@ const NoteCardDirectoryEditable = ({ note: editorValue, contactId, }; - const response = await DirectoryRepository.UpdateNote(noteItem.id, payload); + const response = await DirectoryRepository.UpdateNote( + noteItem.id, + payload + ); const cachedContactProfile = getCachedData("Contact Profile"); if (cachedContactProfile?.contactId === contactId) { @@ -75,9 +78,9 @@ const NoteCardDirectoryEditable = ({ const contactProfile = (contactId) => { DirectoryRepository.GetContactProfile(contactId).then((res) => { - setOpen_contact(res?.data); - setIsOpenModalNote(true); - }); + setOpen_contact(res?.data); + setIsOpenModalNote(true); + }); }; const handleRestore = async () => { @@ -95,7 +98,6 @@ const NoteCardDirectoryEditable = ({ return ( <> - {isOpenModalNote && (
-
-
contactProfile(noteItem.contactId)}> +
contactProfile(noteItem.contactId)} + > - {noteItem?.contactName} + {noteItem?.contactName} {" "} + ({noteItem?.organizationName}) - -
-
- -
+
- by {noteItem?.createdBy?.firstName} {noteItem?.createdBy?.lastName} -   - on {moment + by{" "} + + {" "} + {noteItem?.createdBy?.firstName}{" "} + {noteItem?.createdBy?.lastName}{" "} + +  {" "} + + on{" "} + {moment .utc(noteItem?.createdAt) .add(5, "hours") .add(30, "minutes") .format("DD MMMM, YYYY [at] hh:mm A")} -
@@ -228,26 +235,16 @@ const NoteCardDirectoryEditable = ({ {/* Delete Confirm Modal */} {isDeleteModalOpen && ( -
- setIsDeleteModalOpen(false)} - loading={isDeleting} - paramData={noteItem} - /> -
+ setIsDeleteModalOpen(false)} + loading={isDeleting} + paramData={noteItem} + /> )} ); diff --git a/src/components/Documents/DocumentsList.jsx b/src/components/Documents/DocumentsList.jsx index 35fff652..0a568264 100644 --- a/src/components/Documents/DocumentsList.jsx +++ b/src/components/Documents/DocumentsList.jsx @@ -156,23 +156,16 @@ const DocumentsList = ({ return ( <> {IsDeleteModalOpen && ( -
- setIsDeleteModalOpen(false)} - loading={!!isPending} - paramData={deletingId} - /> -
+ setIsDeleteModalOpen(false)} + loading={!!isPending} + paramData={deletingId} + /> )}
diff --git a/src/components/Employee/EmployeeList.jsx b/src/components/Employee/EmployeeList.jsx index 2ae93d5e..5a79c6ce 100644 --- a/src/components/Employee/EmployeeList.jsx +++ b/src/components/Employee/EmployeeList.jsx @@ -4,4 +4,4 @@ const EmployeeList = () => { return
EmployeeList
; }; -export default EmployeeList; +export default EmployeeList; \ No newline at end of file diff --git a/src/components/Expenses/ExpenseList.jsx b/src/components/Expenses/ExpenseList.jsx index 92fb1bc1..c18d2650 100644 --- a/src/components/Expenses/ExpenseList.jsx +++ b/src/components/Expenses/ExpenseList.jsx @@ -110,8 +110,9 @@ const ExpenseList = ({ filters, groupBy = "transactionDate", searchText }) => { label: "Submitted By", align: "text-start", getValue: (e) => - `${e.createdBy?.firstName ?? ""} ${e.createdBy?.lastName ?? ""}`.trim() || - "N/A", + `${e.createdBy?.firstName ?? ""} ${ + e.createdBy?.lastName ?? "" + }`.trim() || "N/A", customRender: (e) => (
{ return ( <> {IsDeleteModalOpen && ( -
- setIsDeleteModalOpen(false)} - loading={isPending} - paramData={deletingId} - /> -
+ setIsDeleteModalOpen(false)} + loading={isPending} + paramData={deletingId} + /> )}
diff --git a/src/components/Project/Infrastructure/WorkItem.jsx b/src/components/Project/Infrastructure/WorkItem.jsx index 241f5e33..43e41729 100644 --- a/src/components/Project/Infrastructure/WorkItem.jsx +++ b/src/components/Project/Infrastructure/WorkItem.jsx @@ -32,8 +32,8 @@ const WorkItem = ({ forWorkArea, deleteHandleTask, }) => { - const projectId = useSelector((store)=>store.localVariables.projectId) -const isTaskPlanning = /^\/activities\/task$/.test(location.pathname); + const projectId = useSelector((store) => store.localVariables.projectId); + const isTaskPlanning = /^\/activities\/task$/.test(location.pathname); const [itemName, setItemName] = useState(""); const [NewWorkItem, setNewWorkItem] = useState(); @@ -135,25 +135,15 @@ const isTaskPlanning = /^\/activities\/task$/.test(location.pathname); )} {showModal2 && ( -
- -
+ )} @@ -240,9 +230,7 @@ const isTaskPlanning = /^\/activities\/task$/.test(location.pathname); {(ManageInfra || - ( - ManageAndAssignTak && - PlannedWork !== CompletedWork)) && ( + (ManageAndAssignTak && PlannedWork !== CompletedWork)) && ( {/* Desktop (md and up): inline icons */}
diff --git a/src/components/Project/Teams.jsx b/src/components/Project/Teams.jsx index cb725e30..49d4e0fd 100644 --- a/src/components/Project/Teams.jsx +++ b/src/components/Project/Teams.jsx @@ -249,26 +249,15 @@ const Teams = () => {
{IsDeleteModal && ( -
- -
+ removeAllocation(deleteEmployee)} + onClose={closeDeleteModal} + loading={isPending} + /> )}
diff --git a/src/components/common/TagInput.jsx b/src/components/common/TagInput.jsx index b31a7456..c1830d10 100644 --- a/src/components/common/TagInput.jsx +++ b/src/components/common/TagInput.jsx @@ -3,13 +3,15 @@ import { useFormContext } from "react-hook-form"; const TagInput = ({ label, name, placeholder, color = "#e9ecef", options = [] }) => { const { setValue, watch } = useFormContext(); - const tags = watch(name) || []; + const tags = watch(name) || []; const [input, setInput] = useState(""); const [suggestions, setSuggestions] = useState([]); const handleAdd = (newTag) => { - if (!tags.some((t) => t.name === newTag)) { - setValue(name, [...tags, { name: newTag, isActive: true }], { shouldValidate: true }); + const tagObj = typeof newTag === "string" ? { name: newTag, isActive: true } : newTag; + + if (!tags.some((t) => t.name === tagObj.name)) { + setValue(name, [...tags, tagObj], { shouldValidate: true }); } }; @@ -30,26 +32,32 @@ const TagInput = ({ label, name, placeholder, color = "#e9ecef", options = [] }) } }; - const handleChange = (e) => { - const val = e.target.value; - setInput(val); - if (val) { - setSuggestions( - options - .filter( - (opt) => - opt.toLowerCase().includes(val.toLowerCase()) && - !tags.some((t) => t.name === opt) - ) - .map((s) => ({ name: s, isActive: true })) - ); - } else { - setSuggestions([]); - } - }; +const handleChange = (e) => { + const val = e.target.value; + setInput(val); + + if (val) { + setSuggestions( + options + .filter((opt) => { + const label = typeof opt === "string" ? opt : opt.name; + return ( + label.toLowerCase().includes(val.toLowerCase()) && + !tags.some((t) => t.name === label) + ); + }) + .map((opt) => ({ + name: typeof opt === "string" ? opt : opt.name, + isActive: true, + })) + ); + } else { + setSuggestions([]); + } +}; const handleSuggestionClick = (sugg) => { - handleAdd(sugg.name); + handleAdd(sugg); setInput(""); setSuggestions([]); }; @@ -60,7 +68,10 @@ const TagInput = ({ label, name, placeholder, color = "#e9ecef", options = [] }) {label} -
+
{tags.map((tag, index) => ( { )} {deleteContact && ( -
- setDeleteContact(null)} - loading={IsDeleting} - /> -
+ setDeleteContact(null)} + loading={IsDeleting} + /> )} {openBucketModal && ( @@ -383,12 +373,14 @@ const Directory = ({ IsPage = true, prefernceContacts }) => { {/* Empty state AFTER list */} {!loading && contacts?.length === 0 && ( -

No contact found

+

No contact found

)} {!loading && contacts?.length > 0 && currentItems.length === 0 && ( -

No matching contact found

+

+ No matching contact found +

)}
@@ -419,11 +411,9 @@ const Directory = ({ IsPage = true, prefernceContacts }) => { {!loading && contacts?.length === 0 && (

No contact found

)} - {!loading && - contacts?.length > 0 && - currentItems.length === 0 && ( -

No matching contact found

- )} + {!loading && contacts?.length > 0 && currentItems.length === 0 && ( +

No matching contact found

+ )}
)} @@ -446,7 +436,9 @@ const Directory = ({ IsPage = true, prefernceContacts }) => { currentItems.length > ITEMS_PER_PAGE && (
@@ -703,8 +704,9 @@ const EmployeeList = () => {