Merge pull request 'HotChanges_09_10_25 : Added Daily Task Filter' (#467) from HotChanges_09_10_25 into main
Reviewed-on: #467 Merged
This commit is contained in:
commit
1200937097
@ -1,5 +1,5 @@
|
|||||||
import React, { useState } from "react";
|
import React, { useState } from "react";
|
||||||
import { useCurrentService, useProjectInfra } from "../../hooks/useProjects";
|
import { useCurrentService } from "../../hooks/useProjects";
|
||||||
import { useSelectedProject } from "../../slices/apiDataManager";
|
import { useSelectedProject } from "../../slices/apiDataManager";
|
||||||
import { FormProvider, useForm } from "react-hook-form";
|
import { FormProvider, useForm } from "react-hook-form";
|
||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
import { zodResolver } from "@hookform/resolvers/zod";
|
||||||
@ -10,15 +10,14 @@ import {
|
|||||||
import { DateRangePicker1 } from "../common/DateRangePicker";
|
import { DateRangePicker1 } from "../common/DateRangePicker";
|
||||||
import SelectMultiple from "../common/SelectMultiple";
|
import SelectMultiple from "../common/SelectMultiple";
|
||||||
import { localToUtc } from "../../utils/appUtils";
|
import { localToUtc } from "../../utils/appUtils";
|
||||||
|
import { useTaskFilter } from "../../hooks/useTasks";
|
||||||
|
|
||||||
const TaskReportFilterPanel = ({ handleFilter }) => {
|
const TaskReportFilterPanel = ({ handleFilter }) => {
|
||||||
const [resetKey, setResetKey] = useState(0);
|
const [resetKey, setResetKey] = useState(0);
|
||||||
const selectedProjec = useSelectedProject();
|
const selectedProject = useSelectedProject();
|
||||||
const selectedService = useCurrentService();
|
const selectedService = useCurrentService();
|
||||||
const { projectInfra, isLoading, error, isFetched } = useProjectInfra(
|
const { data } = useTaskFilter(selectedProject);
|
||||||
selectedProjec,
|
|
||||||
selectedService
|
|
||||||
);
|
|
||||||
const methods = useForm({
|
const methods = useForm({
|
||||||
resolver: zodResolver(TaskReportFilterSchema),
|
resolver: zodResolver(TaskReportFilterSchema),
|
||||||
defaultValues: TaskReportDefaultValue,
|
defaultValues: TaskReportDefaultValue,
|
||||||
@ -32,21 +31,19 @@ const TaskReportFilterPanel = ({ handleFilter }) => {
|
|||||||
} = methods;
|
} = methods;
|
||||||
|
|
||||||
const onSubmit = (formData) => {
|
const onSubmit = (formData) => {
|
||||||
console.log(formData)
|
const filterPayload = {
|
||||||
const filterPayload = {
|
...formData,
|
||||||
startDate:localToUtc(formData.startDate),
|
dateFrom: localToUtc(formData.dateFrom),
|
||||||
endDate:localToUtc(formData.endDate)
|
dateTo: localToUtc(formData.dateTo),
|
||||||
|
};
|
||||||
}
|
|
||||||
handleFilter(filterPayload);
|
handleFilter(filterPayload);
|
||||||
};
|
};
|
||||||
|
|
||||||
const onClear =()=>{
|
const onClear = () => {
|
||||||
setResetKey((prev) => prev + 1);
|
setResetKey((prev) => prev + 1);
|
||||||
handleFilter(TaskReportDefaultValue)
|
handleFilter(TaskReportDefaultValue);
|
||||||
reset(TaskReportDefaultValue)
|
reset(TaskReportDefaultValue);
|
||||||
}
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<FormProvider {...methods}>
|
<FormProvider {...methods}>
|
||||||
<form onSubmit={handleSubmit(onSubmit)} className="p-2 text-start">
|
<form onSubmit={handleSubmit(onSubmit)} className="p-2 text-start">
|
||||||
@ -54,34 +51,47 @@ const TaskReportFilterPanel = ({ handleFilter }) => {
|
|||||||
<label className="fw-semibold">Choose Date Range:</label>
|
<label className="fw-semibold">Choose Date Range:</label>
|
||||||
<DateRangePicker1
|
<DateRangePicker1
|
||||||
placeholder="DD-MM-YYYY To DD-MM-YYYY"
|
placeholder="DD-MM-YYYY To DD-MM-YYYY"
|
||||||
startField="startDate"
|
startField="dateFrom"
|
||||||
endField="endDate"
|
endField="dateTo"
|
||||||
resetSignal={resetKey}
|
resetSignal={resetKey}
|
||||||
defaultRange={true}
|
defaultRange={false}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* <div className="row g-2">
|
<div className="row g-2">
|
||||||
<SelectMultiple
|
<SelectMultiple
|
||||||
name="buildingIds"
|
name="buildingIds"
|
||||||
label="Projects"
|
label="Building"
|
||||||
options={projectInfra}
|
options={data?.buildings}
|
||||||
labelKey="buildingName"
|
labelKey="name"
|
||||||
valueKey="id"
|
valueKey="id"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="row g-2">
|
<div className="row g-2">
|
||||||
<SelectMultiple
|
<SelectMultiple
|
||||||
name="floorIds"
|
name="floorIds"
|
||||||
label="Floor"
|
label="Floor"
|
||||||
options={projectInfra}
|
options={data?.floors}
|
||||||
labelKey="floorName"
|
labelKey="name"
|
||||||
valueKey="id"
|
valueKey="id"
|
||||||
/>
|
/>
|
||||||
</div> */}
|
</div>
|
||||||
|
<div className="row g-2">
|
||||||
|
<SelectMultiple
|
||||||
|
name="activityIds"
|
||||||
|
label="Activities"
|
||||||
|
options={data?.activities}
|
||||||
|
labelKey="name"
|
||||||
|
valueKey="id"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div className="d-flex justify-content-end py-3 gap-2">
|
<div className="d-flex justify-content-end py-3 gap-2">
|
||||||
<button type="button" className="btn btn-label-secondary btn-sm" onClick={onClear}>
|
<button
|
||||||
|
type="button"
|
||||||
|
className="btn btn-label-secondary btn-sm"
|
||||||
|
onClick={onClear}
|
||||||
|
>
|
||||||
Clear
|
Clear
|
||||||
</button>
|
</button>
|
||||||
<button type="submit" className="btn btn-primary btn-sm">
|
<button type="submit" className="btn btn-primary btn-sm">
|
||||||
|
@ -1,15 +1,17 @@
|
|||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
|
|
||||||
export const TaskReportFilterSchema = z.object({
|
export const TaskReportFilterSchema = z.object({
|
||||||
// buildingIds: z.array(z.string()).optional(),
|
buildingIds: z.array(z.string()).optional(),
|
||||||
// floorIds: z.array(z.string()).optional(),
|
floorIds: z.array(z.string()).optional(),
|
||||||
startDate: z.string().optional(),
|
activityIds: z.array(z.string()).optional(),
|
||||||
endDate: z.string().optional(),
|
dateFrom: z.string().optional(),
|
||||||
|
dateTo: z.string().optional(),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const TaskReportDefaultValue = {
|
export const TaskReportDefaultValue = {
|
||||||
// buildingIds:[],
|
buildingIds:[],
|
||||||
// floorIds:[],
|
floorIds:[],
|
||||||
startDate:null,
|
activityIds:[],
|
||||||
endDate:null
|
dateFrom:null,
|
||||||
|
dateTo:null
|
||||||
}
|
}
|
@ -37,7 +37,6 @@ const ServiceGroups = ({ service }) => {
|
|||||||
|
|
||||||
<div className="w-100 my-2">
|
<div className="w-100 my-2">
|
||||||
|
|
||||||
<p className="fs-5 fw-semibold">Manage Service</p>
|
|
||||||
<div className="accordion" id="accordionExample">
|
<div className="accordion" id="accordionExample">
|
||||||
<div className="accordion-item active shadow-none">
|
<div className="accordion-item active shadow-none">
|
||||||
{/* Service Header */}
|
{/* Service Header */}
|
||||||
|
@ -207,7 +207,6 @@ export const useMarkAttendance = () => {
|
|||||||
onSuccess: (data, variables) => {
|
onSuccess: (data, variables) => {
|
||||||
if (variables.forWhichTab == 1) {
|
if (variables.forWhichTab == 1) {
|
||||||
queryClient.setQueryData(["attendance", selectedProject,selectedOrganization], (oldData) => {
|
queryClient.setQueryData(["attendance", selectedProject,selectedOrganization], (oldData) => {
|
||||||
debugger
|
|
||||||
if (!oldData) return oldData;
|
if (!oldData) return oldData;
|
||||||
return oldData.map((emp) =>
|
return oldData.map((emp) =>
|
||||||
emp.employeeId === data.employeeId ? { ...emp, ...data } : emp
|
emp.employeeId === data.employeeId ? { ...emp, ...data } : emp
|
||||||
|
@ -8,11 +8,30 @@ import { useSelector } from "react-redux";
|
|||||||
|
|
||||||
// ---------Query---------------------------------
|
// ---------Query---------------------------------
|
||||||
|
|
||||||
export const useTaskList = (projectId, pageSize, pageNumber, serviceId, filter) => {
|
|
||||||
|
|
||||||
|
|
||||||
|
const cleanFilter = (filter) => {
|
||||||
|
const cleaned = { ...filter };
|
||||||
|
|
||||||
|
["buildingIds", "floorIds", "activityIds"].forEach((key) => {
|
||||||
|
if (Array.isArray(cleaned[key]) && cleaned[key].length === 0) {
|
||||||
|
delete cleaned[key];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return cleaned;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const useTaskList = (
|
||||||
|
projectId,
|
||||||
|
pageSize,
|
||||||
|
pageNumber,
|
||||||
|
serviceId,
|
||||||
|
filter
|
||||||
|
) => {
|
||||||
return useQuery({
|
return useQuery({
|
||||||
queryKey: ["taskList", projectId, pageSize, pageNumber, serviceId, filter],
|
queryKey: ["taskList", projectId, pageSize, pageNumber, serviceId, filter],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
|
const cleanedFilter = cleanFilter(filter)
|
||||||
const response = await TasksRepository.getTaskList(
|
const response = await TasksRepository.getTaskList(
|
||||||
projectId,
|
projectId,
|
||||||
pageSize,
|
pageSize,
|
||||||
@ -22,10 +41,20 @@ export const useTaskList = (projectId, pageSize, pageNumber, serviceId, filter)
|
|||||||
);
|
);
|
||||||
return response.data;
|
return response.data;
|
||||||
},
|
},
|
||||||
enabled:!!projectId
|
enabled: !!projectId,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const useTaskFilter = (projectId) => {
|
||||||
|
return useQuery({
|
||||||
|
queryKey: ["taskFilter", projectId],
|
||||||
|
queryFn: async () => {
|
||||||
|
const resp = await TasksRepository.getTaskListFilter(projectId);
|
||||||
|
return resp.data;
|
||||||
|
},
|
||||||
|
enabled:!!projectId
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
export const useTaskById = (TaskId) => {
|
export const useTaskById = (TaskId) => {
|
||||||
const {
|
const {
|
||||||
|
@ -86,7 +86,7 @@ const DailyProgrssReport = () => {
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<div className="card card-fullscreen p-5">
|
<div className="card card-fullscreen p-5">
|
||||||
<div className="col-sm-4 col-md-3 col-12">
|
{data?.data?.length > 0 && (<div className="col-sm-4 col-md-3 col-12">
|
||||||
<select
|
<select
|
||||||
className="form-select form-select-sm"
|
className="form-select form-select-sm"
|
||||||
value={service ?? ""}
|
value={service ?? ""}
|
||||||
@ -107,7 +107,7 @@ const DailyProgrssReport = () => {
|
|||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>)}
|
||||||
<div>
|
<div>
|
||||||
<TaskReportList />
|
<TaskReportList />
|
||||||
</div>
|
</div>
|
||||||
|
@ -60,12 +60,12 @@ const ContactFilterPanel = ({ onApply, clearFilter }) => {
|
|||||||
<div className="d-flex justify-content-end py-3 gap-2">
|
<div className="d-flex justify-content-end py-3 gap-2">
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
className="btn btn-label-secondary btn-xs"
|
className="btn btn-label-secondary btn-sm"
|
||||||
onClick={handleClose}
|
onClick={handleClose}
|
||||||
>
|
>
|
||||||
Clear
|
Clear
|
||||||
</button>
|
</button>
|
||||||
<button type="submit" className="btn btn-primary btn-xs">
|
<button type="submit" className="btn btn-primary btn-sm">
|
||||||
Apply
|
Apply
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
@ -60,12 +60,12 @@ const NoteFilterPanel = ({ onApply, clearFilter }) => {
|
|||||||
<div className="d-flex justify-content-end py-3 gap-2">
|
<div className="d-flex justify-content-end py-3 gap-2">
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
className="btn btn-label-secondary btn-xs"
|
className="btn btn-label-secondary btn-sm"
|
||||||
onClick={handleClose}
|
onClick={handleClose}
|
||||||
>
|
>
|
||||||
Clear
|
Clear
|
||||||
</button>
|
</button>
|
||||||
<button type="submit" className="btn btn-primary btn-xs">
|
<button type="submit" className="btn btn-primary btn-sm">
|
||||||
Apply
|
Apply
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
@ -77,7 +77,7 @@ const ImageGalleryPage = () => {
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<div className="card page-min-h p-2">
|
<div className="card page-min-h p-2">
|
||||||
{selectedProjectId && (
|
{/* {selectedProjectId && (
|
||||||
<div className="d-flex flex-row w-20 pb-2">
|
<div className="d-flex flex-row w-20 pb-2">
|
||||||
{!isLoading && assignedServices?.length === 0 ? (
|
{!isLoading && assignedServices?.length === 0 ? (
|
||||||
<span className="badge bg-label-secondary">
|
<span className="badge bg-label-secondary">
|
||||||
@ -102,7 +102,7 @@ const ImageGalleryPage = () => {
|
|||||||
</select>
|
</select>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)} */}
|
||||||
|
|
||||||
<ImageGalleryListView filter={filter}/>
|
<ImageGalleryListView filter={filter}/>
|
||||||
</div>
|
</div>
|
||||||
|
@ -16,6 +16,8 @@ export const TasksRepository = {
|
|||||||
return api.get(url);
|
return api.get(url);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getTaskListFilter:(projectId)=>api.get(`/api/task/filter/${projectId}`),
|
||||||
|
|
||||||
getTaskById: (id) => api.get(`/api/task/get/${id}`),
|
getTaskById: (id) => api.get(`/api/task/get/${id}`),
|
||||||
reportTask: (data) => api.post("api/task/report", data),
|
reportTask: (data) => api.post("api/task/report", data),
|
||||||
taskComments: (data) => api.post("api/task/comment", data),
|
taskComments: (data) => api.post("api/task/comment", data),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user