Merge branch 'Service_Project_Managment' of https://git.marcoaiot.com/admin/marco.pms.web into Kartik_Bug#1737
This commit is contained in:
commit
05f45a66d8
@ -3,6 +3,11 @@
|
||||
--bs-nav-link-font-size: 0.7375rem;
|
||||
--bg-border-color :#f8f6f6
|
||||
}
|
||||
.offcanvas.offcanvas-wide {
|
||||
width: 700px !important; /* adjust as needed */
|
||||
max-width: 90vw; /* responsive fallback */
|
||||
}
|
||||
|
||||
/* ===========================% Background_Colors %========================================================== */
|
||||
.bg-light-primary {
|
||||
background-color: color-mix(in srgb, var(--bs-primary) 10.4%, transparent);
|
||||
|
||||
@ -44,9 +44,8 @@ const PaymentRequestList = ({ filters, groupBy = "submittedBy", search }) => {
|
||||
displayField = "Status";
|
||||
break;
|
||||
case "submittedBy":
|
||||
key = `${item?.createdBy?.firstName ?? ""} ${
|
||||
item.createdBy?.lastName ?? ""
|
||||
}`.trim();
|
||||
key = `${item?.createdBy?.firstName ?? ""} ${item.createdBy?.lastName ?? ""
|
||||
}`.trim();
|
||||
displayField = "Submitted By";
|
||||
break;
|
||||
case "project":
|
||||
@ -93,40 +92,52 @@ const PaymentRequestList = ({ filters, groupBy = "submittedBy", search }) => {
|
||||
align: "text-start",
|
||||
getValue: (e) => e.title || "N/A",
|
||||
},
|
||||
// { key: "payee", label: "Payee", align: "text-start" },
|
||||
{
|
||||
key: "SubmittedBy",
|
||||
label: "Submitted By",
|
||||
align: "text-start",
|
||||
getValue: (e) =>
|
||||
`${e.createdBy?.firstName ?? ""} ${
|
||||
e.createdBy?.lastName ?? ""
|
||||
}`.trim() || "N/A",
|
||||
customRender: (e) => (
|
||||
<div
|
||||
className="d-flex align-items-center cursor-pointer"
|
||||
onClick={() => navigate(`/employee/${e.createdBy?.id}`)}
|
||||
>
|
||||
<Avatar
|
||||
size="xs"
|
||||
classAvatar="m-0"
|
||||
firstName={e.createdBy?.firstName}
|
||||
lastName={e.createdBy?.lastName}
|
||||
/>
|
||||
<span className="text-truncate">
|
||||
{`${e.createdBy?.firstName ?? ""} ${
|
||||
e.createdBy?.lastName ?? ""
|
||||
}`.trim() || "N/A"}
|
||||
</span>
|
||||
</div>
|
||||
),
|
||||
},
|
||||
// {
|
||||
// key: "SubmittedBy",
|
||||
// label: "Submitted By",
|
||||
// align: "text-start",
|
||||
// getValue: (e) =>
|
||||
// `${e.createdBy?.firstName ?? ""} ${
|
||||
// e.createdBy?.lastName ?? ""
|
||||
// }`.trim() || "N/A",
|
||||
// customRender: (e) => (
|
||||
// <div
|
||||
// className="d-flex align-items-center cursor-pointer"
|
||||
// onClick={() => navigate(`/employee/${e.createdBy?.id}`)}
|
||||
// >
|
||||
// <Avatar
|
||||
// size="xs"
|
||||
// classAvatar="m-0"
|
||||
// firstName={e.createdBy?.firstName}
|
||||
// lastName={e.createdBy?.lastName}
|
||||
// />
|
||||
// <span className="text-truncate">
|
||||
// {`${e.createdBy?.firstName ?? ""} ${
|
||||
// e.createdBy?.lastName ?? ""
|
||||
// }`.trim() || "N/A"}
|
||||
// </span>
|
||||
// </div>
|
||||
// ),
|
||||
// },
|
||||
{
|
||||
key: "createdAt",
|
||||
label: "Submitted On",
|
||||
label: "Created At",
|
||||
align: "text-start",
|
||||
getValue: (e) => formatUTCToLocalTime(e?.createdAt),
|
||||
},
|
||||
{
|
||||
key: "payee",
|
||||
label: "Payee",
|
||||
align: "text-start",
|
||||
getValue: (e) => e.payee || "N/A",
|
||||
},
|
||||
{
|
||||
key: "dueDate",
|
||||
label: "Due Date",
|
||||
align: "text-start",
|
||||
getValue: (e) => formatUTCToLocalTime(e?.dueDate),
|
||||
},
|
||||
|
||||
{
|
||||
key: "amount",
|
||||
label: "Amount",
|
||||
@ -143,9 +154,8 @@ const PaymentRequestList = ({ filters, groupBy = "submittedBy", search }) => {
|
||||
align: "text-center",
|
||||
getValue: (e) => (
|
||||
<span
|
||||
className={`badge bg-label-${
|
||||
getColorNameFromHex(e?.expenseStatus?.color) || "secondary"
|
||||
}`}
|
||||
className={`badge bg-label-${getColorNameFromHex(e?.expenseStatus?.color) || "secondary"
|
||||
}`}
|
||||
>
|
||||
{e?.expenseStatus?.name || "Unknown"}
|
||||
</span>
|
||||
@ -171,8 +181,8 @@ const PaymentRequestList = ({ filters, groupBy = "submittedBy", search }) => {
|
||||
const header = [
|
||||
"Request ID",
|
||||
"Request Title",
|
||||
"Submitted By",
|
||||
"Submitted On",
|
||||
"Created At",
|
||||
"Due Date",
|
||||
"Amount",
|
||||
"Status",
|
||||
"Action",
|
||||
@ -181,10 +191,10 @@ const PaymentRequestList = ({ filters, groupBy = "submittedBy", search }) => {
|
||||
|
||||
const grouped = groupBy
|
||||
? Object.fromEntries(
|
||||
Object.entries(groupByField(data?.data ?? [], groupBy)).sort(
|
||||
([keyA], [keyB]) => keyA.localeCompare(keyB)
|
||||
)
|
||||
Object.entries(groupByField(data?.data ?? [], groupBy)).sort(
|
||||
([keyA], [keyB]) => keyA.localeCompare(keyB)
|
||||
)
|
||||
)
|
||||
: { All: data?.data ?? [] };
|
||||
|
||||
const IsGroupedByDate = [
|
||||
|
||||
@ -199,7 +199,7 @@ const ViewPaymentRequest = ({ requestId }) => {
|
||||
<div className="row text-start">
|
||||
<div className="col-6 mb-3">
|
||||
<label className="form-label me-2 mb-0 fw-semibold text-start">
|
||||
Supplier:
|
||||
Payee:
|
||||
</label>
|
||||
</div>
|
||||
<div className="col-6 mb-3">
|
||||
@ -271,28 +271,7 @@ const ViewPaymentRequest = ({ requestId }) => {
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
{data?.paidBy && (
|
||||
<div className="col-6 text-start">
|
||||
<div className="d-flex flex-column gap-2 text-start">
|
||||
<label className="form-label me-2 mb-0 fw-semibold">
|
||||
Paid By:
|
||||
</label>
|
||||
<div className="d-flex align-items-center ">
|
||||
<Avatar
|
||||
size="xs"
|
||||
classAvatar="m-0"
|
||||
firstName={data?.paidBy?.firstName}
|
||||
lastName={data?.paidBy?.lastName}
|
||||
/>
|
||||
<span className="text-muted">
|
||||
{`${data?.paidBy?.firstName ?? ""} ${data?.paidBy?.lastName ?? ""
|
||||
}`.trim() || "N/A"}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
)}
|
||||
|
||||
<div className="text-start my-2">
|
||||
<label className="fw-semibold form-label">Description : </label>
|
||||
|
||||
145
src/components/ServiceProject/JobList.jsx
Normal file
145
src/components/ServiceProject/JobList.jsx
Normal file
@ -0,0 +1,145 @@
|
||||
import React, { useState } 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";
|
||||
import ProjectPage from "../../pages/project/ProjectPage";
|
||||
import { useServiceProjectJobContext } from "./Jobs";
|
||||
|
||||
|
||||
const JobList = ({ filterByProject }) => {
|
||||
const {setSelectedJob} = useServiceProjectJobContext()
|
||||
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 d-none d-sm-table-cell ",
|
||||
},
|
||||
{
|
||||
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" onClick={()=>setSelectedJob({showCanvas:true,job:row?.id})}>
|
||||
<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,80 @@
|
||||
import React from 'react'
|
||||
import React, { createContext, useContext, 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";
|
||||
import OffcanvasComponent from "../common/OffcanvasComponent";
|
||||
import showToast from "../../services/toastService";
|
||||
import ManageJob from "./ManageJob";
|
||||
import ManageJobTicket from "./ManageJobTicket";
|
||||
|
||||
export const JonContext = createContext();
|
||||
export const useServiceProjectJobContext = () => {
|
||||
const context = useContext(JonContext);
|
||||
if (!context) {
|
||||
showToast("Something went wrong", "warning");
|
||||
window.location = "/dashboard";
|
||||
}
|
||||
return context;
|
||||
};
|
||||
const Jobs = () => {
|
||||
return (
|
||||
<div className='row'>
|
||||
<div className='col-12'></div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
const [showCanvas, setShowCanvas] = useState(false);
|
||||
const [selectedProject, setSelectedProject] = useState(null);
|
||||
const [selectJob,setSelectedJob] = useState({showCanvas:false,job:null})
|
||||
const navigate = useNavigate();
|
||||
const { data } = useServiceProjects(ITEMS_PER_PAGE, 1);
|
||||
|
||||
export default Jobs
|
||||
const contextProvider = {
|
||||
setSelectedJob
|
||||
}
|
||||
return (
|
||||
<>
|
||||
<JonContext.Provider value={contextProvider}>
|
||||
<OffcanvasComponent
|
||||
id="customCanvas"
|
||||
title="Job"
|
||||
placement="end"
|
||||
show={selectJob.showCanvas}
|
||||
onClose={() => setSelectedJob({showCanvas:false,job:null})}
|
||||
>
|
||||
<ManageJobTicket Job={selectJob} />
|
||||
</OffcanvasComponent>
|
||||
<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>
|
||||
</JonContext.Provider>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default Jobs;
|
||||
|
||||
@ -1,9 +1,63 @@
|
||||
import React from 'react'
|
||||
import Breadcrumb from '../common/Breadcrumb'
|
||||
import React from "react";
|
||||
import Breadcrumb from "../common/Breadcrumb";
|
||||
import Label from "../common/Label";
|
||||
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";
|
||||
import SelectField from "../common/Forms/SelectField";
|
||||
import {
|
||||
AppFormController,
|
||||
AppFormProvider,
|
||||
useAppForm,
|
||||
} from "../../hooks/appHooks/useAppForm";
|
||||
|
||||
const ManageJob = () => {
|
||||
const methods = useAppForm({
|
||||
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) => {
|
||||
formData.assignees = formData.assignees.map((emp) => ({
|
||||
employeeId: emp,
|
||||
isActive: true,
|
||||
}));
|
||||
|
||||
formData.startDate = localToUtc(formData.startDate);
|
||||
formData.dueDate = localToUtc(formData.dueDate);
|
||||
// CreateJob(formData);
|
||||
console.log(formData);
|
||||
};
|
||||
console.log(errors);
|
||||
return (
|
||||
<div className='container-fluid'>
|
||||
<div className="container-fluid">
|
||||
<Breadcrumb
|
||||
data={[
|
||||
{ label: "Home", link: "/dashboard" },
|
||||
@ -11,9 +65,93 @@ const ManageJob = () => {
|
||||
{ label: "" || "Jobs", link: null },
|
||||
]}
|
||||
/>
|
||||
|
||||
<div className="card m-auto page-min-h">
|
||||
<div className="col-md-4 col-12 p-3"></div>
|
||||
<div className="col-md-8 p-3">
|
||||
<AppFormProvider {...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 ">
|
||||
<Label required>Title</Label>
|
||||
<input
|
||||
type="text"
|
||||
{...register("title")}
|
||||
className="form-control form-control"
|
||||
/>
|
||||
</div>
|
||||
<div className="col-12 col-md-6 mb-2">
|
||||
<AppFormController
|
||||
name="projectId"
|
||||
control={control}
|
||||
render={({ field }) => (
|
||||
<SelectField
|
||||
label="Project"
|
||||
options={data?.data}
|
||||
placeholder="Choose a Project"
|
||||
required
|
||||
labelKeyKey="name"
|
||||
valueKeyKey="id"
|
||||
value={field.value}
|
||||
onChange={field.onChange}
|
||||
isLoading={isProjectLoading}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
</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 form-control-md"
|
||||
/>
|
||||
</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>
|
||||
</AppFormProvider>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
export default ManageJob
|
||||
export default ManageJob;
|
||||
|
||||
71
src/components/ServiceProject/ManageJobTicket.jsx
Normal file
71
src/components/ServiceProject/ManageJobTicket.jsx
Normal file
@ -0,0 +1,71 @@
|
||||
import React from "react";
|
||||
import { useServiceProjectJobDetails } from "../../hooks/useServiceProject";
|
||||
import { SpinnerLoader } from "../common/Loader";
|
||||
import Error from "../common/Error";
|
||||
import { formatUTCToLocalTime } from "../../utils/dateUtils";
|
||||
import Avatar from "../common/Avatar";
|
||||
import EmployeeAvatarGroup from "../common/EmployeeAvatarGroup";
|
||||
|
||||
const ManageJobTicket = ({ Job }) => {
|
||||
const { data, isLoading, isError, error } = useServiceProjectJobDetails(
|
||||
Job?.job
|
||||
);
|
||||
if (isLoading) return <SpinnerLoader />;
|
||||
if (isError)
|
||||
return (
|
||||
<div>
|
||||
<Error error={error} />
|
||||
</div>
|
||||
);
|
||||
return (
|
||||
<div className="row text-start">
|
||||
<div className="col-12">
|
||||
<h6 className="fs-5 fw-semibold">{data?.title}</h6>
|
||||
<div className="d-flex justify-content-between">
|
||||
<div className="d-flex flex-row gap-2">
|
||||
<i className="bx bx-calendar"></i>{" "}
|
||||
<span>{formatUTCToLocalTime(data?.createdAt, true)}</span>
|
||||
</div>
|
||||
<span className="badge bg-label-primary">{data?.status?.name}</span>
|
||||
</div>
|
||||
<div className="d-flex flex-wrap my-3">
|
||||
<p>{data?.description}</p>
|
||||
</div>
|
||||
<div className="d-flex flex-row gap-3">
|
||||
<span className="fw-medium">
|
||||
Start Date : {formatUTCToLocalTime(data?.startDate)}
|
||||
</span>{" "}
|
||||
<i className="bx bx-right-arrow-alt"></i>{" "}
|
||||
<span className="fw-medium">
|
||||
Due To : {formatUTCToLocalTime(data?.startDate)}
|
||||
</span>
|
||||
</div>
|
||||
<div className="d-flex justify-content-between">
|
||||
<div className="d-flex align-items-center">
|
||||
<small className="fs-6 text-secondary fs-italic me-3 mt-2">
|
||||
<em>Created By</em>
|
||||
</small>{" "}
|
||||
<Avatar size="xs"
|
||||
firstName={data?.createdBy?.firstName}
|
||||
lastName={data?.createdBy?.lastName}
|
||||
/>{" "}
|
||||
<span className="fw-medium">{`${data?.createdBy?.firstName} ${data?.createdBy?.lastName}`}</span>
|
||||
</div>
|
||||
<div className="d-flex align-items-center">
|
||||
<small className="fs-6 text-secondary fs-italic me-3 mt-2">
|
||||
<em>Created By</em>
|
||||
</small><EmployeeAvatarGroup employees={data?.assignees}/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<hr className="divider"/>
|
||||
<div className="col-12">
|
||||
<div className="">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default ManageJobTicket;
|
||||
@ -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,38 @@ 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>
|
||||
);
|
||||
};
|
||||
94
src/components/common/Forms/SelectField.jsx
Normal file
94
src/components/common/Forms/SelectField.jsx
Normal file
@ -0,0 +1,94 @@
|
||||
import React, { useEffect, useRef, useState } from "react";
|
||||
import Label from "../Label";
|
||||
|
||||
const SelectField = ({
|
||||
label = "Select",
|
||||
options = [],
|
||||
placeholder = "Select Option",
|
||||
required = false,
|
||||
value,
|
||||
onChange,
|
||||
valueKey = "id",
|
||||
labelKey = "name",
|
||||
isLoading = false,
|
||||
}) => {
|
||||
const [open, setOpen] = useState(false);
|
||||
const dropdownRef = useRef(null);
|
||||
|
||||
useEffect(() => {
|
||||
const handleClickOutside = (event) => {
|
||||
if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
|
||||
setOpen(false);
|
||||
}
|
||||
};
|
||||
document.addEventListener("mousedown", handleClickOutside);
|
||||
return () => document.removeEventListener("mousedown", handleClickOutside);
|
||||
}, []);
|
||||
|
||||
const selectedOption = options.find((opt) => opt[valueKey] === value);
|
||||
|
||||
const displayText = selectedOption ? selectedOption[labelKey] : placeholder;
|
||||
|
||||
const handleSelect = (option) => {
|
||||
onChange(option[valueKey]);
|
||||
setOpen(false);
|
||||
};
|
||||
|
||||
const toggleDropdown = () => setOpen((prev) => !prev);
|
||||
|
||||
return (
|
||||
<div className="mb-3 position-relative" ref={dropdownRef}>
|
||||
{label && (
|
||||
<Label className="form-label" required={required}>
|
||||
{label}
|
||||
</Label>
|
||||
)}
|
||||
|
||||
<button
|
||||
type="button"
|
||||
className={`select2-icons form-select d-flex align-items-center justify-content-between ${
|
||||
open ? "show" : ""
|
||||
}`}
|
||||
onClick={toggleDropdown}
|
||||
disabled={isLoading}
|
||||
>
|
||||
<span
|
||||
className={`text-truncate ${!selectedOption ? "text-muted" : ""}`}
|
||||
>
|
||||
{isLoading ? "Loading..." : displayText}
|
||||
</span>
|
||||
</button>
|
||||
|
||||
{open && !isLoading && (
|
||||
<ul
|
||||
className="dropdown-menu w-100 shadow-sm show animate__fadeIn"
|
||||
style={{
|
||||
position: "absolute",
|
||||
top: "100%",
|
||||
left: 0,
|
||||
zIndex: 1050,
|
||||
marginTop: "4px",
|
||||
borderRadius: "0.375rem",
|
||||
overflow: "hidden",
|
||||
}}
|
||||
>
|
||||
{options.map((option, i) => (
|
||||
<li key={i}>
|
||||
<button
|
||||
type="button"
|
||||
className={`dropdown-item ${
|
||||
option[valueKey] === value ? "active" : ""
|
||||
}`}
|
||||
onClick={() => handleSelect(option)}
|
||||
>
|
||||
{option[labelKey]}
|
||||
</button>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default SelectField;
|
||||
98
src/components/common/Forms/SelectFieldServerSide.jsx
Normal file
98
src/components/common/Forms/SelectFieldServerSide.jsx
Normal file
@ -0,0 +1,98 @@
|
||||
import React, { useEffect, useRef, useState } from "react";
|
||||
import Label from "../Label";
|
||||
import { useDebounce } from "../../../utils/appUtils";
|
||||
|
||||
const SelectFieldServerSide = ({
|
||||
label = "Select",
|
||||
options = [],
|
||||
placeholder = "Select Option",
|
||||
required = false,
|
||||
value,
|
||||
onChange,
|
||||
valueKey = "id",
|
||||
labelKey = "name",
|
||||
isLoading = false,
|
||||
}) => {
|
||||
const [searchText,setSeachText] = useState("")
|
||||
const debounce = useDebounce(searchText,300);
|
||||
// const {} = use
|
||||
const [open, setOpen] = useState(false);
|
||||
const dropdownRef = useRef(null);
|
||||
|
||||
useEffect(() => {
|
||||
const handleClickOutside = (event) => {
|
||||
if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
|
||||
setOpen(false);
|
||||
}
|
||||
};
|
||||
document.addEventListener("mousedown", handleClickOutside);
|
||||
return () => document.removeEventListener("mousedown", handleClickOutside);
|
||||
}, []);
|
||||
|
||||
const selectedOption = options.find((opt) => opt[valueKey] === value);
|
||||
|
||||
const displayText = selectedOption ? selectedOption[labelKey] : placeholder;
|
||||
|
||||
const handleSelect = (option) => {
|
||||
onChange(option[valueKey]);
|
||||
setOpen(false);
|
||||
};
|
||||
|
||||
const toggleDropdown = () => setOpen((prev) => !prev);
|
||||
|
||||
return (
|
||||
<div className="mb-3 position-relative" ref={dropdownRef}>
|
||||
{label && (
|
||||
<Label className="form-label" required={required}>
|
||||
{label}
|
||||
</Label>
|
||||
)}
|
||||
|
||||
<button
|
||||
type="button"
|
||||
className={`select2-icons form-select d-flex align-items-center justify-content-between ${
|
||||
open ? "show" : ""
|
||||
}`}
|
||||
onClick={toggleDropdown}
|
||||
disabled={isLoading}
|
||||
>
|
||||
<span
|
||||
className={`text-truncate ${!selectedOption ? "text-muted" : ""}`}
|
||||
>
|
||||
{isLoading ? "Loading..." : displayText}
|
||||
</span>
|
||||
</button>
|
||||
|
||||
{open && !isLoading && (
|
||||
<ul
|
||||
className="dropdown-menu w-100 shadow-sm show animate__fadeIn"
|
||||
style={{
|
||||
position: "absolute",
|
||||
top: "100%",
|
||||
left: 0,
|
||||
zIndex: 1050,
|
||||
marginTop: "4px",
|
||||
borderRadius: "0.375rem",
|
||||
overflow: "hidden",
|
||||
}}
|
||||
>
|
||||
{options.map((option, i) => (
|
||||
<li key={i}>
|
||||
<button
|
||||
type="button"
|
||||
className={`dropdown-item ${
|
||||
option[valueKey] === value ? "active" : ""
|
||||
}`}
|
||||
onClick={() => handleSelect(option)}
|
||||
>
|
||||
{option[labelKey]}
|
||||
</button>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default SelectFieldServerSide;
|
||||
@ -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" }}>
|
||||
|
||||
67
src/components/common/OffcanvasComponent.jsx
Normal file
67
src/components/common/OffcanvasComponent.jsx
Normal file
@ -0,0 +1,67 @@
|
||||
import React, { useEffect, useRef } from "react";
|
||||
|
||||
const OffcanvasComponent = ({
|
||||
id = "globalOffcanvas",
|
||||
title = "Offcanvas Title",
|
||||
placement = "start", // start | end | top | bottom
|
||||
children,
|
||||
show = false,
|
||||
onClose = () => {},
|
||||
}) => {
|
||||
const offcanvasRef = useRef(null);
|
||||
const bsInstance = useRef(null);
|
||||
|
||||
useEffect(() => {
|
||||
if (!offcanvasRef.current) return;
|
||||
|
||||
// initialize once
|
||||
bsInstance.current = bootstrap.Offcanvas.getOrCreateInstance(offcanvasRef.current);
|
||||
|
||||
const el = offcanvasRef.current;
|
||||
const handleHide = () => onClose();
|
||||
|
||||
el.addEventListener("hidden.bs.offcanvas", handleHide);
|
||||
|
||||
return () => {
|
||||
el.removeEventListener("hidden.bs.offcanvas", handleHide);
|
||||
};
|
||||
}, [onClose]);
|
||||
|
||||
// react to `show` changes
|
||||
useEffect(() => {
|
||||
if (!bsInstance.current) return;
|
||||
|
||||
if (show) bsInstance.current.show();
|
||||
else bsInstance.current.hide();
|
||||
}, [show]);
|
||||
|
||||
return (
|
||||
<div >
|
||||
<div
|
||||
ref={offcanvasRef}
|
||||
id={id}
|
||||
className={`offcanvas offcanvas offcanvas-${placement} offcanvas-wide`}
|
||||
tabIndex="-1"
|
||||
aria-labelledby={`${id}-label`}
|
||||
>
|
||||
<div className="offcanvas-header">
|
||||
<div className='d-flex flex-row gap-3'>
|
||||
<i className='bx bx-lg bx-left-arrow-alt cursor-pointer' data-bs-dismiss="offcanvas"
|
||||
aria-label="Close"></i> <i className='bx bx-briefcase text-primary'></i> <h5 className="offcanvas-title" id={`${id}-label`}>{title}</h5>
|
||||
</div>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
className="btn-close"
|
||||
data-bs-dismiss="offcanvas"
|
||||
aria-label="Close"
|
||||
></button>
|
||||
</div>
|
||||
|
||||
<div className="offcanvas-body">{children}</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default OffcanvasComponent;
|
||||
@ -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) => (
|
||||
|
||||
@ -60,7 +60,7 @@ const GalleryFilterPanel = ({ onApply }) => {
|
||||
<form onSubmit={handleSubmit(onSubmit)}>
|
||||
<div className="mb-2">
|
||||
<Label>Select Date:</Label>
|
||||
<DateRangePicker1
|
||||
<DateRangePicker1 className="w-100"
|
||||
placeholder="DD-MM-YYYY To DD-MM-YYYY"
|
||||
startField="startDate"
|
||||
endField="endDate"
|
||||
|
||||
6
src/hooks/appHooks/useAppForm.js
Normal file
6
src/hooks/appHooks/useAppForm.js
Normal file
@ -0,0 +1,6 @@
|
||||
import { useForm, Controller,FormProvider } from "react-hook-form";
|
||||
|
||||
export const useAppForm = (config) => useForm(config);
|
||||
export const AppFormProvider = FormProvider;
|
||||
export const AppFormController = Controller;
|
||||
|
||||
@ -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,52 @@ 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 useServiceProjectJobDetails = (job)=>{
|
||||
return useQuery({
|
||||
queryKey:['service-job',job],
|
||||
queryFn:async() =>{
|
||||
const resp = await ServiceProjectRepository.GetJobDetails(job);
|
||||
return resp.data;
|
||||
},
|
||||
enabled:!!job
|
||||
})
|
||||
}
|
||||
|
||||
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}`,),
|
||||
};
|
||||
23
src/repositories/ServiceProjectRepository.jsx
Normal file
23
src/repositories/ServiceProjectRepository.jsx
Normal file
@ -0,0 +1,23 @@
|
||||
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}`
|
||||
),
|
||||
GetJobDetails:(id)=>api.get(`/api/ServiceProject/job/details/${id}`)
|
||||
};
|
||||
@ -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