Compare commits
3 Commits
83143dff0a
...
0746e5c349
Author | SHA1 | Date | |
---|---|---|---|
0746e5c349 | |||
00d6774e06 | |||
54e609883d |
@ -6,9 +6,10 @@ import {
|
|||||||
useActivitiesMaster,
|
useActivitiesMaster,
|
||||||
useWorkCategoriesMaster,
|
useWorkCategoriesMaster,
|
||||||
} from "../../../hooks/masterHook/useMaster";
|
} from "../../../hooks/masterHook/useMaster";
|
||||||
import { useManageTask } from "../../../hooks/useProjects";
|
import { useManageTask, useProjectAssignedServices } from "../../../hooks/useProjects";
|
||||||
import showToast from "../../../services/toastService";
|
import showToast from "../../../services/toastService";
|
||||||
import Label from "../../common/Label";
|
import Label from "../../common/Label";
|
||||||
|
import { useSelectedProject } from "../../../slices/apiDataManager";
|
||||||
|
|
||||||
const taskSchema = z.object({
|
const taskSchema = z.object({
|
||||||
buildingID: z.string().min(1, "Building is required"),
|
buildingID: z.string().min(1, "Building is required"),
|
||||||
@ -37,6 +38,15 @@ const TaskModel = ({ project, onSubmit, onClose }) => {
|
|||||||
const { activities, loading: activityLoading } = useActivitiesMaster();
|
const { activities, loading: activityLoading } = useActivitiesMaster();
|
||||||
const { categories, categoryLoading } = useWorkCategoriesMaster();
|
const { categories, categoryLoading } = useWorkCategoriesMaster();
|
||||||
|
|
||||||
|
const projectId = useSelectedProject();
|
||||||
|
|
||||||
|
const { data: assignedServices, isLoading: servicesLoading } = useProjectAssignedServices(projectId);
|
||||||
|
|
||||||
|
const [selectedService, setSelectedService] = useState("");
|
||||||
|
|
||||||
|
const handleServiceChange = (e) => {
|
||||||
|
setSelectedService(e.target.value);
|
||||||
|
};
|
||||||
const {
|
const {
|
||||||
register,
|
register,
|
||||||
handleSubmit,
|
handleSubmit,
|
||||||
@ -97,9 +107,11 @@ const TaskModel = ({ project, onSubmit, onClose }) => {
|
|||||||
|
|
||||||
const onSubmitForm = async (data) => {
|
const onSubmitForm = async (data) => {
|
||||||
const payload = [data];
|
const payload = [data];
|
||||||
CreateTask({payload:payload,buildingId: data.buildingID,
|
CreateTask({
|
||||||
|
payload: payload, buildingId: data.buildingID,
|
||||||
floorId: data.floorId,
|
floorId: data.floorId,
|
||||||
workAreaId: data.workAreaId, PreviousPlannedWork:0,previousCompletedWork:0});
|
workAreaId: data.workAreaId, PreviousPlannedWork: 0, previousCompletedWork: 0
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -150,6 +162,7 @@ const TaskModel = ({ project, onSubmit, onClose }) => {
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{/* Work Area Selection */}
|
||||||
{selectedFloor && (
|
{selectedFloor && (
|
||||||
<div className="col-12 text-start">
|
<div className="col-12 text-start">
|
||||||
<Label className="form-label" required>Select Work Area</Label>
|
<Label className="form-label" required>Select Work Area</Label>
|
||||||
@ -172,6 +185,32 @@ const TaskModel = ({ project, onSubmit, onClose }) => {
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{/* Services Selection */}
|
||||||
|
{selectedWorkArea && (
|
||||||
|
<div className="col-12 text-start">
|
||||||
|
<Label className="form-label">Select Services</Label>
|
||||||
|
<select
|
||||||
|
name="DataTables_Table_0_length"
|
||||||
|
aria-controls="DataTables_Table_0"
|
||||||
|
className="form-select form-select-sm"
|
||||||
|
aria-label="Select Service"
|
||||||
|
value={selectedService}
|
||||||
|
onChange={handleServiceChange}
|
||||||
|
>
|
||||||
|
{servicesLoading && <option>Loading...</option>}
|
||||||
|
{assignedServices?.map((service) => (
|
||||||
|
<option key={service.id} value={service.id}>
|
||||||
|
{service.name}
|
||||||
|
</option>
|
||||||
|
))}
|
||||||
|
</select>
|
||||||
|
{errors.buildingID && (
|
||||||
|
<p className="danger-text">{errors.buildingID.message}</p>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{/* Activity Selection */}
|
||||||
{selectedWorkArea && (
|
{selectedWorkArea && (
|
||||||
<div className="col-12 text-start">
|
<div className="col-12 text-start">
|
||||||
<Label className="form-label" required>Select Activity</Label>
|
<Label className="form-label" required>Select Activity</Label>
|
||||||
@ -192,6 +231,7 @@ const TaskModel = ({ project, onSubmit, onClose }) => {
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
|
||||||
{selectedWorkArea && (
|
{selectedWorkArea && (
|
||||||
<div className="col-12 text-start">
|
<div className="col-12 text-start">
|
||||||
<label className="form-label">Select Work Category</label>
|
<label className="form-label">Select Work Category</label>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user