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