diff --git a/src/components/Activities/AttendcesLogs.jsx b/src/components/Activities/AttendcesLogs.jsx
index f1d8e008..f55a4965 100644
--- a/src/components/Activities/AttendcesLogs.jsx
+++ b/src/components/Activities/AttendcesLogs.jsx
@@ -20,14 +20,21 @@ import { SpinnerLoader } from "../common/Loader";
const usePagination = (data, itemsPerPage) => {
const [currentPage, setCurrentPage] = useState(1);
- const maxPage = Math.ceil(data.length / itemsPerPage);
+ // const maxPage = Math.ceil(data.length / itemsPerPage);
+ const maxPage = Math.max(1, Math.ceil(data.length / itemsPerPage));
const currentItems = useMemo(() => {
const startIndex = (currentPage - 1) * itemsPerPage;
const endIndex = startIndex + itemsPerPage;
return data.slice(startIndex, endIndex);
}, [data, currentPage, itemsPerPage]);
- const paginate = useCallback((pageNumber) => setCurrentPage(pageNumber), []);
+ // const paginate = useCallback((pageNumber) => setCurrentPage(pageNumber), []);
+
+ const paginate = useCallback((pageNumber) => {
+ // keep page within 1..maxPage
+ const p = Math.max(1, Math.min(pageNumber, maxPage));
+ setCurrentPage(p);
+ }, [maxPage]);
const resetPage = useCallback(() => setCurrentPage(1), []);
return {
@@ -36,6 +43,7 @@ const usePagination = (data, itemsPerPage) => {
currentItems,
paginate,
resetPage,
+ setCurrentPage,
};
};
@@ -125,9 +133,16 @@ const AttendanceLog = ({ handleModalData, searchTerm, organizationId }) => {
resetPage,
} = usePagination(filteredSearchData, 20);
+ // useEffect(() => {
+ // resetPage();
+ // }, [filteredSearchData]);
+
useEffect(() => {
- resetPage();
- }, [filteredSearchData]);
+ if (currentPage > totalPages) {
+ paginate(totalPages || 1);
+ }
+ // NOTE: do NOT force reset to page 1 here — keep the same page if still valid
+ }, [filteredSearchData, totalPages, currentPage, paginate]);
const handler = useCallback(
(msg) => {
@@ -144,10 +159,9 @@ const AttendanceLog = ({ handleModalData, searchTerm, organizationId }) => {
record.id === msg.response.id ? { ...record, ...msg.response } : record
);
});
- resetPage();
}
},
- [selectedProject, dateRange, resetPage]
+ [selectedProject, dateRange]
);
useEffect(() => {
@@ -214,7 +228,7 @@ const AttendanceLog = ({ handleModalData, searchTerm, organizationId }) => {
{isLoading ? (
diff --git a/src/components/Directory/NoteCardDirectoryEditable.jsx b/src/components/Directory/NoteCardDirectoryEditable.jsx
index bc6ff517..49eba918 100644
--- a/src/components/Directory/NoteCardDirectoryEditable.jsx
+++ b/src/components/Directory/NoteCardDirectoryEditable.jsx
@@ -9,6 +9,7 @@ import ConfirmModal from "../common/ConfirmModal"; // Make sure path is correct
import "../common/TextEditor/Editor.css";
import GlobalModel from "../common/GlobalModel";
import { useActiveInActiveNote, useUpdateNote } from "../../hooks/useDirectory";
+import { useDirectoryContext } from "../../pages/Directory/DirectoryPage";
const NoteCardDirectoryEditable = ({
noteItem,
@@ -22,14 +23,14 @@ const NoteCardDirectoryEditable = ({
const [isDeleting, setIsDeleting] = useState(false);
const [isRestoring, setIsRestoring] = useState(false);
const [isDeleteModalOpen, setIsDeleteModalOpen] = useState(false);
- const [open_contact, setOpen_contact] = useState(null);
- const [isOpenModalNote, setIsOpenModalNote] = useState(false);
const { mutate: UpdateNote, isPending: isUpatingNote } = useUpdateNote(() =>
setEditing(false)
);
const { mutate: ActiveInactive, isPending: isUpdatingStatus } =
useActiveInActiveNote(() => setIsDeleteModalOpen(false));
+ const { setContactOpen } = useDirectoryContext();
+
const handleUpdateNote = async () => {
const payload = {
@@ -45,12 +46,6 @@ const NoteCardDirectoryEditable = ({
ActiveInactive({ noteId: noteItem.id, noteStatus: !noteItem.isActive });
};
- const contactProfile = (contactId) => {
- DirectoryRepository.GetContactProfile(contactId).then((res) => {
- setOpen_contact(res?.data);
- setIsOpenModalNote(true);
- });
- };
const handleRestore = async () => {
try {
@@ -88,7 +83,9 @@ const NoteCardDirectoryEditable = ({
contactProfile(noteItem.contactId)}
+ onClick={() =>
+ setContactOpen({ contact: { id: noteItem.contactId }, Open: true })
+ }
>
{noteItem?.contactName} {" "}
@@ -97,6 +94,7 @@ const NoteCardDirectoryEditable = ({
+
diff --git a/src/components/ServiceProject/ServiceProjectJob/ManageJob.jsx b/src/components/ServiceProject/ServiceProjectJob/ManageJob.jsx
index cc2066e0..94ced5c3 100644
--- a/src/components/ServiceProject/ServiceProjectJob/ManageJob.jsx
+++ b/src/components/ServiceProject/ServiceProjectJob/ManageJob.jsx
@@ -140,6 +140,7 @@ const ManageJob = ({ Job }) => {
formData.projectId = projectId;
CreateJob(formData);
+ setManageJob({ isOpen: false, jobId: null });
}
};
diff --git a/src/components/Tenant/OrganizationInfo.jsx b/src/components/Tenant/OrganizationInfo.jsx
index 1e166423..9cfdcb7f 100644
--- a/src/components/Tenant/OrganizationInfo.jsx
+++ b/src/components/Tenant/OrganizationInfo.jsx
@@ -58,12 +58,12 @@ const OrganizationInfo = ({ onNext, onPrev, onSubmitTenant }) => {
};
useEffect(() => {
- const logoImage = getValues("logoImage");
- if (logoImage) {
- setLogoPreview(logoImage);
- setLogoName("Uploaded Logo");
- }
-}, [getValues]);
+ const logoImage = getValues("logoImage");
+ if (logoImage) {
+ setLogoPreview(logoImage);
+ setLogoName("Uploaded Logo");
+ }
+ }, [getValues]);
return (
@@ -134,7 +134,7 @@ const OrganizationInfo = ({ onNext, onPrev, onSubmitTenant }) => {
control={control}
placeholder="DD-MM-YYYY"
maxDate={new Date()}
- className={errors.onBoardingDate ? "is-invalid" : ""}
+ className={`w-100 ${errors.onBoardingDate ? "is-invalid" : ""}`}
/>
{errors.onBoardingDate && (
@@ -210,7 +210,7 @@ const OrganizationInfo = ({ onNext, onPrev, onSubmitTenant }) => {
-
{
/>
)}
- {group.name}
+ {group.name}
diff --git a/src/hooks/useTenant.js b/src/hooks/useTenant.js
index 7e2b9ecf..6803d784 100644
--- a/src/hooks/useTenant.js
+++ b/src/hooks/useTenant.js
@@ -132,7 +132,7 @@ export const useAddSubscription = (onSuccessCallback) => {
onSuccess: (data, variables) => {
const { tenantId } = variables;
showToast("Tenant Plan Added SuccessFully", "success");
- queryClient.invalidateQueries({ queryKey: ["Tenant", tenantId] });
+ queryClient.invalidateQueries({ queryKey: ["Tenants", tenantId] });
if (onSuccessCallback) onSuccessCallback();
},
onError: (error) => {