added fetch api of jobs
This commit is contained in:
parent
2746e9d2bb
commit
844a6f59d1
141
src/components/ServiceProject/JobList.jsx
Normal file
141
src/components/ServiceProject/JobList.jsx
Normal file
@ -0,0 +1,141 @@
|
||||
import React from "react";
|
||||
import { getNextBadgeColor } from "../../utils/appUtils";
|
||||
import { useServiceProjectJobs } from "../../hooks/useServiceProject";
|
||||
import { ITEMS_PER_PAGE } from "../../utils/constants";
|
||||
import EmployeeAvatarGroup from "../common/EmployeeAvatarGroup";
|
||||
import { formatUTCToLocalTime } from "../../utils/dateUtils";
|
||||
import { SpinnerLoader } from "../common/Loader";
|
||||
import { useParams } from "react-router-dom";
|
||||
|
||||
const JobList = ({ filterByProject }) => {
|
||||
const { id } = useParams();
|
||||
const { data, isLoading, isError, error } = useServiceProjectJobs(
|
||||
ITEMS_PER_PAGE,
|
||||
1,
|
||||
true,
|
||||
filterByProject ?? id
|
||||
);
|
||||
|
||||
const jobGrid = [
|
||||
{
|
||||
key: "title",
|
||||
label: "Title",
|
||||
getValue: (e) => (
|
||||
<span
|
||||
className="fw-semibold text-truncate d-inline-block"
|
||||
style={{
|
||||
maxWidth: "100%",
|
||||
width: "210px",
|
||||
}}
|
||||
>
|
||||
{e?.title}
|
||||
</span>
|
||||
),
|
||||
isAlwaysVisible: true,
|
||||
className: "text-start",
|
||||
},
|
||||
{
|
||||
key: "project",
|
||||
label: "Project",
|
||||
getValue: (e) => <div className="text-start ">{e?.project?.name}</div>,
|
||||
isAlwaysVisible: true,
|
||||
className: "text-start d-none d-sm-table-cell",
|
||||
},
|
||||
|
||||
{
|
||||
key: "employee",
|
||||
label: "Team",
|
||||
getValue: (e) => <EmployeeAvatarGroup employees={e.assignees} />,
|
||||
isAlwaysVisible: true,
|
||||
className: "text-start d-none d-sm-table-cell",
|
||||
},
|
||||
|
||||
{
|
||||
key: "startDate",
|
||||
label: "Start Date",
|
||||
getValue: (e) => formatUTCToLocalTime(e.startDate),
|
||||
isAlwaysVisible: true,
|
||||
className: "text-center ",
|
||||
},
|
||||
{
|
||||
key: "dueDate",
|
||||
label: "Due To",
|
||||
getValue: (e) => formatUTCToLocalTime(e.startDate),
|
||||
isAlwaysVisible: true,
|
||||
className: "text-center d-none d-sm-table-cell",
|
||||
},
|
||||
];
|
||||
|
||||
return (
|
||||
<div className="dataTables_wrapper dt-bootstrap5 no-footer ">
|
||||
<table
|
||||
className="datatables-users table border-top dataTable no-footer dtr-column text-nowrap table-responsive"
|
||||
aria-describedby="DataTables_Table_0_info"
|
||||
>
|
||||
<thead>
|
||||
<tr>
|
||||
{jobGrid.map((col) => (
|
||||
<th
|
||||
key={col.key}
|
||||
className={`${col.className} text-center`}
|
||||
scope="col"
|
||||
>
|
||||
<div className={col.className}>{col.label}</div>
|
||||
</th>
|
||||
))}
|
||||
<th className="sorting_disabled text-center" aria-label="Actions">
|
||||
Actions
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
{Array.isArray(data?.data) && data.data.length > 0 ? (
|
||||
data.data.map((row, i) => (
|
||||
<tr key={i}>
|
||||
{jobGrid.map((col) => (
|
||||
<td key={col.key} className={col.className}>
|
||||
{col.getValue(row)}
|
||||
</td>
|
||||
))}
|
||||
<td>
|
||||
<div className="dropdown">
|
||||
<button
|
||||
className="btn btn-icon dropdown-toggle hide-arrow"
|
||||
data-bs-toggle="dropdown"
|
||||
>
|
||||
<i className="bx bx-dots-vertical-rounded bx-md"></i>
|
||||
</button>
|
||||
<div className="dropdown-menu dropdown-menu-end">
|
||||
{/* View always visible */}
|
||||
<button className="dropdown-item py-1">
|
||||
<i className="bx bx-detail bx-sm"></i> View
|
||||
</button>
|
||||
|
||||
<>
|
||||
<button className="dropdown-item py-1">
|
||||
<i className="bx bx-edit bx-sm"></i> Edit
|
||||
</button>
|
||||
</>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
))
|
||||
) : (
|
||||
<tr style={{ height: "200px" }}>
|
||||
<td
|
||||
colSpan={jobGrid.length + 1}
|
||||
className="text-center border-0 align-middle"
|
||||
>
|
||||
{isLoading ? <SpinnerLoader /> : "Not Found Jobs."}
|
||||
</td>
|
||||
</tr>
|
||||
)}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default JobList;
|
||||
@ -1,11 +1,49 @@
|
||||
import React from 'react'
|
||||
import React, { useEffect, useState } from "react";
|
||||
import JobList from "./JobList";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { useServiceProjects } from "../../hooks/useServiceProject";
|
||||
import { ITEMS_PER_PAGE } from "../../utils/constants";
|
||||
|
||||
const Jobs = () => {
|
||||
return (
|
||||
<div className='row'>
|
||||
<div className='col-12'></div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
const [selectedProject, setSelectedProject] = useState(null);
|
||||
const navigate = useNavigate();
|
||||
|
||||
export default Jobs
|
||||
const { data } = useServiceProjects(ITEMS_PER_PAGE, 1);
|
||||
return (
|
||||
<div className="card page-min-h my-2 px-4">
|
||||
<div className="row">
|
||||
<div className="col-12 py-2 d-flex justify-content-between ">
|
||||
<div>
|
||||
{" "}
|
||||
<select
|
||||
className="form-select form-select-sm"
|
||||
value={selectedProject}
|
||||
onChange={(e) => setSelectedProject(e.target.value)}
|
||||
>
|
||||
<option disabled selected>
|
||||
Select Poject
|
||||
</option>
|
||||
{data?.data?.map((project) => (
|
||||
<option key={project.id} value={project.id}>
|
||||
{project.name}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
<div className="px-2">
|
||||
<button
|
||||
className="btn btn-sm btn-primary"
|
||||
onClick={() => navigate("/service/job")}
|
||||
>
|
||||
<i className="bx bx-plus-circle bx-md me-2"></i>New Job
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<JobList filterByProject={selectedProject} />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default Jobs;
|
||||
|
||||
@ -1,9 +1,72 @@
|
||||
import React from 'react'
|
||||
import Breadcrumb from '../common/Breadcrumb'
|
||||
import React from "react";
|
||||
import Breadcrumb from "../common/Breadcrumb";
|
||||
import Label from "../common/Label";
|
||||
import { FormProvider, useForm } from "react-hook-form";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import { defaultJobValue, jobSchema } from "./ServiceProjectSchema";
|
||||
import {
|
||||
useCreateServiceProjectJob,
|
||||
useServiceProjects,
|
||||
} from "../../hooks/useServiceProject";
|
||||
import { ITEMS_PER_PAGE } from "../../utils/constants";
|
||||
import DatePicker from "../common/DatePicker";
|
||||
import PmsEmployeeInputTag from "../common/PmsEmployeeInputTag";
|
||||
import TagInput from "../common/TagInput";
|
||||
import { localToUtc } from "../../utils/appUtils";
|
||||
|
||||
const ManageJob = () => {
|
||||
const methods = useForm({
|
||||
resolver: zodResolver(jobSchema),
|
||||
defaultValues: defaultJobValue,
|
||||
});
|
||||
|
||||
const {
|
||||
register,
|
||||
control,
|
||||
watch,
|
||||
handleSubmit,
|
||||
reset,
|
||||
formState: { errors },
|
||||
} = methods;
|
||||
|
||||
const {
|
||||
data,
|
||||
isLoading: isProjectLoading,
|
||||
isError: isProjectError,
|
||||
error,
|
||||
} = useServiceProjects(ITEMS_PER_PAGE, 1);
|
||||
|
||||
const { mutate: CreateJob, isPending } = useCreateServiceProjectJob(() => {
|
||||
reset();
|
||||
});
|
||||
const onSubmit = (formData) => {
|
||||
// if (serviceProjectId) {
|
||||
// let existingServiceIds = projectdata?.services?.map((s) => s.id) || [];
|
||||
|
||||
// const oldAssigneed = projectdata.services.map((service) => ({
|
||||
// serviceId: service.id,
|
||||
// isActive: formData.services.includes(service.id),
|
||||
// }));
|
||||
|
||||
// const newAassigneed = formData.services
|
||||
// .filter((s) => !existingServiceIds.includes(s))
|
||||
// .map((service) => ({ serviceId: service, isActive: true }));
|
||||
|
||||
// formData.assignees = [...oldServices, ...newServices];
|
||||
// }
|
||||
|
||||
formData.assignees = formData.assignees.map((emp) => ({
|
||||
employeeId: emp,
|
||||
isActive: true,
|
||||
}));
|
||||
|
||||
formData.startDate = localToUtc(formData.startDate);
|
||||
formData.dueDate = localToUtc(formData.dueDate);
|
||||
CreateJob(formData);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className='container-fluid'>
|
||||
<div className="container-fluid">
|
||||
<Breadcrumb
|
||||
data={[
|
||||
{ label: "Home", link: "/dashboard" },
|
||||
@ -11,9 +74,102 @@ const ManageJob = () => {
|
||||
{ label: "" || "Jobs", link: null },
|
||||
]}
|
||||
/>
|
||||
|
||||
<div className="card m-auto page-min-h">
|
||||
<div className="col-4 p-3"></div>
|
||||
<div className="col-md-8 p-3">
|
||||
<FormProvider {...methods}>
|
||||
<form className="row text-start" onSubmit={handleSubmit(onSubmit)}>
|
||||
<div>
|
||||
<p className="fs-5 fw-medium">Create Job</p>
|
||||
</div>
|
||||
<div className="col-12 col-md-6 mb-2 mb-md-4">
|
||||
<Label required>Title</Label>
|
||||
<input
|
||||
type="text"
|
||||
{...register("title")}
|
||||
className="form-control form-control-sm"
|
||||
/>
|
||||
</div>
|
||||
<div className="col-12 col-md-6 mb-2 mb-md-4">
|
||||
<Label required>Project</Label>
|
||||
<select
|
||||
className="form-select form-select-sm"
|
||||
{...register("projectId")}
|
||||
>
|
||||
{isProjectLoading ? (
|
||||
<option selected disabled>
|
||||
Loading....
|
||||
</option>
|
||||
) : (
|
||||
<>
|
||||
<option selected disabled>
|
||||
Select Project
|
||||
</option>
|
||||
{data?.data?.map((project) => (
|
||||
<option
|
||||
key={project.id}
|
||||
value={project.id}
|
||||
className="selection-option"
|
||||
>
|
||||
{project.name}
|
||||
</option>
|
||||
))}
|
||||
</>
|
||||
)}
|
||||
</select>
|
||||
</div>
|
||||
<div className="col-12 col-md-6 mb-2 mb-md-4">
|
||||
<Label required>Start Date</Label>
|
||||
<DatePicker
|
||||
name="startDate"
|
||||
control={control}
|
||||
placeholder="DD-MM-YYYY"
|
||||
className="w-full"
|
||||
/>
|
||||
</div>
|
||||
<div className="col-12 col-md-6 mb-2 mb-md-4">
|
||||
<Label required>End Date</Label>
|
||||
<DatePicker
|
||||
control={control}
|
||||
minDate={watch("startDate")}
|
||||
name="dueDate"
|
||||
className="w-full"
|
||||
/>
|
||||
</div>
|
||||
<div className="col-12 col-md-6 mb-2 mb-md-4">
|
||||
<Label required>End Date</Label>
|
||||
<PmsEmployeeInputTag
|
||||
control={control}
|
||||
name="assignees"
|
||||
placeholder="Enter employee"
|
||||
/>
|
||||
</div>
|
||||
<div className="col-12 col-md-6 mb-2 mb-md-4">
|
||||
<TagInput name="tags" label="Tag" required />
|
||||
</div>
|
||||
<div className="col-12">
|
||||
<Label required>Description</Label>
|
||||
<textarea
|
||||
{...register("description")}
|
||||
className="form-control form-control-sm"
|
||||
rows={3}
|
||||
/>
|
||||
</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>
|
||||
</FormProvider>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
export default ManageJob
|
||||
export default ManageJob;
|
||||
|
||||
@ -7,6 +7,7 @@ const ServiceProjectNav = ({ onPillClick, activePill }) => {
|
||||
key: "jobs",
|
||||
icon: "bx bx-briefcase-alt",
|
||||
label: "Jobs",
|
||||
link:"/service/job",
|
||||
},
|
||||
{ key: "teams", icon: "bx bx-group", label: "Teams" },
|
||||
|
||||
|
||||
@ -28,3 +28,37 @@ export const defaultProjectValues = {
|
||||
contactPhone: "",
|
||||
contactEmail: "",
|
||||
};
|
||||
|
||||
//#region JobSchema
|
||||
|
||||
export const TagSchema = z.object({
|
||||
name: z.string().min(1, "Tag name is required"),
|
||||
isActive: z.boolean().default(true),
|
||||
});
|
||||
export const jobSchema = z.object({
|
||||
title: z.string().min(1, "Title is required"),
|
||||
description: z.string().min(1, "Description is required"),
|
||||
projectId: z.string().min(1,"Project is required"),
|
||||
|
||||
assignees: z
|
||||
.array(z.string() )
|
||||
.nonempty("At least one assignee is required"),
|
||||
|
||||
startDate: z.string(),
|
||||
dueDate: z.string(),
|
||||
|
||||
tags: z.array(TagSchema).optional().default([]),
|
||||
});
|
||||
|
||||
export const defaultJobValue = {
|
||||
title:"",
|
||||
description:"",
|
||||
projectId:"",
|
||||
assignees:[],
|
||||
startDate:null,
|
||||
dueDate:null,
|
||||
tags:[]
|
||||
|
||||
}
|
||||
|
||||
//#endregion
|
||||
91
src/components/common/EmployeeAvatarGroup.jsx
Normal file
91
src/components/common/EmployeeAvatarGroup.jsx
Normal file
@ -0,0 +1,91 @@
|
||||
import React from "react";
|
||||
import Avatar from "./Avatar";
|
||||
import Tooltip from "./Tooltip";
|
||||
import HoverPopup from "./HoverPopup";
|
||||
import { map } from "zod";
|
||||
|
||||
const EmployeeAvatarGroup = ({ employees = [] }) => {
|
||||
const visibleEmployees = employees.slice(0, 3);
|
||||
const remainingEmployees = employees.slice(3);
|
||||
const remainingCount = employees.length - visibleEmployees.length;
|
||||
|
||||
return (
|
||||
<div className="d-flex align-items-center avatar-group my-1 text-capitalize ">
|
||||
{visibleEmployees.map((emp, i) => (
|
||||
<div key={i} className="avatar avatar-sm me-1">
|
||||
<HoverPopup title={"Employee"} content={<EmployeeDetails e={emp} />}>
|
||||
{emp.avatarUrl ? (
|
||||
<img
|
||||
src={emp.avatarUrl}
|
||||
alt={`${emp.firstName} ${emp.lastName}`}
|
||||
className="rounded-circle pull-up"
|
||||
title={`${emp.firstName} ${emp.lastName}`}
|
||||
width="40"
|
||||
height="40"
|
||||
/>
|
||||
) : (
|
||||
<Avatar
|
||||
firstName={emp.firstName}
|
||||
lastName={emp.lastName}
|
||||
classAvatar="pull-up"
|
||||
/>
|
||||
)}
|
||||
</HoverPopup>
|
||||
</div>
|
||||
))}
|
||||
|
||||
{remainingCount > 0 && (
|
||||
<div className="avatar p-1">
|
||||
<div className={`avatar avatar-sm `}>
|
||||
<span className="avatar-initial rounded-circle pull-up text-dark border">
|
||||
<HoverPopup
|
||||
title={`More ${remainingCount} emplopyee`}
|
||||
content={<Remaning emp={remainingEmployees} />}
|
||||
>
|
||||
+{remainingCount}
|
||||
</HoverPopup>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default EmployeeAvatarGroup;
|
||||
|
||||
const EmployeeDetails = ({ e }) => {
|
||||
return (
|
||||
<a className="list-group-item list-group-item-action d-flex justify-content-between text-capitalize">
|
||||
<div className="li-wrapper d-flex justify-content-start align-items-start">
|
||||
<Avatar firstName={e?.firstName} lastName={e?.lastName} />
|
||||
<div className="list-content">
|
||||
<p className="mb-0">{`${e?.firstName}' ${e?.lastName} `}</p>
|
||||
<small className="text-body-secondary">
|
||||
{e?.jobRoleName ?? "employee"}
|
||||
</small>
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
);
|
||||
};
|
||||
export const Remaning = ({ emp }) => {
|
||||
console.log(emp);
|
||||
return (
|
||||
<div className="w-100">
|
||||
{emp?.map((e) => (
|
||||
<a className="list-group-item list-group-item-action d-flex justify-content-between text-capitalize">
|
||||
<div className="li-wrapper d-flex justify-content-start align-items-start">
|
||||
<Avatar firstName={e?.firstName} lastName={e?.lastName} />
|
||||
<div className="list-content">
|
||||
<p className="mb-0">{`${e?.firstName} ${e?.lastName} `}</p>
|
||||
<small className="text-body-secondary">
|
||||
{e?.jobRoleName ?? "employee"}
|
||||
</small>
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@ -26,7 +26,7 @@ const HoverPopup = ({ title, content, children }) => {
|
||||
|
||||
return (
|
||||
<div
|
||||
className="d-inline-block position-relative"
|
||||
className="d-inline-block position-relative text-capitalize"
|
||||
ref={triggerRef}
|
||||
onMouseEnter={handleMouseEnter}
|
||||
onMouseLeave={() => setVisible(false)}
|
||||
@ -38,18 +38,8 @@ const HoverPopup = ({ title, content, children }) => {
|
||||
{visible && (
|
||||
<div
|
||||
ref={popupRef}
|
||||
className="bg-white border rounded shadow-sm p-3 text-start"
|
||||
style={{
|
||||
position: "absolute",
|
||||
top: "100%",
|
||||
left: "50%",
|
||||
transform: "translateX(-50%)",
|
||||
zIndex: 1050,
|
||||
minWidth: "240px",
|
||||
maxWidth: "300px",
|
||||
marginTop: "8px",
|
||||
whiteSpace: "normal",
|
||||
}}
|
||||
className="bg-white border rounded shadow-sm p-3 text-start position-absolute top-100 start-500 translate-middle mt-12"
|
||||
|
||||
>
|
||||
{title && (
|
||||
<h6 className="mb-2 fw-semibold text-dark" style={{ fontSize: "0.9rem" }}>
|
||||
|
||||
@ -2,7 +2,7 @@ import { useFormContext, useWatch } from "react-hook-form";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import Label from "./Label";
|
||||
|
||||
const TagInput = ({ label, name, placeholder, color = "#e9ecef", options = [] }) => {
|
||||
const TagInput = ({ label, name, placeholder, color = "#e9ecef", required=false, options = [] }) => {
|
||||
const { setValue, watch } = useFormContext();
|
||||
const tags = watch(name) || [];
|
||||
const [input, setInput] = useState("");
|
||||
@ -65,13 +65,13 @@ const handleChange = (e) => {
|
||||
|
||||
return (
|
||||
<>
|
||||
<label htmlFor={name} className="form-label">
|
||||
<Label htmlFor={name} className="form-label" required={required}>
|
||||
{label}
|
||||
</label>
|
||||
</Label>
|
||||
|
||||
<div
|
||||
className="form-control form-control-sm p-1"
|
||||
style={{ minHeight: "38px", position: "relative" }}
|
||||
style={{ minHeight: "33px", position: "relative" }}
|
||||
>
|
||||
<div className="d-flex flex-wrap align-items-center gap-1">
|
||||
{tags.map((tag, index) => (
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import { ServiceProjectRepository } from "../repositories/ServiceProject";
|
||||
import { ServiceProjectRepository } from "../repositories/ServiceProjectRepository";
|
||||
import showToast from "../services/toastService";
|
||||
|
||||
//#region Service Project
|
||||
export const useServiceProjects = (pageSize, pageNumber) => {
|
||||
return useQuery({
|
||||
queryKey: ["serviceProjects", pageSize, pageNumber],
|
||||
@ -97,3 +98,42 @@ export const useActiveInActiveServiceProject = (onSuccessCallback) => {
|
||||
},
|
||||
});
|
||||
};
|
||||
//#endregion
|
||||
|
||||
//#region Service Jobs
|
||||
|
||||
|
||||
export const useServiceProjectJobs=(pageSize,pageNumber,isActive=true,project)=>{
|
||||
return useQuery({
|
||||
queryKey:["serviceProjectJobs",pageSize,pageNumber,isActive,project],
|
||||
queryFn:async() =>{
|
||||
const resp = await ServiceProjectRepository.GetJobList(pageSize,pageNumber,isActive,project);
|
||||
return resp.data;
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export const useCreateServiceProjectJob = (onSuccessCallback) => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation({
|
||||
mutationFn: async (payload) => {
|
||||
return await ServiceProjectRepository.CreateJob(payload);
|
||||
},
|
||||
onSuccess: (data, variables) => {
|
||||
queryClient.invalidateQueries({ queryKey: [""] });
|
||||
|
||||
if (onSuccessCallback) onSuccessCallback();
|
||||
showToast("Job Created successfully", "success");
|
||||
},
|
||||
onError: (error) => {
|
||||
showToast(
|
||||
error?.response?.data?.message ||
|
||||
error.message ||
|
||||
"Failed to update project",
|
||||
"error"
|
||||
);
|
||||
},
|
||||
});
|
||||
};
|
||||
//#endregion
|
||||
|
||||
@ -1,10 +0,0 @@
|
||||
import { api } from "../utils/axiosClient";
|
||||
|
||||
export const ServiceProjectRepository = {
|
||||
CreateServiceProject: (data) => api.post("/api/ServiceProject/create", data),
|
||||
GetServiceProjects: (pageSize,pageNumber) => api.get(`/api/ServiceProject/list?pageSize=${pageSize}&pageNumber=${pageNumber}`),
|
||||
GetServiceProject: (id) => api.get(`/api/ServiceProject/details/${id}`),
|
||||
UpdateServiceProject: (id, data) =>
|
||||
api.put(`/api/ServiceProject/edit/${id}`, data),
|
||||
DeleteServiceProject: (id,isActive=false) => api.delete(`/api/ServiceProject/delete/${id}?isActive=${isActive}`,),
|
||||
};
|
||||
22
src/repositories/ServiceProjectRepository.jsx
Normal file
22
src/repositories/ServiceProjectRepository.jsx
Normal file
@ -0,0 +1,22 @@
|
||||
import { api } from "../utils/axiosClient";
|
||||
|
||||
export const ServiceProjectRepository = {
|
||||
CreateServiceProject: (data) => api.post("/api/ServiceProject/create", data),
|
||||
GetServiceProjects: (pageSize, pageNumber) =>
|
||||
api.get(
|
||||
`/api/ServiceProject/list?pageSize=${pageSize}&pageNumber=${pageNumber}`
|
||||
),
|
||||
GetServiceProject: (id) => api.get(`/api/ServiceProject/details/${id}`),
|
||||
UpdateServiceProject: (id, data) =>
|
||||
api.put(`/api/ServiceProject/edit/${id}`, data),
|
||||
DeleteServiceProject: (id, isActive = false) =>
|
||||
api.delete(`/api/ServiceProject/delete/${id}?isActive=${isActive}`),
|
||||
|
||||
//#region Job
|
||||
|
||||
CreateJob: (data) => api.post(`/api/ServiceProject/job/create`, data),
|
||||
GetJobList: (pageSize, pageNumber, isActive,projectId,) =>
|
||||
api.get(
|
||||
`/api/ServiceProject/job/list?pageSize=${pageSize}&pageNumber=${pageNumber}&isActive=${isActive}&projectId=${projectId}`
|
||||
),
|
||||
};
|
||||
@ -191,3 +191,20 @@ export const frequencyLabel = (
|
||||
return isLong ? "Unknown" : "N/A";
|
||||
}
|
||||
};
|
||||
|
||||
const badgeColors = [
|
||||
"primary",
|
||||
"secondary",
|
||||
"success",
|
||||
"warning",
|
||||
"info",
|
||||
];
|
||||
|
||||
let colorIndex = 0;
|
||||
|
||||
export function getNextBadgeColor(type="label") {
|
||||
const color = badgeColors[colorIndex];
|
||||
colorIndex = (colorIndex + 1) % badgeColors.length;
|
||||
return `rounded-pill text-bg-${color}`;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user