diff --git a/src/components/Directory/NotesDirectory.jsx b/src/components/Directory/NotesDirectory.jsx index 4bb6b382..43cd9029 100644 --- a/src/components/Directory/NotesDirectory.jsx +++ b/src/components/Directory/NotesDirectory.jsx @@ -22,10 +22,7 @@ const NotesDirectory = ({ setProfileContact, }) => { const [IsActive, setIsActive] = useState(true); - const { contactNotes, refetch } = useContactNotes( - contactProfile?.id, - IsActive - ); + const { contactNotes, refetch } = useContactNotes(contactProfile?.id, IsActive); const [IsSubmitting, setIsSubmitting] = useState(false); const [showEditor, setShowEditor] = useState(false); @@ -70,10 +67,7 @@ const NotesDirectory = ({ ...cached_contactProfile.data, notes: [...(cached_contactProfile.data.notes || []), createdNote], }; - cacheData("Contact Profile", { - contactId: contactProfile?.id, - data: updatedProfile, - }); + cacheData("Contact Profile", { contactId: contactProfile?.id, data: updatedProfile }); } setValue("note", ""); @@ -104,13 +98,10 @@ const NotesDirectory = ({ }; // Use the fullName from contactProfile, which now includes middle and last names if available - const contactName = - contactProfile?.fullName || contactProfile?.firstName || "Contact"; + const contactName = contactProfile?.fullName || contactProfile?.firstName || "Contact"; const noNotesMessage = `Be the first to share your insights! ${contactName} currently has no notes.`; - const notesToDisplay = IsActive - ? contactProfile?.notes || [] - : contactNotes || []; + const notesToDisplay = IsActive ? (contactProfile?.notes || []) : (contactNotes || []); return (
@@ -202,28 +193,31 @@ const NotesDirectory = ({

Loading...

{" "}
)} - {!isLoading && notesToDisplay.length > 0 - ? notesToDisplay - .slice() - .reverse() - .map((noteItem) => ( - - )) - : !isLoading && - !showEditor && ( -
{noNotesMessage}
- )} + {!isLoading && notesToDisplay.length > 0 ? ( + notesToDisplay + .slice() + .reverse() + .map((noteItem) => ( + + )) + ) : ( + !isLoading && !showEditor && ( +
+ {noNotesMessage} +
+ ) + )} ); }; -export default NotesDirectory; +export default NotesDirectory; \ No newline at end of file diff --git a/src/pages/Activities/AttendancePage.jsx b/src/pages/Activities/AttendancePage.jsx index f65d06c8..65cd069d 100644 --- a/src/pages/Activities/AttendancePage.jsx +++ b/src/pages/Activities/AttendancePage.jsx @@ -8,7 +8,6 @@ import { import Breadcrumb from "../../components/common/Breadcrumb"; import AttendanceLog from "../../components/Activities/AttendcesLogs"; import Attendance from "../../components/Activities/Attendance"; -// import AttendanceModel from "../../components/Activities/AttendanceModel"; import showToast from "../../services/toastService"; import Regularization from "../../components/Activities/Regularization"; import { useAttendance } from "../../hooks/useAttendance"; @@ -18,12 +17,12 @@ import { markCurrentAttendance } from "../../slices/apiSlice/attendanceAllSlice" import { useHasUserPermission } from "../../hooks/useHasUserPermission"; import { REGULARIZE_ATTENDANCE } from "../../utils/constants"; import eventBus from "../../services/eventBus"; -// import AttendanceRepository from "../../repositories/AttendanceRepository"; +import AttendanceRepository from "../../repositories/AttendanceRepository"; // Make sure this is imported if used import { useProjectName } from "../../hooks/useProjects"; import GlobalModel from "../../components/common/GlobalModel"; import CheckCheckOutmodel from "../../components/Activities/CheckCheckOutForm"; import AttendLogs from "../../components/Activities/AttendLogs"; -// import Confirmation from "../../components/Activities/Confirmation"; +import Confirmation from "../../components/Activities/Confirmation"; // Make sure this is imported if used import { useQueryClient } from "@tanstack/react-query"; const AttendancePage = () => { @@ -37,7 +36,7 @@ const AttendancePage = () => { attendance, loading: attLoading, recall: attrecall, - } = useAttendace(selectedProject); + } = useAttendance(selectedProject); // Corrected typo: useAttendace to useAttendance const [attendances, setAttendances] = useState(); const [empRoles, setEmpRoles] = useState(null); const [isCreateModalOpen, setIsCreateModalOpen] = useState(false); @@ -58,10 +57,10 @@ const AttendancePage = () => { // Ensure attendances is not null before mapping const updatedAttendance = attendances ? attendances.map((item) => - item.employeeId === msg.response.employeeId - ? { ...item, ...msg.response } - : item - ) + item.employeeId === msg.response.employeeId + ? { ...item, ...msg.response } + : item + ) : [msg.response]; // If attendances is null, initialize with new response cacheData("Attendance", { @@ -71,12 +70,13 @@ const AttendancePage = () => { setAttendances(updatedAttendance); } }, - [selectedProject, attendances] // Removed attrecall as it's not a direct dependency for this state update + [selectedProject, attendances] ); const employeeHandler = useCallback( (msg) => { if (attendances?.some((item) => item.employeeId === msg.employeeId)) { + // Ensure AttendanceRepository is imported and available AttendanceRepository.getAttendance(selectedProject) .then((response) => { cacheData("Attendance", { data: response.data, selectedProject }); @@ -127,10 +127,10 @@ const AttendancePage = () => { if (action.payload && action.payload.employeeId) { const updatedAttendance = attendances ? attendances.map((item) => - item.employeeId === action.payload.employeeId - ? { ...item, ...action.payload } - : item - ) + item.employeeId === action.payload.employeeId + ? { ...item, ...action.payload } + : item + ) : [action.payload]; // If attendances is null, initialize with new payload cacheData("Attendance", { @@ -151,6 +151,7 @@ const AttendancePage = () => { const handleToggle = (event) => { setShowPending(event.target.checked); }; + useEffect(() => { if (selectedProject === null && projectNames.length > 0) { dispatch(setProjectId(projectNames[0]?.id)); @@ -162,8 +163,8 @@ const AttendancePage = () => { if (modelConfig !== null) { openModel(); } - }, [modelConfig]); // Removed isCreateModalOpen from here as it's set by openModel() - + }, [modelConfig]); + useEffect(() => { setAttendances(attendance); }, [attendance]); @@ -204,27 +205,8 @@ const AttendancePage = () => { return () => eventBus.off("attendance", handler); }, [handler]); - // useEffect(() => { - // eventBus.on("employee", employeeHandler); - // return () => eventBus.off("employee", employeeHandler); - // }, [employeeHandler]); return ( <> - {/* {isCreateModalOpen && modelConfig && ( - - )} */} {isCreateModalOpen && modelConfig && ( {
{activeTab === "all" && ( -
- -
- )} +
+ {!attLoading && filteredAndSearchedTodayAttendance()?.length === 0 && (

{" "} @@ -327,7 +307,7 @@ const AttendancePage = () => { : "No Employee assigned yet."}{" "}

)} - +
)} {activeTab === "logs" && (