Merge pull request 'pramod_Task#410 : Display Directory Feature at Project Section' (#162) from pramod_Task#410 into Feature_Directory
Reviewed-on: #162
This commit is contained in:
commit
99d8be1e4b
@ -112,7 +112,7 @@ const AttendanceLog = ({ handleModalData, projectId, showOnlyCheckout }) => {
|
|||||||
|
|
||||||
const { currentPage, totalPages, currentItems: paginatedAttendances, paginate, resetPage } = usePagination(
|
const { currentPage, totalPages, currentItems: paginatedAttendances, paginate, resetPage } = usePagination(
|
||||||
processedData,
|
processedData,
|
||||||
10
|
20
|
||||||
);
|
);
|
||||||
|
|
||||||
// Reset to the first page whenever processedData changes (due to switch on/off)
|
// Reset to the first page whenever processedData changes (due to switch on/off)
|
||||||
@ -171,7 +171,7 @@ const AttendanceLog = ({ handleModalData, projectId, showOnlyCheckout }) => {
|
|||||||
acc.push(
|
acc.push(
|
||||||
<tr key={`header-${currentDate}`} className="table-row-header">
|
<tr key={`header-${currentDate}`} className="table-row-header">
|
||||||
<td colSpan={6} className="text-start">
|
<td colSpan={6} className="text-start">
|
||||||
<strong>{moment(currentDate).format("YYYY-MM-DD")}</strong>
|
<strong>{moment(currentDate).format("DD-MM-YYYY")}</strong>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
);
|
);
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import React, { useState } from "react";
|
import React, { useState,useEffect } from "react";
|
||||||
import { formatDate } from "../../utils/dateUtils";
|
import { formatDate } from "../../utils/dateUtils";
|
||||||
import { useForm } from "react-hook-form";
|
import { useForm } from "react-hook-form";
|
||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
import { zodResolver } from "@hookform/resolvers/zod";
|
||||||
@ -14,14 +14,22 @@ export const ReportTask = ({ report, closeModal, refetch }) => {
|
|||||||
|
|
||||||
const schema = z.object({
|
const schema = z.object({
|
||||||
completedTask: z
|
completedTask: z
|
||||||
.number()
|
.preprocess(
|
||||||
.min(0, "Completed Work must be greater than 0")
|
(val) => (val === "" || val === null || Number.isNaN(val) ? undefined : Number(val)),
|
||||||
|
z
|
||||||
|
.number({
|
||||||
|
required_error: "Completed Work must be a number",
|
||||||
|
invalid_type_error: "Completed Work must be a number",
|
||||||
|
})
|
||||||
|
.min(1, "Completed Work must be greater than 0")
|
||||||
.max(maxPending, {
|
.max(maxPending, {
|
||||||
message: `Completed task cannot exceed total pending tasks: ${maxPending}`,
|
message: `Completed task cannot exceed total pending tasks: ${maxPending}`,
|
||||||
})
|
})
|
||||||
.optional(),
|
),
|
||||||
comment: z.string().min(1, "Comment cannot be empty"),
|
comment: z.string().min(1, "Comment cannot be empty"),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
const {
|
const {
|
||||||
register,
|
register,
|
||||||
handleSubmit,
|
handleSubmit,
|
||||||
@ -32,6 +40,14 @@ export const ReportTask = ({ report, closeModal, refetch }) => {
|
|||||||
defaultValues: { completedTask: 0, comment: "" },
|
defaultValues: { completedTask: 0, comment: "" },
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (report) {
|
||||||
|
reset({ completedTask: 0, comment: "" }); // optional: customize default if needed
|
||||||
|
}
|
||||||
|
}, [report, reset]);
|
||||||
|
|
||||||
|
|
||||||
const onSubmit = async (data) => {
|
const onSubmit = async (data) => {
|
||||||
try {
|
try {
|
||||||
setloading(true);
|
setloading(true);
|
||||||
@ -56,6 +72,7 @@ export const ReportTask = ({ report, closeModal, refetch }) => {
|
|||||||
};
|
};
|
||||||
const handleClose = () => {
|
const handleClose = () => {
|
||||||
closeModal();
|
closeModal();
|
||||||
|
reset();
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@ -13,15 +13,23 @@ const schema = z.object({
|
|||||||
comment: z.string().min(1, "Comment cannot be empty"),
|
comment: z.string().min(1, "Comment cannot be empty"),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ReportTaskComments component for displaying and adding comments to a task.
|
||||||
|
* It also shows a summary of the activity and task details.
|
||||||
|
*
|
||||||
|
* @param {object} props - The component props.
|
||||||
|
* @param {object} props.commentsData - Data related to the task and its comments, including the description.
|
||||||
|
* @param {function} props.closeModal - Callback function to close the modal.
|
||||||
|
*/
|
||||||
|
|
||||||
const ReportTaskComments = ({ commentsData, closeModal }) => {
|
const ReportTaskComments = ({ commentsData, closeModal }) => {
|
||||||
const [loading, setloading] = useState(false);
|
const [loading, setloading] = useState(false);
|
||||||
const [comments, setComment] = useState([]);
|
const [comments, setComment] = useState([]);
|
||||||
const [bgClass, setBgClass] = useState("");
|
|
||||||
const {
|
const {
|
||||||
register,
|
register,
|
||||||
handleSubmit,
|
handleSubmit,
|
||||||
formState: { errors },
|
formState: { errors },
|
||||||
reset,
|
reset, // Destructure reset from useForm
|
||||||
} = useForm({
|
} = useForm({
|
||||||
resolver: zodResolver(schema),
|
resolver: zodResolver(schema),
|
||||||
});
|
});
|
||||||
@ -29,19 +37,28 @@ const ReportTaskComments = ({ commentsData, closeModal }) => {
|
|||||||
const containerRef = useRef(null);
|
const containerRef = useRef(null);
|
||||||
const firstRender = useRef(true);
|
const firstRender = useRef(true);
|
||||||
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setComment(commentsData?.comments);
|
const taskList = getCachedData("taskList");
|
||||||
|
if (taskList && taskList.data && commentsData?.id) {
|
||||||
|
const currentTask = taskList.data.find(task => task.id === commentsData.id);
|
||||||
|
if (currentTask && currentTask.comments) {
|
||||||
|
setComment(currentTask.comments);
|
||||||
|
} else {
|
||||||
|
setComment(commentsData?.comments || []);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
setComment(commentsData?.comments || []);
|
||||||
|
}
|
||||||
|
firstRender.current = true;
|
||||||
}, [commentsData]);
|
}, [commentsData]);
|
||||||
|
|
||||||
// Scroll logic: scroll to bottom when new comments are added
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!firstRender.current && containerRef.current) {
|
if (!firstRender.current && containerRef.current) {
|
||||||
containerRef.current.scrollTop = containerRef.current.scrollHeight;
|
containerRef.current.scrollTop = containerRef.current.scrollHeight;
|
||||||
} else {
|
} else {
|
||||||
firstRender.current = false; // Mark the first render as complete
|
firstRender.current = false;
|
||||||
}
|
}
|
||||||
}, [comments]); // Run this when comments array is updated
|
}, [comments]);
|
||||||
|
|
||||||
const onSubmit = async (data) => {
|
const onSubmit = async (data) => {
|
||||||
let sendComment = {
|
let sendComment = {
|
||||||
@ -52,8 +69,12 @@ const ReportTaskComments = ({ commentsData, closeModal }) => {
|
|||||||
try {
|
try {
|
||||||
setloading(true);
|
setloading(true);
|
||||||
const resp = await TasksRepository.taskComments(sendComment);
|
const resp = await TasksRepository.taskComments(sendComment);
|
||||||
|
|
||||||
setComment((prevItems) => [...prevItems, resp.data]);
|
setComment((prevItems) => [...prevItems, resp.data]);
|
||||||
|
|
||||||
const taskList = getCachedData("taskList");
|
const taskList = getCachedData("taskList");
|
||||||
|
|
||||||
|
if (taskList && taskList.data) {
|
||||||
const updatedTaskList = taskList.data.map((task) => {
|
const updatedTaskList = taskList.data.map((task) => {
|
||||||
if (task.id === resp.data.taskAllocationId) {
|
if (task.id === resp.data.taskAllocationId) {
|
||||||
const existingComments = Array.isArray(task.comments)
|
const existingComments = Array.isArray(task.comments)
|
||||||
@ -66,14 +87,16 @@ const ReportTaskComments = ({ commentsData, closeModal }) => {
|
|||||||
}
|
}
|
||||||
return task;
|
return task;
|
||||||
});
|
});
|
||||||
|
|
||||||
cacheData("taskList", {
|
cacheData("taskList", {
|
||||||
data: updatedTaskList,
|
data: updatedTaskList,
|
||||||
projectId: taskList.projectId,
|
projectId: taskList.projectId,
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
reset();
|
reset();
|
||||||
setloading(false);
|
setloading(false);
|
||||||
showToast("Successfully Sent", "success");
|
showToast("Successfully Sent", "success");
|
||||||
// closeModal();
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setloading(false);
|
setloading(false);
|
||||||
showToast(error.response.data?.message || "Something went wrong", "error");
|
showToast(error.response.data?.message || "Something went wrong", "error");
|
||||||
@ -93,16 +116,20 @@ const ReportTaskComments = ({ commentsData, closeModal }) => {
|
|||||||
onClick={closeModal}
|
onClick={closeModal}
|
||||||
aria-label="Close"
|
aria-label="Close"
|
||||||
></button>
|
></button>
|
||||||
<p className="fs-6 text-dark text-start m-0">Activity Summary</p>
|
<h5 className=" text-center mb-2">
|
||||||
|
Activity Summary
|
||||||
|
</h5>
|
||||||
|
|
||||||
<p className="small-text text-start my-2">
|
<p className="small-text text-start my-2">
|
||||||
{comments && comments[0]?.comment}
|
{commentsData?.workItem?.workArea?.floor?.building?.description}
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p className="fw-bold my-2 text-start">
|
<p className="fw-bold my-2 text-start">
|
||||||
Assigned By :
|
Assigned By :
|
||||||
<span className=" ms-2">
|
<span className=" ms-2">
|
||||||
{commentsData?.assignedBy.firstName +
|
{commentsData?.assignedBy?.firstName +
|
||||||
" " +
|
" " +
|
||||||
commentsData?.assignedBy.lastName}
|
commentsData?.assignedBy?.lastName}
|
||||||
</span>{" "}
|
</span>{" "}
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
@ -126,7 +153,7 @@ const ReportTaskComments = ({ commentsData, closeModal }) => {
|
|||||||
Completed Work : {commentsData?.completedTask}
|
Completed Work : {commentsData?.completedTask}
|
||||||
</p>
|
</p>
|
||||||
<div className="d-flex align-items-center flex-wrap">
|
<div className="d-flex align-items-center flex-wrap">
|
||||||
<p className="fw-bold text-start m-0 me-1">Team:</p>
|
<p className="fw-bold text-start m-0 me-1">Team :</p>
|
||||||
<div className="d-flex flex-wrap align-items-center gap-2">
|
<div className="d-flex flex-wrap align-items-center gap-2">
|
||||||
{commentsData?.teamMembers?.map((member, idx) => (
|
{commentsData?.teamMembers?.map((member, idx) => (
|
||||||
<span key={idx} className="d-flex align-items-center">
|
<span key={idx} className="d-flex align-items-center">
|
||||||
@ -147,7 +174,6 @@ const ReportTaskComments = ({ commentsData, closeModal }) => {
|
|||||||
{...register("comment")}
|
{...register("comment")}
|
||||||
className="form-control"
|
className="form-control"
|
||||||
id="exampleFormControlTextarea1"
|
id="exampleFormControlTextarea1"
|
||||||
rows="1"
|
|
||||||
placeholder="Enter comment"
|
placeholder="Enter comment"
|
||||||
/>
|
/>
|
||||||
{errors.comment && (
|
{errors.comment && (
|
||||||
@ -162,7 +188,7 @@ const ReportTaskComments = ({ commentsData, closeModal }) => {
|
|||||||
>
|
>
|
||||||
Close
|
Close
|
||||||
</button>
|
</button>
|
||||||
<button type="submit" className="btn btn-sm btn-primary ms-2">
|
<button type="submit" className="btn btn-sm btn-primary ms-2" disabled={loading}>
|
||||||
{loading ? "Sending..." : "Comment"}
|
{loading ? "Sending..." : "Comment"}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
@ -170,8 +196,7 @@ const ReportTaskComments = ({ commentsData, closeModal }) => {
|
|||||||
|
|
||||||
<ul
|
<ul
|
||||||
className="list-group px-0 mx-0 overflow-auto border-0"
|
className="list-group px-0 mx-0 overflow-auto border-0"
|
||||||
// ref={containerRef} // auto scroll according data
|
ref={containerRef}
|
||||||
style={{ maxHeight: "200px" }}
|
|
||||||
>
|
>
|
||||||
{comments &&
|
{comments &&
|
||||||
comments
|
comments
|
||||||
@ -179,14 +204,13 @@ const ReportTaskComments = ({ commentsData, closeModal }) => {
|
|||||||
.reverse()
|
.reverse()
|
||||||
.map((data, idx) => {
|
.map((data, idx) => {
|
||||||
const fullName = `${data?.employee?.firstName} ${data?.employee?.lastName}`;
|
const fullName = `${data?.employee?.firstName} ${data?.employee?.lastName}`;
|
||||||
const bgClass = getBgClassFromHash(fullName);
|
|
||||||
return (
|
return (
|
||||||
<li
|
<li
|
||||||
className={`list-group-item list-group-item-action border-none my-1 p-1`}
|
className={`list-group-item list-group-item-action border-none my-1 p-1`}
|
||||||
key={idx}
|
key={idx}
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
className={`li-wrapper d-flex justify-content-start align-items-start my-0`}
|
className={`li-wrapper d-flex justify-content-start align-items-center my-0`}
|
||||||
>
|
>
|
||||||
<div className="avatar avatar-xs me-1">
|
<div className="avatar avatar-xs me-1">
|
||||||
<span
|
<span
|
||||||
@ -196,9 +220,9 @@ const ReportTaskComments = ({ commentsData, closeModal }) => {
|
|||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className={`text-start py-0`}>
|
<div className={`d-flex align-items-center justify-content-start`}>
|
||||||
<p className={`mb-0 text-${bgClass}`}>{fullName}</p>
|
<p className={`mb-0 text-muted me-2`}>{fullName}</p>
|
||||||
<p className="text-muted m-0" style={{ fontSize: "10px" }}>
|
<p className={`text-secondary m-0`} style={{ fontSize: "10px" }}>
|
||||||
{moment.utc(data?.commentDate).local().fromNow()}
|
{moment.utc(data?.commentDate).local().fromNow()}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -79,10 +79,10 @@ const CardViewDirectory = ({
|
|||||||
)}
|
)}
|
||||||
{!IsActive && (
|
{!IsActive && (
|
||||||
<i
|
<i
|
||||||
className={`bx bx-history ${
|
className={`bx ${
|
||||||
dirActions.action && dirActions.id === contact.id
|
dirActions.action && dirActions.id === contact.id
|
||||||
? "bx-spin"
|
? "bx-loader-alt bx-spin"
|
||||||
: ""
|
: "bx-recycle"
|
||||||
} me-1 text-primary cursor-pointer`}
|
} me-1 text-primary cursor-pointer`}
|
||||||
title="Restore"
|
title="Restore"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
|
|||||||
@ -110,8 +110,9 @@ const ListViewDirectory = ({
|
|||||||
)}
|
)}
|
||||||
{!IsActive && (
|
{!IsActive && (
|
||||||
<i
|
<i
|
||||||
className={`bx bx-history ${
|
className={`bx ${
|
||||||
dirActions.action && dirActions.id === contact.id ? "bx-spin" : ""
|
dirActions.action && dirActions.id === contact.id ? "bx-loader-alt bx-spin"
|
||||||
|
: "bx-recycle"
|
||||||
} me-1 text-primary cursor-pointer`}
|
} me-1 text-primary cursor-pointer`}
|
||||||
title="Restore"
|
title="Restore"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
|
|||||||
@ -296,7 +296,7 @@ const ManageBucket = () =>
|
|||||||
<tbody className="table-border-bottom-0 overflow-auto">
|
<tbody className="table-border-bottom-0 overflow-auto">
|
||||||
{loading && (
|
{loading && (
|
||||||
<tr className="mt-10">
|
<tr className="mt-10">
|
||||||
<td colSpan={4}>
|
<td colSpan={5}>
|
||||||
{" "}
|
{" "}
|
||||||
<div className="d-flex justify-content-center align-items-center py-5">
|
<div className="d-flex justify-content-center align-items-center py-5">
|
||||||
Loading...
|
Loading...
|
||||||
@ -306,7 +306,7 @@ const ManageBucket = () =>
|
|||||||
)}
|
)}
|
||||||
{!loading && buckets.length == 0 && (
|
{!loading && buckets.length == 0 && (
|
||||||
<tr>
|
<tr>
|
||||||
<td colSpan={4}>
|
<td colSpan={5}>
|
||||||
<div className="d-flex justify-content-center align-items-center py-5">
|
<div className="d-flex justify-content-center align-items-center py-5">
|
||||||
Bucket Not Available.
|
Bucket Not Available.
|
||||||
</div>
|
</div>
|
||||||
@ -315,7 +315,7 @@ const ManageBucket = () =>
|
|||||||
)}
|
)}
|
||||||
{!loading && sortedBucktesList.length == 0 && (
|
{!loading && sortedBucktesList.length == 0 && (
|
||||||
<tr>
|
<tr>
|
||||||
<td className="text-center py-4 h-25" colSpan={4}>
|
<td className="text-center py-4 h-25" colSpan={5}>
|
||||||
<div className="d-flex justify-content-center align-items-center py-5">
|
<div className="d-flex justify-content-center align-items-center py-5">
|
||||||
No Matching Bucket Found.
|
No Matching Bucket Found.
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -156,15 +156,16 @@ const NoteCardDirectory = ({refetchProfile,refetchNotes, noteItem, contactId, se
|
|||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
) : isActivProcess ? (
|
) : isActivProcess ? (
|
||||||
< i className='bx bx-refresh text-primary bx-spin' ></i>
|
< i className='bx bx-loader-alt bx-spin text-primary' ></i>
|
||||||
) : (
|
) : (
|
||||||
<i
|
<i
|
||||||
className="bx bx-history me-1 text-primary cursor-pointer"
|
className="bx bx-recycle me-1 text-primary cursor-pointer"
|
||||||
onClick={() => handleDeleteNote(!noteItem.isActive)}
|
onClick={() => handleDeleteNote(!noteItem.isActive)}
|
||||||
title="Restore"
|
title="Restore"
|
||||||
></i>
|
></i>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@ -273,13 +273,6 @@ const AssignRoleModel = ({ assignData, onClose }) => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{employeeLoading && <div>Loading employees...</div>}
|
|
||||||
{!employeeLoading &&
|
|
||||||
filteredEmployees?.length === 0 &&
|
|
||||||
employees && (
|
|
||||||
<div>No employees found for the selected role.</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<div className="row">
|
<div className="row">
|
||||||
<div className="col-12 h-sm-25 overflow-auto mt-2">
|
<div className="col-12 h-sm-25 overflow-auto mt-2">
|
||||||
{selectedRole !== "" && (
|
{selectedRole !== "" && (
|
||||||
|
|||||||
@ -102,12 +102,20 @@ const ManageProjectInfo = ({ project, handleSubmitForm, onClose }) => {
|
|||||||
const onSubmitForm = (updatedProject) => {
|
const onSubmitForm = (updatedProject) => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
handleSubmitForm( updatedProject, setLoading,reset );
|
handleSubmitForm( updatedProject, setLoading,reset );
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleCancel = () => {
|
||||||
|
reset({
|
||||||
|
id: project?.id || "",
|
||||||
|
name: project?.name || "",
|
||||||
|
contactPerson: project?.contactPerson || "",
|
||||||
|
projectAddress: project?.projectAddress || "",
|
||||||
|
startDate: formatDate(project?.startDate) || currentDate,
|
||||||
|
endDate: formatDate(project?.endDate) || currentDate,
|
||||||
|
projectStatusId: String(project?.projectStatusId || "00000000-0000-0000-0000-000000000000"),
|
||||||
|
});
|
||||||
|
onClose();
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
@ -119,7 +127,7 @@ const ManageProjectInfo = ({ project, handleSubmitForm, onClose }) => {
|
|||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
className="btn-close"
|
className="btn-close"
|
||||||
onClick={onClose}
|
onClick={handleCancel}
|
||||||
aria-label="Close"
|
aria-label="Close"
|
||||||
></button>
|
></button>
|
||||||
<div className="text-center mb-2">
|
<div className="text-center mb-2">
|
||||||
@ -280,7 +288,7 @@ const ManageProjectInfo = ({ project, handleSubmitForm, onClose }) => {
|
|||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
className="btn btn-sm btn-label-secondary"
|
className="btn btn-sm btn-label-secondary"
|
||||||
onClick={onClose}
|
onClick={handleCancel}
|
||||||
aria-label="Close"
|
aria-label="Close"
|
||||||
>
|
>
|
||||||
Cancel
|
Cancel
|
||||||
|
|||||||
@ -1,10 +1,13 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import { hasUserPermission } from "../../utils/authUtils";
|
import { hasUserPermission } from "../../utils/authUtils";
|
||||||
import { useHasUserPermission } from "../../hooks/useHasUserPermission";
|
import { useHasUserPermission } from "../../hooks/useHasUserPermission";
|
||||||
import { VIEW_PROJECT_INFRA } from "../../utils/constants";
|
import { DIRECTORY_ADMIN, DIRECTORY_MANAGER, DIRECTORY_USER, VIEW_PROJECT_INFRA } from "../../utils/constants";
|
||||||
|
|
||||||
const ProjectNav = ({ onPillClick, activePill }) => {
|
const ProjectNav = ({ onPillClick, activePill }) => {
|
||||||
const HasViewInfraStructure = useHasUserPermission(VIEW_PROJECT_INFRA);
|
const HasViewInfraStructure = useHasUserPermission( VIEW_PROJECT_INFRA );
|
||||||
|
const DirAdmin = useHasUserPermission(DIRECTORY_ADMIN);
|
||||||
|
const DireManager = useHasUserPermission(DIRECTORY_MANAGER)
|
||||||
|
const DirUser = useHasUserPermission(DIRECTORY_USER)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="nav-align-top">
|
<div className="nav-align-top">
|
||||||
@ -73,6 +76,7 @@ const ProjectNav = ({ onPillClick, activePill }) => {
|
|||||||
<i className="bx bxs-file-image bx-sm me-1_5"></i> <span className="d-none d-md-inline">Image Gallary</span>
|
<i className="bx bxs-file-image bx-sm me-1_5"></i> <span className="d-none d-md-inline">Image Gallary</span>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
{DirAdmin || DireManager || DirUser && (
|
||||||
<li className="nav-item">
|
<li className="nav-item">
|
||||||
<a
|
<a
|
||||||
className={`nav-link ${activePill === "directory" ? "active" : ""}`}
|
className={`nav-link ${activePill === "directory" ? "active" : ""}`}
|
||||||
@ -85,6 +89,8 @@ const ProjectNav = ({ onPillClick, activePill }) => {
|
|||||||
<i className='bx bxs-contact bx-sm me-1_5'></i> <span className="d-none d-md-inline">Directory</span>
|
<i className='bx bxs-contact bx-sm me-1_5'></i> <span className="d-none d-md-inline">Directory</span>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
)}
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@ -12,7 +12,7 @@ const DateRangePicker = ({ onRangeChange, DateDifference = 7, defaultStartDate =
|
|||||||
|
|
||||||
const fp = flatpickr(inputRef.current, {
|
const fp = flatpickr(inputRef.current, {
|
||||||
mode: "range",
|
mode: "range",
|
||||||
dateFormat: "Y-m-d",
|
dateFormat: "d-m-Y",
|
||||||
defaultDate: [fifteenDaysAgo, today],
|
defaultDate: [fifteenDaysAgo, today],
|
||||||
static: true,
|
static: true,
|
||||||
clickOpens: true,
|
clickOpens: true,
|
||||||
|
|||||||
@ -13,7 +13,7 @@ const FloatingMenu = () => {
|
|||||||
actions.map((action, index) => (
|
actions.map((action, index) => (
|
||||||
<button
|
<button
|
||||||
key={index}
|
key={index}
|
||||||
className={`badge bg-label-${action.color} rounded-pill mb-2 d-inline-flex align-items-center gap-2 px-3 py-1 cursor-pointer fab-option`}
|
className={`badge bg-${action.color} rounded-pill mb-2 d-inline-flex align-items-center gap-2 px-3 py-1 cursor-pointer fab-option`}
|
||||||
onClick={action.onClick}
|
onClick={action.onClick}
|
||||||
title={action.label}
|
title={action.label}
|
||||||
>
|
>
|
||||||
|
|||||||
@ -66,7 +66,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"text": "Directory",
|
"text": "Directory",
|
||||||
"icon": "bx bx-folder",
|
"icon": "bx bx-group",
|
||||||
"available": true,
|
"available": true,
|
||||||
"link": "/directory"
|
"link": "/directory"
|
||||||
},
|
},
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import { useEffect, useState } from "react";
|
|||||||
import { DirectoryRepository } from "../repositories/DirectoryRepository";
|
import { DirectoryRepository } from "../repositories/DirectoryRepository";
|
||||||
import { cacheData, getCachedData } from "../slices/apiDataManager";
|
import { cacheData, getCachedData } from "../slices/apiDataManager";
|
||||||
|
|
||||||
export const useDirectory = (isActive) => {
|
export const useDirectory = (isActive,prefernceContacts) => {
|
||||||
const [contacts, setContacts] = useState([]);
|
const [contacts, setContacts] = useState([]);
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const [error, setError] = useState(null);
|
const [error, setError] = useState(null);
|
||||||
@ -10,7 +10,7 @@ export const useDirectory = (isActive) => {
|
|||||||
const fetch = async (activeParam = isActive) => {
|
const fetch = async (activeParam = isActive) => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
try {
|
try {
|
||||||
const response = await DirectoryRepository.GetContacts(activeParam);
|
const response = await DirectoryRepository.GetContacts(activeParam,prefernceContacts);
|
||||||
setContacts(response.data);
|
setContacts(response.data);
|
||||||
cacheData("contacts", { data: response.data, isActive: activeParam });
|
cacheData("contacts", { data: response.data, isActive: activeParam });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -22,12 +22,12 @@ export const useDirectory = (isActive) => {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const cachedContacts = getCachedData("contacts");
|
const cachedContacts = getCachedData("contacts");
|
||||||
if (!cachedContacts?.data || cachedContacts.isActive !== isActive) {
|
if (!cachedContacts?.data || cachedContacts.isActive !== isActive || prefernceContacts) {
|
||||||
fetch(isActive);
|
fetch(isActive,prefernceContacts);
|
||||||
} else {
|
} else {
|
||||||
setContacts(cachedContacts.data);
|
setContacts(cachedContacts.data);
|
||||||
}
|
}
|
||||||
}, [isActive]);
|
}, [isActive,prefernceContacts]);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
contacts,
|
contacts,
|
||||||
|
|||||||
@ -6,7 +6,7 @@ import { useTaskList } from "../../hooks/useTasks";
|
|||||||
import { useProjects } from "../../hooks/useProjects";
|
import { useProjects } from "../../hooks/useProjects";
|
||||||
import { setProjectId } from "../../slices/localVariablesSlice";
|
import { setProjectId } from "../../slices/localVariablesSlice";
|
||||||
import { useProfile } from "../../hooks/useProfile";
|
import { useProfile } from "../../hooks/useProfile";
|
||||||
import { formatDate } from "../../utils/dateUtils";
|
// import { formatDate } from "../../utils/dateUtils"; // Removed this import
|
||||||
import GlobalModel from "../../components/common/GlobalModel";
|
import GlobalModel from "../../components/common/GlobalModel";
|
||||||
import AssignRoleModel from "../../components/Project/AssignRole";
|
import AssignRoleModel from "../../components/Project/AssignRole";
|
||||||
import { ReportTask } from "../../components/Activities/ReportTask";
|
import { ReportTask } from "../../components/Activities/ReportTask";
|
||||||
@ -14,6 +14,7 @@ import ReportTaskComments from "../../components/Activities/ReportTaskComments";
|
|||||||
import DateRangePicker from "../../components/common/DateRangePicker";
|
import DateRangePicker from "../../components/common/DateRangePicker";
|
||||||
import DatePicker from "../../components/common/DatePicker";
|
import DatePicker from "../../components/common/DatePicker";
|
||||||
import { useSearchParams } from "react-router-dom";
|
import { useSearchParams } from "react-router-dom";
|
||||||
|
import moment from "moment";
|
||||||
|
|
||||||
const DailyTask = () => {
|
const DailyTask = () => {
|
||||||
const [searchParams] = useSearchParams();
|
const [searchParams] = useSearchParams();
|
||||||
@ -141,6 +142,7 @@ const DailyTask = () => {
|
|||||||
<DateRangePicker
|
<DateRangePicker
|
||||||
onRangeChange={setDateRange}
|
onRangeChange={setDateRange}
|
||||||
DateDifference="6"
|
DateDifference="6"
|
||||||
|
dateFormat="DD-MM-YYYY"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="col-sm-3 col-6 text-end mb-1">
|
<div className="col-sm-3 col-6 text-end mb-1">
|
||||||
@ -199,7 +201,7 @@ const DailyTask = () => {
|
|||||||
<React.Fragment key={i}>
|
<React.Fragment key={i}>
|
||||||
<tr className="table-row-header">
|
<tr className="table-row-header">
|
||||||
<td colSpan={7} className="text-start">
|
<td colSpan={7} className="text-start">
|
||||||
<strong>{date}</strong>
|
<strong>{moment(date).format("DD-MM-YYYY")}</strong>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{TaskLists.filter((task) =>
|
{TaskLists.filter((task) =>
|
||||||
@ -246,7 +248,7 @@ const DailyTask = () => {
|
|||||||
task.workItem.completedWork}
|
task.workItem.completedWork}
|
||||||
</td>
|
</td>
|
||||||
<td>{task.completedTask}</td>
|
<td>{task.completedTask}</td>
|
||||||
<td>{formatDate(task.assignmentDate)}</td>
|
<td>{moment(task.assignmentDate).format("DD-MM-YYYY")}</td>
|
||||||
<td className="text-center">
|
<td className="text-center">
|
||||||
<div
|
<div
|
||||||
key={refIndex}
|
key={refIndex}
|
||||||
|
|||||||
@ -21,8 +21,9 @@ import ManageBucket from "../../components/Directory/ManageBucket";
|
|||||||
import {useFab} from "../../Context/FabContext";
|
import {useFab} from "../../Context/FabContext";
|
||||||
import {DireProvider, useDir} from "../../Context/DireContext";
|
import {DireProvider, useDir} from "../../Context/DireContext";
|
||||||
|
|
||||||
const Directory = () =>
|
const Directory = ({IsPage=true,prefernceContacts}) =>
|
||||||
{
|
{
|
||||||
|
const[projectPrefernce,setPerfence] = useState(null)
|
||||||
const[IsActive,setIsActive] = useState(true)
|
const[IsActive,setIsActive] = useState(true)
|
||||||
const [isOpenModal, setIsOpenModal] = useState(false);
|
const [isOpenModal, setIsOpenModal] = useState(false);
|
||||||
const [isOpenModalNote, setIsOpenModalNote] = useState(false);
|
const [isOpenModalNote, setIsOpenModalNote] = useState(false);
|
||||||
@ -44,7 +45,7 @@ const Directory = () =>
|
|||||||
const { dirActions, setDirActions } = useDir();
|
const { dirActions, setDirActions } = useDir();
|
||||||
|
|
||||||
|
|
||||||
const { contacts, loading , refetch} = useDirectory(IsActive);
|
const { contacts, loading , refetch} = useDirectory(IsActive,projectPrefernce);
|
||||||
const { contactCategory, loading: contactCategoryLoading } =
|
const { contactCategory, loading: contactCategoryLoading } =
|
||||||
useContactCategory();
|
useContactCategory();
|
||||||
const {buckets} = useBuckets();
|
const {buckets} = useBuckets();
|
||||||
@ -72,7 +73,7 @@ const Directory = () =>
|
|||||||
|
|
||||||
// cacheData("Contacts", {data:updatedContacts,isActive:IsActive});
|
// cacheData("Contacts", {data:updatedContacts,isActive:IsActive});
|
||||||
// setContactList(updatedContacts);
|
// setContactList(updatedContacts);
|
||||||
refetch()
|
refetch(IsActive,prefernceContacts)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const msg =
|
const msg =
|
||||||
error.response?.data?.message ||
|
error.response?.data?.message ||
|
||||||
@ -217,34 +218,42 @@ const handleDeleteContact = async (overrideId = null) => {
|
|||||||
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setActions([
|
const actions = [];
|
||||||
{
|
|
||||||
|
if (IsPage) {
|
||||||
|
actions.push({
|
||||||
|
label: "Manage Bucket",
|
||||||
|
icon: "fa-solid fa-bucket fs-5",
|
||||||
|
color:"primary",
|
||||||
|
onClick: () => setOpenBucketModal(true),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
actions.push({
|
||||||
label: "New Contact",
|
label: "New Contact",
|
||||||
icon: "bx bx-plus-circle",
|
icon: "bx bx-plus-circle",
|
||||||
color: "warning",
|
color: "warning",
|
||||||
onClick: () => setIsOpenModal(true),
|
onClick: () => setIsOpenModal(true),
|
||||||
},
|
} );
|
||||||
|
|
||||||
|
|
||||||
|
setActions(actions);
|
||||||
|
|
||||||
|
return () => setActions([]);
|
||||||
|
}, [IsPage]);
|
||||||
|
useEffect( () =>
|
||||||
{
|
{
|
||||||
label: "Manage Bucket",
|
setPerfence(prefernceContacts)
|
||||||
icon: "fa-solid fa-bucket fs-5 ",
|
},[prefernceContacts])
|
||||||
color: "primary",
|
|
||||||
onClick: () => setOpenBucketModal(true),
|
|
||||||
},
|
|
||||||
|
|
||||||
]);
|
|
||||||
|
|
||||||
return () => setActions([]); // Clean up
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="container-xxl flex-grow-1 container-p-y">
|
<div className="container-xxl flex-grow-1 container-p-y">
|
||||||
|
|
||||||
<Breadcrumb
|
{IsPage && ( <Breadcrumb
|
||||||
data={[
|
data={[
|
||||||
{ label: "Home", link: "/dashboard" },
|
{ label: "Home", link: "/dashboard" },
|
||||||
{ label: "Directory", link: null },
|
{ label: "Directory", link: null },
|
||||||
]}
|
]}
|
||||||
></Breadcrumb>
|
></Breadcrumb>)}
|
||||||
|
|
||||||
{isOpenModal && (
|
{isOpenModal && (
|
||||||
<GlobalModel
|
<GlobalModel
|
||||||
|
|||||||
@ -29,7 +29,7 @@ const DirectoryPageHeader = ({
|
|||||||
<>
|
<>
|
||||||
<div className="row"></div>
|
<div className="row"></div>
|
||||||
<div className="row mx-0 px-0 align-items-center">
|
<div className="row mx-0 px-0 align-items-center">
|
||||||
<div className="col-12 col-md-4 mb-2 px-1 d-flex align-items-center ">
|
<div className="col-12 col-md-6 mb-2 px-1 d-flex align-items-center gap-4 ">
|
||||||
<input
|
<input
|
||||||
type="search"
|
type="search"
|
||||||
className="form-control form-control-sm me-2"
|
className="form-control form-control-sm me-2"
|
||||||
@ -167,7 +167,7 @@ const DirectoryPageHeader = ({
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="col-12 col-md-8 mb-2 px-1 d-flex justify-content-end gap-2 align-items-center text-end">
|
<div className="col-12 col-md-6 mb-2 px-1 d-flex justify-content-end gap-2 align-items-center text-end">
|
||||||
<label className="switch switch-primary align-self-start mb-2">
|
<label className="switch switch-primary align-self-start mb-2">
|
||||||
<input
|
<input
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
|
|||||||
@ -22,6 +22,7 @@ import {
|
|||||||
import { useDispatch } from "react-redux";
|
import { useDispatch } from "react-redux";
|
||||||
import { setProjectId } from "../../slices/localVariablesSlice";
|
import { setProjectId } from "../../slices/localVariablesSlice";
|
||||||
import { ComingSoonPage } from "../Misc/ComingSoonPage";
|
import { ComingSoonPage } from "../Misc/ComingSoonPage";
|
||||||
|
import Directory from "../Directory/Directory";
|
||||||
|
|
||||||
const ProjectDetails = () => {
|
const ProjectDetails = () => {
|
||||||
let { projectId } = useParams();
|
let { projectId } = useParams();
|
||||||
@ -117,12 +118,10 @@ const ProjectDetails = () => {
|
|||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "activities": {
|
case "directory": {
|
||||||
return (
|
return (
|
||||||
<div className="row">
|
<div className="row">
|
||||||
<div className="col-lg-12 col-xl-12">
|
<Directory IsPage={ false} prefernceContacts={projectDetails.id} />
|
||||||
<ActivityTimeline></ActivityTimeline>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,7 +3,17 @@ import {api} from "../utils/axiosClient";
|
|||||||
export const DirectoryRepository = {
|
export const DirectoryRepository = {
|
||||||
GetOrganizations:()=>api.get('/api/directory/organization'),
|
GetOrganizations:()=>api.get('/api/directory/organization'),
|
||||||
|
|
||||||
GetContacts: (isActive) => api.get( `/api/directory?active=${isActive}` ),
|
GetContacts: (isActive, projectId) => {
|
||||||
|
const params = new URLSearchParams();
|
||||||
|
params.append("active", isActive);
|
||||||
|
|
||||||
|
if (projectId) {
|
||||||
|
params.append("projectId", projectId);
|
||||||
|
}
|
||||||
|
|
||||||
|
return api.get(`/api/Directory?${params.toString()}`);
|
||||||
|
}
|
||||||
|
,
|
||||||
CreateContact: ( data ) => api.post( '/api/directory', data ),
|
CreateContact: ( data ) => api.post( '/api/directory', data ),
|
||||||
UpdateContact: ( id, data ) => api.put( `/api/directory/${ id }`, data ),
|
UpdateContact: ( id, data ) => api.put( `/api/directory/${ id }`, data ),
|
||||||
DeleteContact: ( id,isActive) => api.delete( `/api/directory/${ id }/?active=${isActive}` ),
|
DeleteContact: ( id,isActive) => api.delete( `/api/directory/${ id }/?active=${isActive}` ),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user