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 [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 ? (
|
||||
<div
|
||||
className="d-flex justify-content-center align-items-center"
|
||||
style={{ minHeight: "50vh" }}
|
||||
style={{ minHeight: "50vh" }}
|
||||
>
|
||||
<SpinnerLoader />
|
||||
</div>
|
||||
|
||||
@ -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 = ({
|
||||
<div>
|
||||
<div
|
||||
className="d-flex ms-3 align-middle cursor-pointer"
|
||||
onClick={() => contactProfile(noteItem.contactId)}
|
||||
onClick={() =>
|
||||
setContactOpen({ contact: { id: noteItem.contactId }, Open: true })
|
||||
}
|
||||
>
|
||||
<span>
|
||||
<span className="fw-bold "> {noteItem?.contactName} </span>{" "}
|
||||
@ -97,6 +94,7 @@ const NoteCardDirectoryEditable = ({
|
||||
</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div className="d-flex ms-0 align-middle"></div>
|
||||
<div className="d-flex ms-3 mt-2">
|
||||
<span className="text-muted">
|
||||
|
||||
@ -25,7 +25,9 @@ const Sidebar = () => {
|
||||
/>
|
||||
</span> */}
|
||||
|
||||
<small className="app-brand-link fw-bold navbar-brand text-green fs-6">
|
||||
<small
|
||||
className="app-brand-link fw-bold navbar-brand text-green fs-6"
|
||||
>
|
||||
<span className="app-brand-logo demo">
|
||||
<img src="/img/brand/marco.png" width="50" />
|
||||
</span>
|
||||
@ -35,7 +37,8 @@ const Sidebar = () => {
|
||||
</small>
|
||||
</Link>
|
||||
|
||||
<small className="layout-menu-toggle menu-link text-large ms-auto">
|
||||
<small className="layout-menu-toggle menu-link text-large ms-auto">
|
||||
|
||||
<i className="bx bx-chevron-left bx-sm d-flex align-items-center justify-content-center"></i>
|
||||
</small>
|
||||
</div>
|
||||
@ -58,7 +61,7 @@ const Sidebar = () => {
|
||||
</>
|
||||
)}
|
||||
{data &&
|
||||
data?.data?.map((section) => (
|
||||
data?.data.map((section) => (
|
||||
<React.Fragment
|
||||
key={section.id || section.header || section.items[0]?.id}
|
||||
>
|
||||
|
||||
@ -10,13 +10,11 @@ import {
|
||||
import useMaster, { useServices } from "../../../hooks/masterHook/useMaster";
|
||||
import showToast from "../../../services/toastService";
|
||||
import { useOrganizationEmployees } from "../../../hooks/useOrganization";
|
||||
import { useDispatch } from "react-redux";
|
||||
import { changeMaster } from "../../../slices/localVariablesSlice";
|
||||
|
||||
const TeamEmployeeList = ({ organizationId, searchTerm, closeModal }) => {
|
||||
const selectedProject = useSelectedProject();
|
||||
const debounceSearchTerm = useDebounce(searchTerm, 500);
|
||||
const dispatch = useDispatch();
|
||||
|
||||
const {
|
||||
data: employeesData = [],
|
||||
isLoading,
|
||||
@ -47,7 +45,6 @@ const TeamEmployeeList = ({ organizationId, searchTerm, closeModal }) => {
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
dispatch(changeMaster("Job Role"));
|
||||
if (employeesData?.data?.length > 0) {
|
||||
const available = employeesData.data.filter((emp) => {
|
||||
const projEmp = projectEmployees.find((pe) => pe.employeeId === emp.id);
|
||||
@ -122,7 +119,7 @@ const TeamEmployeeList = ({ organizationId, searchTerm, closeModal }) => {
|
||||
status: true,
|
||||
}));
|
||||
|
||||
handleAssignEmployee({ payload, actionType: "assign" });
|
||||
handleAssignEmployee({ payload,actionType:"assign"} );
|
||||
|
||||
setEmployees((prev) =>
|
||||
prev.map((emp) => ({
|
||||
@ -135,26 +132,26 @@ const TeamEmployeeList = ({ organizationId, searchTerm, closeModal }) => {
|
||||
);
|
||||
};
|
||||
|
||||
if (isLoading) {
|
||||
return (<div className="page-min-h d-flex justify-content-center align-items-center "><p className="text-muted">Loading employees...</p></div>);
|
||||
}
|
||||
if (isLoading) {
|
||||
return ( <div className="page-min-h d-flex justify-content-center align-items-center "><p className="text-muted">Loading employees...</p></div>) ;
|
||||
}
|
||||
|
||||
if (isError) {
|
||||
return (
|
||||
<div className="page-min-h d-flex justify-content-center align-items-center ">
|
||||
{error?.status === 400 ? (
|
||||
<p className="m-0">Enter employee you want to find.</p>
|
||||
) : (
|
||||
<p className="m-0 dange-text">Something went wrong. Please try again later.</p>
|
||||
)}
|
||||
</div>
|
||||
if (isError) {
|
||||
return (
|
||||
<div className="page-min-h d-flex justify-content-center align-items-center ">
|
||||
{error?.status === 400 ? (
|
||||
<p className="m-0">Enter employee you want to find.</p>
|
||||
) : (
|
||||
<p className="m-0 dange-text">Something went wrong. Please try again later.</p>
|
||||
)}
|
||||
</div>
|
||||
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
if (employees.length === 0) {
|
||||
return (<div className="page-min-h d-flex justify-content-center align-items-center "><p className="text-muted">No available employees to assign.</p></div>);
|
||||
}
|
||||
if (employees.length === 0) {
|
||||
return(<div className="page-min-h d-flex justify-content-center align-items-center "><p className="text-muted">No available employees to assign.</p></div>) ;
|
||||
}
|
||||
|
||||
|
||||
return (
|
||||
@ -186,8 +183,9 @@ const TeamEmployeeList = ({ organizationId, searchTerm, closeModal }) => {
|
||||
onChange={(e) =>
|
||||
handleSelectChange(index, "serviceId", e.target.value)
|
||||
}
|
||||
className={`form-select form-select-sm w-auto border-none rounded-0 py-1 px-auto ${emp.errors.serviceId ? "is-invalid" : ""
|
||||
}`}
|
||||
className={`form-select form-select-sm w-auto border-none rounded-0 py-1 px-auto ${
|
||||
emp.errors.serviceId ? "is-invalid" : ""
|
||||
}`}
|
||||
>
|
||||
<option value="">Select Service</option>
|
||||
{services?.map((s) => (
|
||||
@ -207,8 +205,9 @@ const TeamEmployeeList = ({ organizationId, searchTerm, closeModal }) => {
|
||||
onChange={(e) =>
|
||||
handleSelectChange(index, "jobRole", e.target.value)
|
||||
}
|
||||
className={`form-select form-select-sm w-auto border-none rounded-0 py-1 px-auto ${emp.errors.jobRole ? "is-invalid" : ""
|
||||
}`}
|
||||
className={`form-select form-select-sm w-auto border-none rounded-0 py-1 px-auto ${
|
||||
emp.errors.jobRole ? "is-invalid" : ""
|
||||
}`}
|
||||
>
|
||||
<option value="">Select Job Role</option>
|
||||
{jobRoles?.map((r) => (
|
||||
|
||||
@ -140,6 +140,7 @@ const ManageJob = ({ Job }) => {
|
||||
formData.projectId = projectId;
|
||||
|
||||
CreateJob(formData);
|
||||
setManageJob({ isOpen: false, jobId: null });
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -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 && (
|
||||
<div className="invalid-feedback">
|
||||
@ -210,7 +210,7 @@ const OrganizationInfo = ({ onNext, onPrev, onSubmitTenant }) => {
|
||||
</div>
|
||||
|
||||
<div className="col-sm-6">
|
||||
<SelectMultiple
|
||||
<SelectMultiple
|
||||
name="serviceIds"
|
||||
label="Services"
|
||||
options={services?.data}
|
||||
|
||||
@ -109,7 +109,7 @@ const ServiceGroups = ({ service }) => {
|
||||
/>
|
||||
</span>
|
||||
)}
|
||||
<p className="m-0 fw-bold ">{group.name}</p>
|
||||
<p className="m-0 ">{group.name}</p>
|
||||
</div>
|
||||
<div className="d-flex flex-row gap-3">
|
||||
<div className="d-flex flex-row gap-2">
|
||||
|
||||
@ -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) => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user