added offcanavs for create and update
This commit is contained in:
parent
dab3c5fe52
commit
7190a3c190
@ -94,7 +94,6 @@ const JobComments = ({ data }) => {
|
|||||||
const newFiles = files.filter((_, i) => i !== index);
|
const newFiles = files.filter((_, i) => i !== index);
|
||||||
setValue("attachments", newFiles, { shouldValidate: true });
|
setValue("attachments", newFiles, { shouldValidate: true });
|
||||||
};
|
};
|
||||||
console.log(watch("attachments"))
|
|
||||||
return (
|
return (
|
||||||
<div className="row">
|
<div className="row">
|
||||||
<div className="sticky-section bg-white p-3">
|
<div className="sticky-section bg-white p-3">
|
||||||
|
|||||||
@ -9,9 +9,8 @@ import { useParams } from "react-router-dom";
|
|||||||
import ProjectPage from "../../pages/project/ProjectPage";
|
import ProjectPage from "../../pages/project/ProjectPage";
|
||||||
import { useServiceProjectJobContext } from "./Jobs";
|
import { useServiceProjectJobContext } from "./Jobs";
|
||||||
|
|
||||||
|
|
||||||
const JobList = ({ filterByProject }) => {
|
const JobList = ({ filterByProject }) => {
|
||||||
const {setSelectedJob} = useServiceProjectJobContext()
|
const { setSelectedJob, setManageJob } = useServiceProjectJobContext();
|
||||||
const { id } = useParams();
|
const { id } = useParams();
|
||||||
const { data, isLoading, isError, error } = useServiceProjectJobs(
|
const { data, isLoading, isError, error } = useServiceProjectJobs(
|
||||||
ITEMS_PER_PAGE,
|
ITEMS_PER_PAGE,
|
||||||
@ -112,12 +111,22 @@ const JobList = ({ filterByProject }) => {
|
|||||||
</button>
|
</button>
|
||||||
<div className="dropdown-menu dropdown-menu-end">
|
<div className="dropdown-menu dropdown-menu-end">
|
||||||
{/* View always visible */}
|
{/* View always visible */}
|
||||||
<button className="dropdown-item py-1" onClick={()=>setSelectedJob({showCanvas:true,job:row?.id})}>
|
<button
|
||||||
|
className="dropdown-item py-1"
|
||||||
|
onClick={() =>
|
||||||
|
setSelectedJob({ showCanvas: true, job: row?.id })
|
||||||
|
}
|
||||||
|
>
|
||||||
<i className="bx bx-detail bx-sm"></i> View
|
<i className="bx bx-detail bx-sm"></i> View
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<>
|
<>
|
||||||
<button className="dropdown-item py-1">
|
<button
|
||||||
|
className="dropdown-item py-1"
|
||||||
|
onClick={() =>
|
||||||
|
setManageJob({ isOpen: true, jobId: row?.id })
|
||||||
|
}
|
||||||
|
>
|
||||||
<i className="bx bx-edit bx-sm"></i> Edit
|
<i className="bx bx-edit bx-sm"></i> Edit
|
||||||
</button>
|
</button>
|
||||||
</>
|
</>
|
||||||
|
|||||||
@ -20,15 +20,21 @@ export const useServiceProjectJobContext = () => {
|
|||||||
return context;
|
return context;
|
||||||
};
|
};
|
||||||
const Jobs = () => {
|
const Jobs = () => {
|
||||||
|
const [manageJob, setManageJob] = useState({ isOpen: false, jobId: null });
|
||||||
const [showCanvas, setShowCanvas] = useState(false);
|
const [showCanvas, setShowCanvas] = useState(false);
|
||||||
const [selectedProject, setSelectedProject] = useState(null);
|
const [selectedProject, setSelectedProject] = useState(null);
|
||||||
const [selectJob,setSelectedJob] = useState({showCanvas:false,job:null})
|
const [selectJob, setSelectedJob] = useState({
|
||||||
|
showCanvas: false,
|
||||||
|
job: null,
|
||||||
|
});
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const { data } = useServiceProjects(ITEMS_PER_PAGE, 1);
|
const { data } = useServiceProjects(ITEMS_PER_PAGE, 1);
|
||||||
|
|
||||||
const contextProvider = {
|
const contextProvider = {
|
||||||
setSelectedJob
|
setSelectedJob,
|
||||||
}
|
setSelectedProject,
|
||||||
|
setManageJob,
|
||||||
|
};
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<JonContext.Provider value={contextProvider}>
|
<JonContext.Provider value={contextProvider}>
|
||||||
@ -37,10 +43,19 @@ const Jobs = () => {
|
|||||||
title="Job"
|
title="Job"
|
||||||
placement="end"
|
placement="end"
|
||||||
show={selectJob.showCanvas}
|
show={selectJob.showCanvas}
|
||||||
onClose={() => setSelectedJob({showCanvas:false,job:null})}
|
onClose={() => setSelectedJob({ showCanvas: false, job: null })}
|
||||||
>
|
>
|
||||||
<ManageJobTicket Job={selectJob} />
|
<ManageJobTicket Job={selectJob} />
|
||||||
</OffcanvasComponent>
|
</OffcanvasComponent>
|
||||||
|
<OffcanvasComponent
|
||||||
|
id="customCanvas1"
|
||||||
|
title={`${manageJob.jobId ? "Update a Job" : "Create a new Job"} `}
|
||||||
|
placement="end"
|
||||||
|
show={manageJob.isOpen}
|
||||||
|
onClose={() => setManageJob({ isOpen: false, jobId: null })}
|
||||||
|
>
|
||||||
|
<ManageJob Job={manageJob.jobId} />
|
||||||
|
</OffcanvasComponent>
|
||||||
<div className="card page-min-h my-2 px-4">
|
<div className="card page-min-h my-2 px-4">
|
||||||
<div className="row">
|
<div className="row">
|
||||||
<div className="col-12 py-2 d-flex justify-content-between ">
|
<div className="col-12 py-2 d-flex justify-content-between ">
|
||||||
@ -64,7 +79,7 @@ const Jobs = () => {
|
|||||||
<div className="px-2">
|
<div className="px-2">
|
||||||
<button
|
<button
|
||||||
className="btn btn-sm btn-primary"
|
className="btn btn-sm btn-primary"
|
||||||
onClick={() => navigate("/service/job")}
|
onClick={() => setManageJob({ isOpen: true, jobId: null })}
|
||||||
>
|
>
|
||||||
<i className="bx bx-plus-circle bx-md me-2"></i>New Job
|
<i className="bx bx-plus-circle bx-md me-2"></i>New Job
|
||||||
</button>
|
</button>
|
||||||
@ -74,7 +89,6 @@ const Jobs = () => {
|
|||||||
<JobList filterByProject={selectedProject} />
|
<JobList filterByProject={selectedProject} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</JonContext.Provider>
|
</JonContext.Provider>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@ -1,10 +1,12 @@
|
|||||||
import React from "react";
|
import React, { useEffect } from "react";
|
||||||
import Breadcrumb from "../common/Breadcrumb";
|
import Breadcrumb from "../common/Breadcrumb";
|
||||||
import Label from "../common/Label";
|
import Label from "../common/Label";
|
||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
import { zodResolver } from "@hookform/resolvers/zod";
|
||||||
import { defaultJobValue, jobSchema } from "./ServiceProjectSchema";
|
import { defaultJobValue, jobSchema } from "./ServiceProjectSchema";
|
||||||
import {
|
import {
|
||||||
useCreateServiceProjectJob,
|
useCreateServiceProjectJob,
|
||||||
|
useJobTags,
|
||||||
|
useServiceProjectJobDetails,
|
||||||
useServiceProjects,
|
useServiceProjects,
|
||||||
} from "../../hooks/useServiceProject";
|
} from "../../hooks/useServiceProject";
|
||||||
import { ITEMS_PER_PAGE } from "../../utils/constants";
|
import { ITEMS_PER_PAGE } from "../../utils/constants";
|
||||||
@ -19,7 +21,7 @@ import {
|
|||||||
useAppForm,
|
useAppForm,
|
||||||
} from "../../hooks/appHooks/useAppForm";
|
} from "../../hooks/appHooks/useAppForm";
|
||||||
|
|
||||||
const ManageJob = () => {
|
const ManageJob = ({ Job }) => {
|
||||||
const methods = useAppForm({
|
const methods = useAppForm({
|
||||||
resolver: zodResolver(jobSchema),
|
resolver: zodResolver(jobSchema),
|
||||||
defaultValues: defaultJobValue,
|
defaultValues: defaultJobValue,
|
||||||
@ -40,10 +42,23 @@ const ManageJob = () => {
|
|||||||
isError: isProjectError,
|
isError: isProjectError,
|
||||||
error,
|
error,
|
||||||
} = useServiceProjects(ITEMS_PER_PAGE, 1);
|
} = useServiceProjects(ITEMS_PER_PAGE, 1);
|
||||||
|
const {
|
||||||
|
data: JobTags,
|
||||||
|
isLoading: isTagLoading,
|
||||||
|
isError: isTagError,
|
||||||
|
error: tagError,
|
||||||
|
} = useJobTags();
|
||||||
|
const {
|
||||||
|
data: JobData,
|
||||||
|
isLoading: isJobLoading,
|
||||||
|
isError: isJobError,
|
||||||
|
error: jobError,
|
||||||
|
} = useServiceProjectJobDetails(Job);
|
||||||
|
|
||||||
const { mutate: CreateJob, isPending } = useCreateServiceProjectJob(() => {
|
const { mutate: CreateJob, isPending } = useCreateServiceProjectJob(() => {
|
||||||
reset();
|
reset();
|
||||||
});
|
});
|
||||||
|
|
||||||
const onSubmit = (formData) => {
|
const onSubmit = (formData) => {
|
||||||
formData.assignees = formData.assignees.map((emp) => ({
|
formData.assignees = formData.assignees.map((emp) => ({
|
||||||
employeeId: emp,
|
employeeId: emp,
|
||||||
@ -52,104 +67,107 @@ const ManageJob = () => {
|
|||||||
|
|
||||||
formData.startDate = localToUtc(formData.startDate);
|
formData.startDate = localToUtc(formData.startDate);
|
||||||
formData.dueDate = localToUtc(formData.dueDate);
|
formData.dueDate = localToUtc(formData.dueDate);
|
||||||
// CreateJob(formData);
|
CreateJob(formData)
|
||||||
console.log(formData);
|
|
||||||
};
|
};
|
||||||
console.log(errors);
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!JobData || !Job) return;
|
||||||
|
const assignedEmployees = (JobData.assignees || []).map((e) => e.id);
|
||||||
|
reset({
|
||||||
|
title: JobData.title ?? "",
|
||||||
|
description: JobData.description ?? "",
|
||||||
|
projectId: JobData.project.id ?? "",
|
||||||
|
assignees: assignedEmployees,
|
||||||
|
startDate: JobData.startDate ?? null,
|
||||||
|
dueDate: JobData.dueDate ?? null,
|
||||||
|
tags: [],
|
||||||
|
});
|
||||||
|
}, [JobData]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="container-fluid">
|
<div className="container">
|
||||||
<Breadcrumb
|
<AppFormProvider {...methods}>
|
||||||
data={[
|
<form className="row text-start" onSubmit={handleSubmit(onSubmit)}>
|
||||||
{ label: "Home", link: "/dashboard" },
|
<div className="col-12 col-md-6 mb-2 ">
|
||||||
{ label: "Sevice Projects", link: "/projects" },
|
<Label required>Title</Label>
|
||||||
{ label: "" || "Jobs", link: null },
|
<input
|
||||||
]}
|
type="text"
|
||||||
/>
|
{...register("title")}
|
||||||
<div className="card m-auto page-min-h">
|
className="form-control form-control"
|
||||||
<div className="col-md-4 col-12 p-3"></div>
|
/>
|
||||||
<div className="col-md-8 p-3">
|
</div>
|
||||||
<AppFormProvider {...methods}>
|
<div className="col-12 col-md-6 mb-2">
|
||||||
<form className="row text-start" onSubmit={handleSubmit(onSubmit)}>
|
<AppFormController
|
||||||
<div>
|
name="projectId"
|
||||||
<p className="fs-5 fw-medium">Create Job</p>
|
control={control}
|
||||||
</div>
|
render={({ field }) => (
|
||||||
<div className="col-12 col-md-6 mb-2 ">
|
<SelectField
|
||||||
<Label required>Title</Label>
|
label="Project"
|
||||||
<input
|
options={data?.data}
|
||||||
type="text"
|
placeholder="Choose a Project"
|
||||||
{...register("title")}
|
required
|
||||||
className="form-control form-control"
|
labelKeyKey="name"
|
||||||
|
valueKeyKey="id"
|
||||||
|
value={field.value}
|
||||||
|
onChange={field.onChange}
|
||||||
|
isLoading={isProjectLoading}
|
||||||
/>
|
/>
|
||||||
</div>
|
)}
|
||||||
<div className="col-12 col-md-6 mb-2">
|
/>
|
||||||
<AppFormController
|
</div>
|
||||||
name="projectId"
|
<div className="col-12 col-md-6 mb-2 mb-md-4">
|
||||||
control={control}
|
<Label required>Start Date</Label>
|
||||||
render={({ field }) => (
|
<DatePicker
|
||||||
<SelectField
|
name="startDate"
|
||||||
label="Project"
|
control={control}
|
||||||
options={data?.data}
|
placeholder="DD-MM-YYYY"
|
||||||
placeholder="Choose a Project"
|
className="w-full form-control-md"
|
||||||
required
|
/>
|
||||||
labelKeyKey="name"
|
</div>
|
||||||
valueKeyKey="id"
|
<div className="col-12 col-md-6 mb-2 mb-md-4">
|
||||||
value={field.value}
|
<Label required>End Date</Label>
|
||||||
onChange={field.onChange}
|
<DatePicker
|
||||||
isLoading={isProjectLoading}
|
control={control}
|
||||||
/>
|
minDate={watch("startDate")}
|
||||||
)}
|
name="dueDate"
|
||||||
/>
|
className="w-full"
|
||||||
</div>
|
/>
|
||||||
<div className="col-12 col-md-6 mb-2 mb-md-4">
|
</div>
|
||||||
<Label required>Start Date</Label>
|
<div className="col-12 col-md-6 mb-2 mb-md-4">
|
||||||
<DatePicker
|
<Label required>End Date</Label>
|
||||||
name="startDate"
|
<PmsEmployeeInputTag
|
||||||
control={control}
|
control={control}
|
||||||
placeholder="DD-MM-YYYY"
|
name="assignees"
|
||||||
className="w-full form-control-md"
|
placeholder="Enter employee"
|
||||||
/>
|
/>
|
||||||
</div>
|
</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">
|
||||||
<Label required>End Date</Label>
|
<TagInput
|
||||||
<DatePicker
|
options={JobTags?.data}
|
||||||
control={control}
|
name="tags"
|
||||||
minDate={watch("startDate")}
|
label="Tag"
|
||||||
name="dueDate"
|
required
|
||||||
className="w-full"
|
/>
|
||||||
/>
|
</div>
|
||||||
</div>
|
<div className="col-12">
|
||||||
<div className="col-12 col-md-6 mb-2 mb-md-4">
|
<Label required>Description</Label>
|
||||||
<Label required>End Date</Label>
|
<textarea
|
||||||
<PmsEmployeeInputTag
|
{...register("description")}
|
||||||
control={control}
|
className="form-control form-control-sm"
|
||||||
name="assignees"
|
rows={3}
|
||||||
placeholder="Enter employee"
|
/>
|
||||||
/>
|
</div>
|
||||||
</div>
|
<div className="d-flex flex-row-reverse my-4">
|
||||||
<div className="col-12 col-md-6 mb-2 mb-md-4">
|
<button
|
||||||
<TagInput name="tags" label="Tag" required />
|
type="submit"
|
||||||
</div>
|
className="btn btn-sm btn-primary"
|
||||||
<div className="col-12">
|
disabled={isPending}
|
||||||
<Label required>Description</Label>
|
>
|
||||||
<textarea
|
{isPending ? "Please wait..." : "Submit"}
|
||||||
{...register("description")}
|
</button>
|
||||||
className="form-control form-control-sm"
|
</div>
|
||||||
rows={3}
|
</form>
|
||||||
/>
|
</AppFormProvider>
|
||||||
</div>
|
|
||||||
<div className="d-flex flex-row-reverse my-2">
|
|
||||||
<button
|
|
||||||
type="submit"
|
|
||||||
className="btn btn-sm btn-primary"
|
|
||||||
disabled={isPending}
|
|
||||||
>
|
|
||||||
{isPending ? "Please wait..." : "Submit"}
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</AppFormProvider>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1,34 +1,32 @@
|
|||||||
import React from 'react'
|
import React from "react";
|
||||||
|
|
||||||
const ServiceProjectNav = ({ onPillClick, activePill }) => {
|
const ServiceProjectNav = ({ onPillClick, activePill }) => {
|
||||||
const ProjectTab = [
|
const ProjectTab = [
|
||||||
{ key: "profile", icon: "bx bx-user", label: "Profile" },
|
{ key: "profile", icon: "bx bx-user", label: "Profile" },
|
||||||
{
|
{
|
||||||
key: "jobs",
|
key: "jobs",
|
||||||
icon: "bx bx-briefcase-alt",
|
icon: "bx bx-briefcase-alt",
|
||||||
label: "Jobs",
|
label: "Jobs",
|
||||||
link:"/service/job",
|
link: "/service/job",
|
||||||
},
|
},
|
||||||
{ key: "teams", icon: "bx bx-group", label: "Teams" },
|
{ key: "teams", icon: "bx bx-group", label: "Teams" },
|
||||||
|
|
||||||
{
|
{
|
||||||
key: "directory",
|
key: "directory",
|
||||||
icon: "bx bxs-contact",
|
icon: "bx bxs-contact",
|
||||||
label: "Directory",
|
label: "Directory",
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
];
|
];
|
||||||
return (
|
return (
|
||||||
<div className="table-responsive">
|
<div className="table-responsive">
|
||||||
<div className="nav-align-top">
|
<div className="nav-align-top">
|
||||||
<ul className="nav nav-tabs">
|
<ul className="nav nav-tabs">
|
||||||
{ProjectTab?.filter((tab) => !tab.hidden)?.map((tab) => (
|
{ProjectTab?.filter((tab) => !tab.hidden)?.map((tab) => (
|
||||||
<li key={tab.key} className="nav-item cursor-pointer">
|
<li key={tab.key} className="nav-item cursor-pointer">
|
||||||
<a
|
<a
|
||||||
|
className={`nav-link ${
|
||||||
className={`nav-link ${activePill === tab.key ? "active cursor-pointer" : ""
|
activePill === tab.key ? "active cursor-pointer" : ""
|
||||||
} fs-6`}
|
} fs-6`}
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
onPillClick(tab.key);
|
onPillClick(tab.key);
|
||||||
@ -42,7 +40,7 @@ const ServiceProjectNav = ({ onPillClick, activePill }) => {
|
|||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
);
|
||||||
}
|
};
|
||||||
|
|
||||||
export default ServiceProjectNav
|
export default ServiceProjectNav;
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
|
|
||||||
|
//#region Service Project
|
||||||
export const projectSchema = z.object({
|
export const projectSchema = z.object({
|
||||||
name: z.string().min(1, "Name is required"),
|
name: z.string().min(1, "Name is required"),
|
||||||
shortName: z.string().min(1, "Short name is required"),
|
shortName: z.string().min(1, "Short name is required"),
|
||||||
@ -31,12 +32,15 @@ export const defaultProjectValues = {
|
|||||||
contactEmail: "",
|
contactEmail: "",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//#endregion
|
||||||
|
|
||||||
//#region JobSchema
|
//#region JobSchema
|
||||||
|
|
||||||
export const TagSchema = z.object({
|
export const TagSchema = z.object({
|
||||||
name: z.string().min(1, "Tag name is required"),
|
name: z.string().min(1, "Tag name is required"),
|
||||||
isActive: z.boolean().default(true),
|
isActive: z.boolean().default(true),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const jobSchema = z.object({
|
export const jobSchema = z.object({
|
||||||
title: z.string().min(1, "Title is required"),
|
title: z.string().min(1, "Title is required"),
|
||||||
description: z.string().min(1, "Description is required"),
|
description: z.string().min(1, "Description is required"),
|
||||||
@ -57,27 +61,27 @@ const ALLOWED_TYPES = [
|
|||||||
"image/jpg",
|
"image/jpg",
|
||||||
"image/jpeg",
|
"image/jpeg",
|
||||||
];
|
];
|
||||||
|
|
||||||
export const JobCommentSchema = z.object({
|
export const JobCommentSchema = z.object({
|
||||||
comment: z.string().min(1, { message: "Please leave comment" }),
|
comment: z.string().min(1, { message: "Please leave comment" }),
|
||||||
attachments: z
|
attachments: z
|
||||||
.array(
|
.array(
|
||||||
z.object({
|
z.object({
|
||||||
fileName: z.string().min(1),
|
fileName: z.string().min(1),
|
||||||
base64Data: z.string().nullable(),
|
base64Data: z.string().nullable(),
|
||||||
contentType: z.string().refine((val) => ALLOWED_TYPES.includes(val), {
|
contentType: z.string().refine((val) => ALLOWED_TYPES.includes(val), {
|
||||||
message: "Only PDF, PNG, JPG, or JPEG files are allowed",
|
message: "Only PDF, PNG, JPG, or JPEG files are allowed",
|
||||||
}),
|
}),
|
||||||
documentId: z.string().optional(),
|
documentId: z.string().optional(),
|
||||||
fileSize: z.number().max(MAX_FILE_SIZE),
|
fileSize: z.number().max(MAX_FILE_SIZE),
|
||||||
description: z.string().optional(),
|
description: z.string().optional(),
|
||||||
isActive: z.boolean().default(true),
|
isActive: z.boolean().default(true),
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
.optional()
|
.optional()
|
||||||
.default([]),
|
.default([]),
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export const defaultJobValue = {
|
export const defaultJobValue = {
|
||||||
title: "",
|
title: "",
|
||||||
description: "",
|
description: "",
|
||||||
|
|||||||
@ -1,4 +1,9 @@
|
|||||||
import { useInfiniteQuery, useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
import {
|
||||||
|
useInfiniteQuery,
|
||||||
|
useMutation,
|
||||||
|
useQuery,
|
||||||
|
useQueryClient,
|
||||||
|
} from "@tanstack/react-query";
|
||||||
import { ServiceProjectRepository } from "../repositories/ServiceProjectRepository";
|
import { ServiceProjectRepository } from "../repositories/ServiceProjectRepository";
|
||||||
import showToast from "../services/toastService";
|
import showToast from "../services/toastService";
|
||||||
|
|
||||||
@ -121,13 +126,17 @@ export const useServiceProjectJobs = (
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
export const useJobComments = (jobId, pageSize, pageNumber ) => {
|
export const useJobComments = (jobId, pageSize, pageNumber) => {
|
||||||
return useInfiniteQuery({
|
return useInfiniteQuery({
|
||||||
queryKey: ["jobComments", jobId, pageSize],
|
queryKey: ["jobComments", jobId, pageSize],
|
||||||
|
|
||||||
queryFn: async ({ pageParam = pageNumber }) => {
|
queryFn: async ({ pageParam = pageNumber }) => {
|
||||||
const resp = await ServiceProjectRepository.GetJobComment(jobId, pageSize, pageParam);
|
const resp = await ServiceProjectRepository.GetJobComment(
|
||||||
return resp.data;
|
jobId,
|
||||||
|
pageSize,
|
||||||
|
pageParam
|
||||||
|
);
|
||||||
|
return resp.data;
|
||||||
},
|
},
|
||||||
|
|
||||||
initialPageParam: pageNumber,
|
initialPageParam: pageNumber,
|
||||||
@ -139,6 +148,12 @@ export const useJobComments = (jobId, pageSize, pageNumber ) => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
export const useJobTags = () => {
|
||||||
|
return useQuery({
|
||||||
|
queryKey: ["Job_Tags"],
|
||||||
|
queryFn: async () => await ServiceProjectRepository.GetJobTags(),
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
export const useServiceProjectJobDetails = (job) => {
|
export const useServiceProjectJobDetails = (job) => {
|
||||||
return useQuery({
|
return useQuery({
|
||||||
|
|||||||
@ -21,8 +21,9 @@ export const ServiceProjectRepository = {
|
|||||||
),
|
),
|
||||||
GetJobDetails: (id) => api.get(`/api/ServiceProject/job/details/${id}`),
|
GetJobDetails: (id) => api.get(`/api/ServiceProject/job/details/${id}`),
|
||||||
AddComment: (data) => api.post("/api/ServiceProject/job/add/comment", data),
|
AddComment: (data) => api.post("/api/ServiceProject/job/add/comment", data),
|
||||||
GetJobComment: (jobTicketId,pageSize,pageNumber) =>
|
GetJobComment: (jobTicketId, pageSize, pageNumber) =>
|
||||||
api.get(
|
api.get(
|
||||||
`/api/ServiceProject/job/comment/list?jobTicketId=${jobTicketId}&pageSize=${pageSize}&pageNumber=${pageNumber}`
|
`/api/ServiceProject/job/comment/list?jobTicketId=${jobTicketId}&pageSize=${pageSize}&pageNumber=${pageNumber}`
|
||||||
),
|
),
|
||||||
|
GetJobTags: () => api.get(`/api/ServiceProject/job/tag/list`),
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user