Compare commits
5 Commits
main
...
Issues_Nov
| Author | SHA1 | Date | |
|---|---|---|---|
| e8f6298f93 | |||
| da13e40fd5 | |||
| 9c02a4a925 | |||
| c975e54331 | |||
| 2109a5f1f1 |
@ -20,14 +20,21 @@ import { SpinnerLoader } from "../common/Loader";
|
|||||||
|
|
||||||
const usePagination = (data, itemsPerPage) => {
|
const usePagination = (data, itemsPerPage) => {
|
||||||
const [currentPage, setCurrentPage] = useState(1);
|
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 currentItems = useMemo(() => {
|
||||||
const startIndex = (currentPage - 1) * itemsPerPage;
|
const startIndex = (currentPage - 1) * itemsPerPage;
|
||||||
const endIndex = startIndex + itemsPerPage;
|
const endIndex = startIndex + itemsPerPage;
|
||||||
return data.slice(startIndex, endIndex);
|
return data.slice(startIndex, endIndex);
|
||||||
}, [data, currentPage, itemsPerPage]);
|
}, [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), []);
|
const resetPage = useCallback(() => setCurrentPage(1), []);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@ -36,6 +43,7 @@ const usePagination = (data, itemsPerPage) => {
|
|||||||
currentItems,
|
currentItems,
|
||||||
paginate,
|
paginate,
|
||||||
resetPage,
|
resetPage,
|
||||||
|
setCurrentPage,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -125,9 +133,16 @@ const AttendanceLog = ({ handleModalData, searchTerm, organizationId }) => {
|
|||||||
resetPage,
|
resetPage,
|
||||||
} = usePagination(filteredSearchData, 20);
|
} = usePagination(filteredSearchData, 20);
|
||||||
|
|
||||||
|
// useEffect(() => {
|
||||||
|
// resetPage();
|
||||||
|
// }, [filteredSearchData]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
resetPage();
|
if (currentPage > totalPages) {
|
||||||
}, [filteredSearchData]);
|
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(
|
const handler = useCallback(
|
||||||
(msg) => {
|
(msg) => {
|
||||||
@ -144,10 +159,9 @@ const AttendanceLog = ({ handleModalData, searchTerm, organizationId }) => {
|
|||||||
record.id === msg.response.id ? { ...record, ...msg.response } : record
|
record.id === msg.response.id ? { ...record, ...msg.response } : record
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
resetPage();
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[selectedProject, dateRange, resetPage]
|
[selectedProject, dateRange]
|
||||||
);
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -214,7 +228,7 @@ const AttendanceLog = ({ handleModalData, searchTerm, organizationId }) => {
|
|||||||
{isLoading ? (
|
{isLoading ? (
|
||||||
<div
|
<div
|
||||||
className="d-flex justify-content-center align-items-center"
|
className="d-flex justify-content-center align-items-center"
|
||||||
style={{ minHeight: "50vh" }}
|
style={{ minHeight: "50vh" }}
|
||||||
>
|
>
|
||||||
<SpinnerLoader />
|
<SpinnerLoader />
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -9,6 +9,7 @@ import ConfirmModal from "../common/ConfirmModal"; // Make sure path is correct
|
|||||||
import "../common/TextEditor/Editor.css";
|
import "../common/TextEditor/Editor.css";
|
||||||
import GlobalModel from "../common/GlobalModel";
|
import GlobalModel from "../common/GlobalModel";
|
||||||
import { useActiveInActiveNote, useUpdateNote } from "../../hooks/useDirectory";
|
import { useActiveInActiveNote, useUpdateNote } from "../../hooks/useDirectory";
|
||||||
|
import { useDirectoryContext } from "../../pages/Directory/DirectoryPage";
|
||||||
|
|
||||||
const NoteCardDirectoryEditable = ({
|
const NoteCardDirectoryEditable = ({
|
||||||
noteItem,
|
noteItem,
|
||||||
@ -22,14 +23,14 @@ const NoteCardDirectoryEditable = ({
|
|||||||
const [isDeleting, setIsDeleting] = useState(false);
|
const [isDeleting, setIsDeleting] = useState(false);
|
||||||
const [isRestoring, setIsRestoring] = useState(false);
|
const [isRestoring, setIsRestoring] = useState(false);
|
||||||
const [isDeleteModalOpen, setIsDeleteModalOpen] = 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(() =>
|
const { mutate: UpdateNote, isPending: isUpatingNote } = useUpdateNote(() =>
|
||||||
setEditing(false)
|
setEditing(false)
|
||||||
);
|
);
|
||||||
const { mutate: ActiveInactive, isPending: isUpdatingStatus } =
|
const { mutate: ActiveInactive, isPending: isUpdatingStatus } =
|
||||||
useActiveInActiveNote(() => setIsDeleteModalOpen(false));
|
useActiveInActiveNote(() => setIsDeleteModalOpen(false));
|
||||||
|
const { setContactOpen } = useDirectoryContext();
|
||||||
|
|
||||||
|
|
||||||
const handleUpdateNote = async () => {
|
const handleUpdateNote = async () => {
|
||||||
const payload = {
|
const payload = {
|
||||||
@ -45,12 +46,6 @@ const NoteCardDirectoryEditable = ({
|
|||||||
ActiveInactive({ noteId: noteItem.id, noteStatus: !noteItem.isActive });
|
ActiveInactive({ noteId: noteItem.id, noteStatus: !noteItem.isActive });
|
||||||
};
|
};
|
||||||
|
|
||||||
const contactProfile = (contactId) => {
|
|
||||||
DirectoryRepository.GetContactProfile(contactId).then((res) => {
|
|
||||||
setOpen_contact(res?.data);
|
|
||||||
setIsOpenModalNote(true);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleRestore = async () => {
|
const handleRestore = async () => {
|
||||||
try {
|
try {
|
||||||
@ -88,7 +83,9 @@ const NoteCardDirectoryEditable = ({
|
|||||||
<div>
|
<div>
|
||||||
<div
|
<div
|
||||||
className="d-flex ms-3 align-middle cursor-pointer"
|
className="d-flex ms-3 align-middle cursor-pointer"
|
||||||
onClick={() => contactProfile(noteItem.contactId)}
|
onClick={() =>
|
||||||
|
setContactOpen({ contact: { id: noteItem.contactId }, Open: true })
|
||||||
|
}
|
||||||
>
|
>
|
||||||
<span>
|
<span>
|
||||||
<span className="fw-bold "> {noteItem?.contactName} </span>{" "}
|
<span className="fw-bold "> {noteItem?.contactName} </span>{" "}
|
||||||
@ -97,6 +94,7 @@ const NoteCardDirectoryEditable = ({
|
|||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="d-flex ms-0 align-middle"></div>
|
<div className="d-flex ms-0 align-middle"></div>
|
||||||
<div className="d-flex ms-3 mt-2">
|
<div className="d-flex ms-3 mt-2">
|
||||||
<span className="text-muted">
|
<span className="text-muted">
|
||||||
|
|||||||
@ -140,6 +140,7 @@ const ManageJob = ({ Job }) => {
|
|||||||
formData.projectId = projectId;
|
formData.projectId = projectId;
|
||||||
|
|
||||||
CreateJob(formData);
|
CreateJob(formData);
|
||||||
|
setManageJob({ isOpen: false, jobId: null });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -58,12 +58,12 @@ const OrganizationInfo = ({ onNext, onPrev, onSubmitTenant }) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const logoImage = getValues("logoImage");
|
const logoImage = getValues("logoImage");
|
||||||
if (logoImage) {
|
if (logoImage) {
|
||||||
setLogoPreview(logoImage);
|
setLogoPreview(logoImage);
|
||||||
setLogoName("Uploaded Logo");
|
setLogoName("Uploaded Logo");
|
||||||
}
|
}
|
||||||
}, [getValues]);
|
}, [getValues]);
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -134,7 +134,7 @@ const OrganizationInfo = ({ onNext, onPrev, onSubmitTenant }) => {
|
|||||||
control={control}
|
control={control}
|
||||||
placeholder="DD-MM-YYYY"
|
placeholder="DD-MM-YYYY"
|
||||||
maxDate={new Date()}
|
maxDate={new Date()}
|
||||||
className={errors.onBoardingDate ? "is-invalid" : ""}
|
className={`w-100 ${errors.onBoardingDate ? "is-invalid" : ""}`}
|
||||||
/>
|
/>
|
||||||
{errors.onBoardingDate && (
|
{errors.onBoardingDate && (
|
||||||
<div className="invalid-feedback">
|
<div className="invalid-feedback">
|
||||||
@ -210,7 +210,7 @@ const OrganizationInfo = ({ onNext, onPrev, onSubmitTenant }) => {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="col-sm-6">
|
<div className="col-sm-6">
|
||||||
<SelectMultiple
|
<SelectMultiple
|
||||||
name="serviceIds"
|
name="serviceIds"
|
||||||
label="Services"
|
label="Services"
|
||||||
options={services?.data}
|
options={services?.data}
|
||||||
|
|||||||
@ -109,7 +109,7 @@ const ServiceGroups = ({ service }) => {
|
|||||||
/>
|
/>
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
<p className="m-0 fw-bold ">{group.name}</p>
|
<p className="m-0 ">{group.name}</p>
|
||||||
</div>
|
</div>
|
||||||
<div className="d-flex flex-row gap-3">
|
<div className="d-flex flex-row gap-3">
|
||||||
<div className="d-flex flex-row gap-2">
|
<div className="d-flex flex-row gap-2">
|
||||||
|
|||||||
@ -132,7 +132,7 @@ export const useAddSubscription = (onSuccessCallback) => {
|
|||||||
onSuccess: (data, variables) => {
|
onSuccess: (data, variables) => {
|
||||||
const { tenantId } = variables;
|
const { tenantId } = variables;
|
||||||
showToast("Tenant Plan Added SuccessFully", "success");
|
showToast("Tenant Plan Added SuccessFully", "success");
|
||||||
queryClient.invalidateQueries({ queryKey: ["Tenant", tenantId] });
|
queryClient.invalidateQueries({ queryKey: ["Tenants", tenantId] });
|
||||||
if (onSuccessCallback) onSuccessCallback();
|
if (onSuccessCallback) onSuccessCallback();
|
||||||
},
|
},
|
||||||
onError: (error) => {
|
onError: (error) => {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user