fixed - useProject (infra) params
This commit is contained in:
parent
8de1230f79
commit
3cfac9a2bb
@ -36,9 +36,7 @@ const JobList = () => {
|
|||||||
maxWidth: "100%",
|
maxWidth: "100%",
|
||||||
width: "210px",
|
width: "210px",
|
||||||
}}
|
}}
|
||||||
onClick={() =>
|
onClick={() => setSelectedJob({ showCanvas: true, job: e?.id })}
|
||||||
setSelectedJob({ showCanvas: true, job: e?.id })
|
|
||||||
}
|
|
||||||
>
|
>
|
||||||
{e?.title}
|
{e?.title}
|
||||||
</span>
|
</span>
|
||||||
@ -69,7 +67,10 @@ const JobList = () => {
|
|||||||
const badgeColor = statusColorMap[statusName] || "label-secondary";
|
const badgeColor = statusColorMap[statusName] || "label-secondary";
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<span className={`badge bg-${badgeColor}`} style={{ fontSize: "12px" }}>
|
<span
|
||||||
|
className={`badge bg-${badgeColor}`}
|
||||||
|
style={{ fontSize: "12px" }}
|
||||||
|
>
|
||||||
{statusName}
|
{statusName}
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
@ -90,8 +91,8 @@ const JobList = () => {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
isAlwaysVisible: true,
|
isAlwaysVisible: true,
|
||||||
className: "text-start d-none d-sm-table-cell"
|
className: "text-start d-none d-sm-table-cell",
|
||||||
}
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -105,7 +106,9 @@ const JobList = () => {
|
|||||||
{jobGrid.map((col) => (
|
{jobGrid.map((col) => (
|
||||||
<th
|
<th
|
||||||
key={col.key}
|
key={col.key}
|
||||||
className={`${col.align || "text-center"} ${col.className || ""}`}
|
className={`${col.align || "text-center"} ${
|
||||||
|
col.className || ""
|
||||||
|
}`}
|
||||||
scope="col"
|
scope="col"
|
||||||
>
|
>
|
||||||
<div className={col.className}>{col.label}</div>
|
<div className={col.className}>{col.label}</div>
|
||||||
@ -120,9 +123,15 @@ const JobList = () => {
|
|||||||
<tbody>
|
<tbody>
|
||||||
{Array.isArray(data?.data) && data.data.length > 0 ? (
|
{Array.isArray(data?.data) && data.data.length > 0 ? (
|
||||||
data.data.map((row, i) => (
|
data.data.map((row, i) => (
|
||||||
<tr key={i} className="text-start">
|
<tr
|
||||||
|
key={i}
|
||||||
|
className="text-start"
|
||||||
|
|
||||||
|
>
|
||||||
{jobGrid.map((col) => (
|
{jobGrid.map((col) => (
|
||||||
<td key={col.key} className={col.className}>
|
<td key={col.key} className={col.className} onClick={() =>
|
||||||
|
setSelectedJob({ showCanvas: true, job: row?.id })
|
||||||
|
}>
|
||||||
{col.getValue(row)}
|
{col.getValue(row)}
|
||||||
</td>
|
</td>
|
||||||
))}
|
))}
|
||||||
@ -135,7 +144,6 @@ const JobList = () => {
|
|||||||
<i className="bx bx-dots-vertical-rounded bx-md"></i>
|
<i className="bx bx-dots-vertical-rounded bx-md"></i>
|
||||||
</button>
|
</button>
|
||||||
<div className="dropdown-menu dropdown-menu-end">
|
<div className="dropdown-menu dropdown-menu-end">
|
||||||
{/* View always visible */}
|
|
||||||
<button
|
<button
|
||||||
className="dropdown-item py-1"
|
className="dropdown-item py-1"
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
|
|||||||
@ -57,7 +57,7 @@ const Jobs = () => {
|
|||||||
>
|
>
|
||||||
<ManageJob Job={manageJob.jobId} />
|
<ManageJob Job={manageJob.jobId} />
|
||||||
</OffcanvasComponent>
|
</OffcanvasComponent>
|
||||||
<div className="card page-min-h my-2 px-7">
|
<div className="card page-min-h my-2 px-7 pb-4">
|
||||||
<div className="row">
|
<div className="row">
|
||||||
<div className="col-12 py-2 d-flex justify-content-end ">
|
<div className="col-12 py-2 d-flex justify-content-end ">
|
||||||
<div className="px-2">
|
<div className="px-2">
|
||||||
|
|||||||
@ -23,10 +23,13 @@ import {
|
|||||||
} from "../../hooks/appHooks/useAppForm";
|
} from "../../hooks/appHooks/useAppForm";
|
||||||
import { useParams } from "react-router-dom";
|
import { useParams } from "react-router-dom";
|
||||||
import { useDispatch } from "react-redux";
|
import { useDispatch } from "react-redux";
|
||||||
|
import { useJobStatus } from "../../hooks/masterHook/useMaster";
|
||||||
|
import { useServiceProjectJobContext } from "./Jobs";
|
||||||
|
|
||||||
const ManageJob = ({ Job }) => {
|
const ManageJob = ({ Job }) => {
|
||||||
|
const { setManageJob, setSelectedJob } = useServiceProjectJobContext();
|
||||||
const { projectId } = useParams();
|
const { projectId } = useParams();
|
||||||
const dispatch = useDispatch()
|
const dispatch = useDispatch();
|
||||||
const methods = useAppForm({
|
const methods = useAppForm({
|
||||||
resolver: zodResolver(jobSchema),
|
resolver: zodResolver(jobSchema),
|
||||||
defaultValues: defaultJobValue,
|
defaultValues: defaultJobValue,
|
||||||
@ -52,11 +55,19 @@ const ManageJob = ({ Job }) => {
|
|||||||
isError: isJobError,
|
isError: isJobError,
|
||||||
error: jobError,
|
error: jobError,
|
||||||
} = useServiceProjectJobDetails(Job);
|
} = useServiceProjectJobDetails(Job);
|
||||||
|
|
||||||
|
const { data, isLoading, isError, error } = useJobStatus(
|
||||||
|
JobData?.status?.id,
|
||||||
|
projectId
|
||||||
|
);
|
||||||
const { mutate: CreateJob, isPending } = useCreateServiceProjectJob(() => {
|
const { mutate: CreateJob, isPending } = useCreateServiceProjectJob(() => {
|
||||||
reset();
|
reset();
|
||||||
});
|
});
|
||||||
const { mutate: UpdateJob, isPending: Updating } = useUpdateServiceProjectJob(
|
const { mutate: UpdateJob, isPending: Updating } = useUpdateServiceProjectJob(
|
||||||
() => { dispatch()}
|
() => {
|
||||||
|
setManageJob({ isOpen: false, jobId: null });
|
||||||
|
setSelectedJob({ showCanvas: true, job: Job });
|
||||||
|
}
|
||||||
);
|
);
|
||||||
const onSubmit = (formData) => {
|
const onSubmit = (formData) => {
|
||||||
if (Job) {
|
if (Job) {
|
||||||
@ -120,7 +131,7 @@ const ManageJob = ({ Job }) => {
|
|||||||
formData.dueDate = localToUtc(formData.dueDate);
|
formData.dueDate = localToUtc(formData.dueDate);
|
||||||
formData.projectId = projectId;
|
formData.projectId = projectId;
|
||||||
|
|
||||||
// CreateJob(formData);
|
CreateJob(formData);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -145,6 +156,7 @@ const ManageJob = ({ Job }) => {
|
|||||||
startDate: JobData.startDate ?? null,
|
startDate: JobData.startDate ?? null,
|
||||||
dueDate: JobData.dueDate ?? null,
|
dueDate: JobData.dueDate ?? null,
|
||||||
tags: JobData.tags ?? [],
|
tags: JobData.tags ?? [],
|
||||||
|
statusId: JobData.status.id,
|
||||||
});
|
});
|
||||||
}, [JobData, Job, projectId]);
|
}, [JobData, Job, projectId]);
|
||||||
|
|
||||||
@ -182,7 +194,7 @@ const ManageJob = ({ Job }) => {
|
|||||||
size="md"
|
size="md"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="col-12 col-md-12 mb-2 mb-md-4">
|
<div className="col-12 col-md-6 mb-2 mb-md-4">
|
||||||
<Label required>Select Employee</Label>
|
<Label required>Select Employee</Label>
|
||||||
<PmsEmployeeInputTag
|
<PmsEmployeeInputTag
|
||||||
control={control}
|
control={control}
|
||||||
@ -190,6 +202,30 @@ const ManageJob = ({ Job }) => {
|
|||||||
placeholder="Select employee"
|
placeholder="Select employee"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
<div className="col-12 col-md-6 mb-2 mb-md-4">
|
||||||
|
<AppFormController
|
||||||
|
name="statusId"
|
||||||
|
control={control}
|
||||||
|
render={({ field }) => (
|
||||||
|
<SelectField
|
||||||
|
label="Select Status"
|
||||||
|
options={data ?? []}
|
||||||
|
placeholder="Choose a Status"
|
||||||
|
required
|
||||||
|
labelKeyKey="name"
|
||||||
|
valueKeyKey="id"
|
||||||
|
value={field.value}
|
||||||
|
onChange={field.onChange}
|
||||||
|
isLoading={isLoading}
|
||||||
|
className="m-0"
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
|
||||||
|
{errors.statusId && (
|
||||||
|
<small className="danger-text">{errors.statusId.message}</small>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
<div className="col-12 col-md-6 mb-2 mb-md-4">
|
<div className="col-12 col-md-6 mb-2 mb-md-4">
|
||||||
<TagInput
|
<TagInput
|
||||||
options={JobTags?.data}
|
options={JobTags?.data}
|
||||||
|
|||||||
@ -53,11 +53,17 @@ const ManageJobTicket = ({ Job }) => {
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
{/* Edit icon on right */}
|
{/* Edit icon on right */}
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="d-flex justify-content-between align-items-center mb-3">
|
||||||
|
<div className="d-flex flex-row gap-2">
|
||||||
|
<span className="badge bg-label-primary">{data?.status?.name}</span>
|
||||||
<HoverPopup
|
<HoverPopup
|
||||||
id="STATUS_CHANEG"
|
id="STATUS_CHANEG"
|
||||||
title="Change Status"
|
title="Change Status"
|
||||||
Mode="click"
|
Mode="click"
|
||||||
className="end-6 start-50 me-16"
|
className=""
|
||||||
content={
|
content={
|
||||||
<ChangeStatus
|
<ChangeStatus
|
||||||
statusId={data?.status?.id}
|
statusId={data?.status?.id}
|
||||||
@ -70,12 +76,6 @@ const ManageJobTicket = ({ Job }) => {
|
|||||||
<i className="bx bx-edit bx-sm cursor-pointer"></i>
|
<i className="bx bx-edit bx-sm cursor-pointer"></i>
|
||||||
</HoverPopup>
|
</HoverPopup>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="d-flex justify-content-between align-items-center mb-3">
|
|
||||||
<div className="d-flex flex-row gap-2">
|
|
||||||
<span className="badge bg-label-primary">{data?.status?.name}</span>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
{data?.dueDate &&
|
{data?.dueDate &&
|
||||||
(() => {
|
(() => {
|
||||||
const { days, color } = daysLeft(data?.startDate, data?.dueDate);
|
const { days, color } = daysLeft(data?.startDate, data?.dueDate);
|
||||||
|
|||||||
@ -68,6 +68,8 @@ export const jobSchema = z.object({
|
|||||||
dueDate: z.string(),
|
dueDate: z.string(),
|
||||||
|
|
||||||
tags: z.array(TagSchema).optional().default([]),
|
tags: z.array(TagSchema).optional().default([]),
|
||||||
|
|
||||||
|
statusId: z.string().optional(),
|
||||||
});
|
});
|
||||||
|
|
||||||
const MAX_FILE_SIZE = 5 * 1024 * 1024; // 5MB
|
const MAX_FILE_SIZE = 5 * 1024 * 1024; // 5MB
|
||||||
@ -103,6 +105,7 @@ export const defaultJobValue = {
|
|||||||
description: "",
|
description: "",
|
||||||
projectId: "",
|
projectId: "",
|
||||||
assignees: [],
|
assignees: [],
|
||||||
|
statusId: null,
|
||||||
startDate: null,
|
startDate: null,
|
||||||
dueDate: null,
|
dueDate: null,
|
||||||
tags: [],
|
tags: [],
|
||||||
|
|||||||
@ -27,7 +27,7 @@ const Comment = ({ invoice }) => {
|
|||||||
AddComment(payload);
|
AddComment(payload);
|
||||||
};
|
};
|
||||||
return (
|
return (
|
||||||
<div className="row pt-1 px-2">
|
<div className="row pt-1 px-2 pb-3">
|
||||||
<form onSubmit={handleSubmit(onSubmit)}>
|
<form onSubmit={handleSubmit(onSubmit)}>
|
||||||
<div className="col-12">
|
<div className="col-12">
|
||||||
<textarea
|
<textarea
|
||||||
|
|||||||
@ -1,15 +1,25 @@
|
|||||||
import React, { useEffect, useMemo, useRef, useState } from "react";
|
import React, { useEffect, useMemo, useRef, useState } from "react";
|
||||||
import { useDispatch, useSelector } from "react-redux";
|
import { useDispatch, useSelector } from "react-redux";
|
||||||
import { closePopup, openPopup, togglePopup } from "../../slices/localVariablesSlice";
|
import {
|
||||||
|
closePopup,
|
||||||
|
openPopup,
|
||||||
|
togglePopup,
|
||||||
|
} from "../../slices/localVariablesSlice";
|
||||||
|
|
||||||
const HoverPopup = ({ id, title, content, children, className, Mode = "hover" }) => {
|
const HoverPopup = ({
|
||||||
|
id,
|
||||||
|
title,
|
||||||
|
content,
|
||||||
|
children,
|
||||||
|
className,
|
||||||
|
Mode = "hover",
|
||||||
|
}) => {
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const visible = useSelector((s) => s.localVariables.popups[id] || false);
|
const visible = useSelector((s) => s.localVariables.popups[id] || false);
|
||||||
|
|
||||||
const triggerRef = useRef(null);
|
const triggerRef = useRef(null);
|
||||||
const popupRef = useRef(null);
|
const popupRef = useRef(null);
|
||||||
|
|
||||||
// Hover mode
|
|
||||||
const handleMouseEnter = () => {
|
const handleMouseEnter = () => {
|
||||||
if (Mode === "hover") dispatch(openPopup(id));
|
if (Mode === "hover") dispatch(openPopup(id));
|
||||||
};
|
};
|
||||||
@ -18,7 +28,6 @@ const HoverPopup = ({ id, title, content, children, className, Mode = "hover" })
|
|||||||
if (Mode === "hover") dispatch(closePopup(id));
|
if (Mode === "hover") dispatch(closePopup(id));
|
||||||
};
|
};
|
||||||
|
|
||||||
// Click mode
|
|
||||||
const handleClick = (e) => {
|
const handleClick = (e) => {
|
||||||
if (Mode === "click") {
|
if (Mode === "click") {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
@ -26,7 +35,6 @@ const HoverPopup = ({ id, title, content, children, className, Mode = "hover" })
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Outside click handling
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (Mode !== "click" || !visible) return;
|
if (Mode !== "click" || !visible) return;
|
||||||
|
|
||||||
@ -45,7 +53,6 @@ const HoverPopup = ({ id, title, content, children, className, Mode = "hover" })
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="d-inline-block position-relative">
|
<div className="d-inline-block position-relative">
|
||||||
{/* Trigger element */}
|
|
||||||
<div
|
<div
|
||||||
ref={triggerRef}
|
ref={triggerRef}
|
||||||
onMouseEnter={handleMouseEnter}
|
onMouseEnter={handleMouseEnter}
|
||||||
@ -56,19 +63,16 @@ const HoverPopup = ({ id, title, content, children, className, Mode = "hover" })
|
|||||||
{children}
|
{children}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Popup */}
|
|
||||||
{visible && (
|
{visible && (
|
||||||
<div
|
<div
|
||||||
ref={popupRef}
|
ref={popupRef}
|
||||||
className={`bg-white border rounded shadow-sm p-3 position-absolute top-100 mt-2 start-50 translate-middle-x ${className}`}
|
className={`bg-white border w-max rounded shadow-sm p-3 position-absolute top-100 mt-2 start-50 translate-middle-x ${className}`}
|
||||||
style={{ zIndex: 1000, width: "240px" }}
|
style={{ zIndex: 1000 }}
|
||||||
onClick={(e) => e.stopPropagation()} // prevents closing when clicking inside
|
onClick={(e) => e.stopPropagation()}
|
||||||
>
|
>
|
||||||
{title && <h6 className="fw-semibold mb-2">{title}</h6>}
|
{title && <h6 className="fw-semibold mb-2">{title}</h6>}
|
||||||
|
|
||||||
<div>{content}</div>
|
<div>{content}</div>
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -20,13 +20,13 @@ export const useCurrentService = () => {
|
|||||||
|
|
||||||
// ------------------------------Query-------------------
|
// ------------------------------Query-------------------
|
||||||
|
|
||||||
export const useProjects = (pageNumber,pageSize) => {
|
export const useProjects = (pageSize,pageNumber) => {
|
||||||
const loggedUser = useSelector((store) => store.globalVariables.loginUser);
|
const loggedUser = useSelector((store) => store.globalVariables.loginUser);
|
||||||
return useQuery({
|
return useQuery({
|
||||||
queryKey: ["ProjectsList",pageNumber,pageSize],
|
queryKey: ["ProjectsList",pageSize,pageNumber],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const response = await ProjectRepository.getProjectList(pageNumber,pageSize);
|
const response = await ProjectRepository.getProjectList(pageSize,pageNumber);
|
||||||
return response?.data?.data;
|
return response?.data;
|
||||||
},
|
},
|
||||||
enabled: !!loggedUser,
|
enabled: !!loggedUser,
|
||||||
});
|
});
|
||||||
|
|||||||
@ -181,6 +181,7 @@ export const useJobComments = (jobId, pageSize, pageNumber) => {
|
|||||||
);
|
);
|
||||||
return resp.data;
|
return resp.data;
|
||||||
},
|
},
|
||||||
|
enabled:!!jobId,
|
||||||
|
|
||||||
initialPageParam: pageNumber,
|
initialPageParam: pageNumber,
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import { api } from "../utils/axiosClient";
|
import { api } from "../utils/axiosClient";
|
||||||
|
|
||||||
const ProjectRepository = {
|
const ProjectRepository = {
|
||||||
getProjectList: (pageNumber,pageSize) => api.get(`/api/project/list?&pageNumber=${pageNumber}&pageSize=${pageSize}`),
|
getProjectList: (pageSize,pageNumber) => api.get(`/api/project/list?pageSize=${pageSize}&pageNumber=${pageNumber}`),
|
||||||
getProjectByprojectId: (projetid) =>
|
getProjectByprojectId: (projetid) =>
|
||||||
api.get(`/api/project/details/${projetid}`),
|
api.get(`/api/project/details/${projetid}`),
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user