sorted all dropdown list
This commit is contained in:
parent
6daf3f8a35
commit
6496fd7eb2
@ -2,7 +2,7 @@ import React, { useState, useEffect } from "react";
|
|||||||
import { useForm } from "react-hook-form";
|
import { useForm } from "react-hook-form";
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
import { zodResolver } from "@hookform/resolvers/zod";
|
||||||
import {getCachedData} from "../../../slices/apiDataManager";
|
import { getCachedData } from "../../../slices/apiDataManager";
|
||||||
import showToast from "../../../services/toastService";
|
import showToast from "../../../services/toastService";
|
||||||
|
|
||||||
// Zod validation schema
|
// Zod validation schema
|
||||||
@ -25,13 +25,11 @@ const FloorModel = ({
|
|||||||
onSubmit,
|
onSubmit,
|
||||||
clearTrigger,
|
clearTrigger,
|
||||||
onClearComplete,
|
onClearComplete,
|
||||||
} ) =>
|
}) => {
|
||||||
{
|
|
||||||
|
|
||||||
const [formData, setFormData] = useState(defaultModel);
|
const [formData, setFormData] = useState(defaultModel);
|
||||||
const [ selectedBuilding, setSelectedBuilding ] = useState( {} );
|
const [selectedBuilding, setSelectedBuilding] = useState({});
|
||||||
const [buildings, setBuildings] = useState(project?.buildings || []);
|
const [buildings, setBuildings] = useState(project?.buildings || []);
|
||||||
|
|
||||||
// Initialize the form with React Hook Form
|
// Initialize the form with React Hook Form
|
||||||
const {
|
const {
|
||||||
register,
|
register,
|
||||||
@ -45,14 +43,12 @@ const FloorModel = ({
|
|||||||
defaultValues: defaultModel,
|
defaultValues: defaultModel,
|
||||||
});
|
});
|
||||||
|
|
||||||
useEffect( () =>
|
useEffect(() => {
|
||||||
{
|
|
||||||
|
|
||||||
if (clearTrigger) {
|
if (clearTrigger) {
|
||||||
reset(defaultModel);
|
reset(defaultModel);
|
||||||
onClearComplete();
|
onClearComplete();
|
||||||
}
|
}
|
||||||
}, [clearTrigger, onClearComplete, reset,]);
|
}, [clearTrigger, onClearComplete, reset]);
|
||||||
|
|
||||||
// Handle building selection change
|
// Handle building selection change
|
||||||
const handleBuildigChange = (e) => {
|
const handleBuildigChange = (e) => {
|
||||||
@ -64,7 +60,6 @@ const FloorModel = ({
|
|||||||
id: "",
|
id: "",
|
||||||
floorName: "",
|
floorName: "",
|
||||||
buildingId: building.id,
|
buildingId: building.id,
|
||||||
|
|
||||||
});
|
});
|
||||||
setValue("buildingId", building.id); // Set value for validation
|
setValue("buildingId", building.id); // Set value for validation
|
||||||
setValue("id", "0"); // Reset floorId when changing building
|
setValue("id", "0"); // Reset floorId when changing building
|
||||||
@ -74,13 +69,10 @@ const FloorModel = ({
|
|||||||
id: "",
|
id: "",
|
||||||
floorName: "",
|
floorName: "",
|
||||||
buildingId: "0",
|
buildingId: "0",
|
||||||
|
|
||||||
});
|
});
|
||||||
setValue("buildingId", "0");
|
setValue("buildingId", "0");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Handle floor selection change
|
// Handle floor selection change
|
||||||
const handleFloorChange = (e) => {
|
const handleFloorChange = (e) => {
|
||||||
@ -91,15 +83,13 @@ const FloorModel = ({
|
|||||||
id: floor.id,
|
id: floor.id,
|
||||||
floorName: floor.floorName,
|
floorName: floor.floorName,
|
||||||
buildingId: selectedBuilding.id,
|
buildingId: selectedBuilding.id,
|
||||||
|
|
||||||
});
|
});
|
||||||
setValue("floorName", floor.floorName);
|
setValue("floorName", floor.floorName);
|
||||||
} else {
|
} else {
|
||||||
setFormData({
|
setFormData({
|
||||||
id: "0",
|
id: "0",
|
||||||
floorName: "",
|
floorName: "",
|
||||||
buildingId: selectedBuilding.id,
|
buildingId: selectedBuilding.id,
|
||||||
|
|
||||||
});
|
});
|
||||||
setValue("floorName", "");
|
setValue("floorName", "");
|
||||||
}
|
}
|
||||||
@ -107,36 +97,32 @@ const FloorModel = ({
|
|||||||
|
|
||||||
// Handle form submission
|
// Handle form submission
|
||||||
const onFormSubmit = (data) => {
|
const onFormSubmit = (data) => {
|
||||||
onSubmit( data );
|
onSubmit(data);
|
||||||
reset(
|
reset({
|
||||||
{
|
floorName: "",
|
||||||
floorName: ""
|
});
|
||||||
} )
|
if (data.id !== "0") {
|
||||||
if ( data.id !== "0" )
|
showToast("Floor updated successfully.", "success");
|
||||||
{
|
} else {
|
||||||
showToast( "Floor updated successfully.", "success" );
|
showToast("Floor created successfully.", "success");
|
||||||
} else
|
}
|
||||||
{
|
|
||||||
showToast( "Floor created successfully.", "success" );
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="modal-dialog modal-lg modal-simple modal-edit-user">
|
<div className="modal-dialog modal-lg modal-simple modal-edit-user">
|
||||||
<div className="modal-content">
|
<div className="modal-content">
|
||||||
<div className="modal-body">
|
<div className="modal-body">
|
||||||
<div className="row">
|
<div className="row">
|
||||||
<button type="button" className="btn-close" aria-label="Close" onClick={onClose}/>
|
<button
|
||||||
|
type="button"
|
||||||
|
className="btn-close"
|
||||||
|
aria-label="Close"
|
||||||
|
onClick={onClose}
|
||||||
|
/>
|
||||||
<div className="text-center mb-1">
|
<div className="text-center mb-1">
|
||||||
<h5 className="mb-1">Manage Floors - {project.name}</h5>
|
<h5 className="mb-1">Manage Floors - {project.name}</h5>
|
||||||
</div>
|
</div>
|
||||||
<form
|
<form className="row g-2" onSubmit={handleSubmit(onFormSubmit)}>
|
||||||
className="row g-2"
|
|
||||||
onSubmit={handleSubmit(onFormSubmit)}
|
|
||||||
>
|
|
||||||
<div className="col-12 col-md-12">
|
<div className="col-12 col-md-12">
|
||||||
<label className="form-label" htmlFor="buildingId">
|
<label className="form-label" htmlFor="buildingId">
|
||||||
Select Building
|
Select Building
|
||||||
@ -150,12 +136,15 @@ const FloorModel = ({
|
|||||||
>
|
>
|
||||||
<option value="0">Select Building</option>
|
<option value="0">Select Building</option>
|
||||||
{buildings &&
|
{buildings &&
|
||||||
buildings?.length > 0 &&
|
buildings?.length > 0 &&
|
||||||
buildings.map((building) => (
|
buildings
|
||||||
<option key={building.id} value={building.id}>
|
?.slice()
|
||||||
{building.name}
|
?.sort((a, b) => a.name.localeCompare(b.name))
|
||||||
</option>
|
?.map((building) => (
|
||||||
))}
|
<option key={building.id} value={building.id}>
|
||||||
|
{building.name}
|
||||||
|
</option>
|
||||||
|
))}
|
||||||
</select>
|
</select>
|
||||||
{errors.buildingId && (
|
{errors.buildingId && (
|
||||||
<p className="text-danger">{errors.buildingId.message}</p>
|
<p className="text-danger">{errors.buildingId.message}</p>
|
||||||
@ -164,9 +153,7 @@ const FloorModel = ({
|
|||||||
|
|
||||||
{formData.buildingId !== "0" && (
|
{formData.buildingId !== "0" && (
|
||||||
<div className="col-12 col-md-12">
|
<div className="col-12 col-md-12">
|
||||||
<label className="form-label" >
|
<label className="form-label">Select Floor</label>
|
||||||
Select Floor
|
|
||||||
</label>
|
|
||||||
<select
|
<select
|
||||||
id="id"
|
id="id"
|
||||||
className="select2 form-select form-select-sm"
|
className="select2 form-select form-select-sm"
|
||||||
@ -180,14 +167,16 @@ const FloorModel = ({
|
|||||||
{floor.floorName}
|
{floor.floorName}
|
||||||
</option>
|
</option>
|
||||||
) )} */}
|
) )} */}
|
||||||
|
|
||||||
{selectedBuilding &&
|
{selectedBuilding &&
|
||||||
selectedBuilding?.floors.length > 0 &&
|
selectedBuilding.floors.length > 0 &&
|
||||||
selectedBuilding?.floors.map((floor) => (
|
[...selectedBuilding.floors]
|
||||||
<option key={floor.id} value={floor.id}>
|
?.sort((a, b) => a.floorName.localeCompare(b.floorName))
|
||||||
{floor.floorName}
|
?.map((floor) => (
|
||||||
</option>
|
<option key={floor.id} value={floor.id}>
|
||||||
))}
|
{floor.floorName}
|
||||||
|
</option>
|
||||||
|
))}
|
||||||
</select>
|
</select>
|
||||||
{errors.id && (
|
{errors.id && (
|
||||||
<p className="text-danger">{errors.id.message}</p>
|
<p className="text-danger">{errors.id.message}</p>
|
||||||
|
@ -162,11 +162,14 @@ const TaskModel = ({
|
|||||||
onChange={handleBuildingChange}
|
onChange={handleBuildingChange}
|
||||||
>
|
>
|
||||||
<option value="0">Select Building</option>
|
<option value="0">Select Building</option>
|
||||||
{project.buildings.map((building) => (
|
{project.buildings
|
||||||
<option key={building.id} value={building.id}>
|
?.slice()
|
||||||
{building.name}
|
?.sort((a, b) => a.name.localeCompare(b.name))
|
||||||
</option>
|
?.map((building) => (
|
||||||
))}
|
<option key={building.id} value={building.id}>
|
||||||
|
{building.name}
|
||||||
|
</option>
|
||||||
|
))}
|
||||||
</select>
|
</select>
|
||||||
{errors.buildingID && (
|
{errors.buildingID && (
|
||||||
<p className="danger-text">{errors.buildingID.message}</p>
|
<p className="danger-text">{errors.buildingID.message}</p>
|
||||||
@ -186,12 +189,15 @@ const TaskModel = ({
|
|||||||
onChange={handleFloorChange}
|
onChange={handleFloorChange}
|
||||||
>
|
>
|
||||||
<option value="0">Select Floor</option>
|
<option value="0">Select Floor</option>
|
||||||
{selectedBuilding.floors.map((floor) => (
|
{selectedBuilding.floors
|
||||||
<option key={floor.id} value={floor.id}>
|
?.slice()
|
||||||
{floor.floorName} - ({floor.workAreas.length} Work
|
?.sort((a, b) => a.floorName.localeCompare(b.floorName))
|
||||||
Areas)
|
?.map((floor) => (
|
||||||
</option>
|
<option key={floor.id} value={floor.id}>
|
||||||
))}
|
{floor.floorName} - ({floor.workAreas.length} Work
|
||||||
|
Areas)
|
||||||
|
</option>
|
||||||
|
))}
|
||||||
</select>
|
</select>
|
||||||
{errors.floorId && (
|
{errors.floorId && (
|
||||||
<p className="danger-text">{errors.floorId.message}</p>
|
<p className="danger-text">{errors.floorId.message}</p>
|
||||||
@ -212,11 +218,14 @@ const TaskModel = ({
|
|||||||
onChange={handleWorkAreaChange}
|
onChange={handleWorkAreaChange}
|
||||||
>
|
>
|
||||||
<option value="0">Select Work Area</option>
|
<option value="0">Select Work Area</option>
|
||||||
{selectedFloor.workAreas.map((workArea) => (
|
{selectedFloor.workAreas
|
||||||
<option key={workArea.id} value={workArea.id}>
|
?.slice()
|
||||||
{workArea.areaName}
|
?.sort((a, b) => a.areaName.localeCompare(b.areaName))
|
||||||
</option>
|
?.map((workArea) => (
|
||||||
))}
|
<option key={workArea.id} value={workArea.id}>
|
||||||
|
{workArea.areaName}
|
||||||
|
</option>
|
||||||
|
))}
|
||||||
</select>
|
</select>
|
||||||
{errors.workAreaId && (
|
{errors.workAreaId && (
|
||||||
<p className="danger-text">{errors.workAreaId.message}</p>
|
<p className="danger-text">{errors.workAreaId.message}</p>
|
||||||
@ -237,10 +246,11 @@ const TaskModel = ({
|
|||||||
onChange={handleActivityChange}
|
onChange={handleActivityChange}
|
||||||
>
|
>
|
||||||
<option value="0">Select Activity</option>
|
<option value="0">Select Activity</option>
|
||||||
{activities?.slice()
|
{activities
|
||||||
.sort((a, b) =>
|
?.slice()
|
||||||
|
?.sort((a, b) =>
|
||||||
a.activityName.localeCompare(b.activityName)
|
a.activityName.localeCompare(b.activityName)
|
||||||
)
|
)
|
||||||
?.map((activity) => (
|
?.map((activity) => (
|
||||||
<option key={activity.id} value={activity.id}>
|
<option key={activity.id} value={activity.id}>
|
||||||
{activity.activityName}
|
{activity.activityName}
|
||||||
|
@ -5,12 +5,15 @@ import { z } from "zod";
|
|||||||
import showToast from "../../../services/toastService";
|
import showToast from "../../../services/toastService";
|
||||||
|
|
||||||
// Zod schema for form validation
|
// Zod schema for form validation
|
||||||
const workAreaSchema = z.object( {
|
const workAreaSchema = z.object({
|
||||||
id:z.string().nonempty("Floor is required"),
|
id: z.string().nonempty("Floor is required"),
|
||||||
|
|
||||||
buildingId: z.string().nonempty("Building is required"),
|
buildingId: z.string().nonempty("Building is required"),
|
||||||
floorId: z.string().nonempty("Floor is required"),
|
floorId: z.string().nonempty("Floor is required"),
|
||||||
areaName: z.string().nonempty( "Work Area Name is required" ).min( 3, "Name must be at least 3 characters long" ),
|
areaName: z
|
||||||
|
.string()
|
||||||
|
.nonempty("Work Area Name is required")
|
||||||
|
.min(3, "Name must be at least 3 characters long"),
|
||||||
});
|
});
|
||||||
|
|
||||||
// Default form data
|
// Default form data
|
||||||
@ -20,17 +23,30 @@ const defaultModel = {
|
|||||||
floorId: "0",
|
floorId: "0",
|
||||||
};
|
};
|
||||||
|
|
||||||
const WorkAreaModel = ({ project, onSubmit, clearTrigger, onClearComplete, onClose }) => {
|
const WorkAreaModel = ({
|
||||||
|
project,
|
||||||
|
onSubmit,
|
||||||
|
clearTrigger,
|
||||||
|
onClearComplete,
|
||||||
|
onClose,
|
||||||
|
}) => {
|
||||||
const [selectedBuilding, setSelectedBuilding] = useState(null);
|
const [selectedBuilding, setSelectedBuilding] = useState(null);
|
||||||
const [ selectedFloor, setSelectedFloor ] = useState( null );
|
const [selectedFloor, setSelectedFloor] = useState(null);
|
||||||
const [selectdWorkArea,setWorkArea] = useState()
|
const [selectdWorkArea, setWorkArea] = useState();
|
||||||
|
|
||||||
const { register, handleSubmit, formState: { errors }, setValue, reset, watch } = useForm({
|
const {
|
||||||
|
register,
|
||||||
|
handleSubmit,
|
||||||
|
formState: { errors },
|
||||||
|
setValue,
|
||||||
|
reset,
|
||||||
|
watch,
|
||||||
|
} = useForm({
|
||||||
resolver: zodResolver(workAreaSchema), // Use Zod resolver for validation
|
resolver: zodResolver(workAreaSchema), // Use Zod resolver for validation
|
||||||
defaultValues: defaultModel,
|
defaultValues: defaultModel,
|
||||||
});
|
});
|
||||||
|
|
||||||
const floorId = watch( "floorId" ); // Watch the floorId for conditional rendering
|
const floorId = watch("floorId"); // Watch the floorId for conditional rendering
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (clearTrigger) {
|
if (clearTrigger) {
|
||||||
@ -41,25 +57,22 @@ const WorkAreaModel = ({ project, onSubmit, clearTrigger, onClearComplete, onClo
|
|||||||
}
|
}
|
||||||
}, [clearTrigger, onClearComplete, reset]);
|
}, [clearTrigger, onClearComplete, reset]);
|
||||||
|
|
||||||
const handleWorkAreaChange = ( e ) =>
|
const handleWorkAreaChange = (e) => {
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
const { value } = e.target;
|
const { value } = e.target;
|
||||||
|
|
||||||
if (value === "0") {
|
if (value === "0") {
|
||||||
setValue("id", "0"); // Create New Work Area
|
setValue("id", "0"); // Create New Work Area
|
||||||
setValue( "areaName", "" );
|
setValue("areaName", "");
|
||||||
|
|
||||||
setWorkArea(String(0))
|
|
||||||
} else {
|
|
||||||
const workArea = selectedFloor?.workAreas.find((b) => b.id === Number(value));
|
|
||||||
if ( workArea )
|
|
||||||
{
|
|
||||||
setValue("id", String(workArea.id)); // Set id as a string
|
|
||||||
setValue("areaName", workArea.areaName);
|
|
||||||
setWorkArea(String(workArea.id))
|
|
||||||
|
|
||||||
|
setWorkArea(String(0));
|
||||||
|
} else {
|
||||||
|
const workArea = selectedFloor?.workAreas.find(
|
||||||
|
(b) => b.id === Number(value)
|
||||||
|
);
|
||||||
|
if (workArea) {
|
||||||
|
setValue("id", String(workArea.id)); // Set id as a string
|
||||||
|
setValue("areaName", workArea.areaName);
|
||||||
|
setWorkArea(String(workArea.id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -70,8 +83,8 @@ const WorkAreaModel = ({ project, onSubmit, clearTrigger, onClearComplete, onClo
|
|||||||
|
|
||||||
if (floor) {
|
if (floor) {
|
||||||
setSelectedFloor(floor);
|
setSelectedFloor(floor);
|
||||||
setValue("floorId", floor.id); // Update floorId
|
setValue("floorId", floor.id); // Update floorId
|
||||||
setValue("id", "0"); // Reset Work Area ID for new area creation
|
setValue("id", "0"); // Reset Work Area ID for new area creation
|
||||||
setValue("areaName", ""); // Reset Work Area Name when changing floor
|
setValue("areaName", ""); // Reset Work Area Name when changing floor
|
||||||
} else {
|
} else {
|
||||||
setSelectedFloor(null);
|
setSelectedFloor(null);
|
||||||
@ -89,37 +102,31 @@ const WorkAreaModel = ({ project, onSubmit, clearTrigger, onClearComplete, onClo
|
|||||||
reset(defaultModel); // Reset the form when a new building is selected
|
reset(defaultModel); // Reset the form when a new building is selected
|
||||||
};
|
};
|
||||||
|
|
||||||
const onSubmitForm = ( data ) =>
|
const onSubmitForm = (data) => {
|
||||||
{
|
|
||||||
|
|
||||||
let WorkArea = {
|
let WorkArea = {
|
||||||
id: data.id,
|
id: data.id,
|
||||||
areaName: data.areaName,
|
areaName: data.areaName,
|
||||||
floorId: data.floorId,
|
floorId: data.floorId,
|
||||||
buildingId:data.buildingId
|
buildingId: data.buildingId,
|
||||||
|
};
|
||||||
|
onSubmit(WorkArea);
|
||||||
|
|
||||||
|
reset({
|
||||||
|
id: "0",
|
||||||
|
areaName: "",
|
||||||
|
});
|
||||||
|
if (data.id !== "0") {
|
||||||
|
showToast("WorkArea updated successfully.", "success");
|
||||||
|
} else {
|
||||||
|
showToast("WorkArea created successfully.", "success");
|
||||||
}
|
}
|
||||||
onSubmit( WorkArea );
|
|
||||||
|
|
||||||
reset( {
|
|
||||||
id:"0",
|
|
||||||
areaName:""
|
|
||||||
} );
|
|
||||||
if ( data.id !== "0" )
|
|
||||||
{
|
|
||||||
showToast( "WorkArea updated successfully.", "success" );
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
showToast( "WorkArea created successfully.", "success" );
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleCancel = () => {
|
const handleCancel = () => {
|
||||||
reset(defaultModel);
|
reset(defaultModel);
|
||||||
setSelectedFloor(null);
|
setSelectedFloor(null);
|
||||||
setSelectedBuilding( null );
|
setSelectedBuilding(null);
|
||||||
onClose()
|
onClose();
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -127,14 +134,21 @@ const WorkAreaModel = ({ project, onSubmit, clearTrigger, onClearComplete, onClo
|
|||||||
<div className="modal-content">
|
<div className="modal-content">
|
||||||
<div className="modal-body">
|
<div className="modal-body">
|
||||||
<div className="row">
|
<div className="row">
|
||||||
<button type="button" className="btn-close" aria-label="Close" onClick={onClose}/>
|
<button
|
||||||
|
type="button"
|
||||||
|
className="btn-close"
|
||||||
|
aria-label="Close"
|
||||||
|
onClick={onClose}
|
||||||
|
/>
|
||||||
<div className="text-center mb-1">
|
<div className="text-center mb-1">
|
||||||
<h5 className="mb-1">Manage Work Area</h5>
|
<h5 className="mb-1">Manage Work Area</h5>
|
||||||
</div>
|
</div>
|
||||||
<form className="row g-2" onSubmit={handleSubmit(onSubmitForm)}>
|
<form className="row g-2" onSubmit={handleSubmit(onSubmitForm)}>
|
||||||
{/* Building Selection */}
|
{/* Building Selection */}
|
||||||
<div className="col-6 col-md-6">
|
<div className="col-6 col-md-6">
|
||||||
<label className="form-label" htmlFor="buildingId">Select Building</label>
|
<label className="form-label" htmlFor="buildingId">
|
||||||
|
Select Building
|
||||||
|
</label>
|
||||||
<select
|
<select
|
||||||
id="buildingId"
|
id="buildingId"
|
||||||
name="buildingId"
|
name="buildingId"
|
||||||
@ -143,11 +157,14 @@ const WorkAreaModel = ({ project, onSubmit, clearTrigger, onClearComplete, onClo
|
|||||||
onChange={handleBuildingChange}
|
onChange={handleBuildingChange}
|
||||||
>
|
>
|
||||||
<option value="0">Select Building</option>
|
<option value="0">Select Building</option>
|
||||||
{project?.buildings?.map((building) => (
|
{project?.buildings
|
||||||
<option key={building.id} value={building.id}>
|
?.slice()
|
||||||
{building.name}
|
.sort((a, b) => a.name.localeCompare(b.name))
|
||||||
</option>
|
.map((building) => (
|
||||||
))}
|
<option key={building.id} value={building.id}>
|
||||||
|
{building.name}
|
||||||
|
</option>
|
||||||
|
))}
|
||||||
</select>
|
</select>
|
||||||
{errors.buildingId && <span>{errors.buildingId.message}</span>}
|
{errors.buildingId && <span>{errors.buildingId.message}</span>}
|
||||||
</div>
|
</div>
|
||||||
@ -155,7 +172,9 @@ const WorkAreaModel = ({ project, onSubmit, clearTrigger, onClearComplete, onClo
|
|||||||
{/* Floor Selection */}
|
{/* Floor Selection */}
|
||||||
{selectedBuilding && selectedBuilding.buildingId !== "0" && (
|
{selectedBuilding && selectedBuilding.buildingId !== "0" && (
|
||||||
<div className="col-6 col-md-6">
|
<div className="col-6 col-md-6">
|
||||||
<label className="form-label" htmlFor="floorId">Select Floor</label>
|
<label className="form-label" htmlFor="floorId">
|
||||||
|
Select Floor
|
||||||
|
</label>
|
||||||
<select
|
<select
|
||||||
id="floorId"
|
id="floorId"
|
||||||
name="floorId"
|
name="floorId"
|
||||||
@ -164,11 +183,14 @@ const WorkAreaModel = ({ project, onSubmit, clearTrigger, onClearComplete, onClo
|
|||||||
onChange={handleFloorChange}
|
onChange={handleFloorChange}
|
||||||
>
|
>
|
||||||
<option value="0">Select Floor</option>
|
<option value="0">Select Floor</option>
|
||||||
{selectedBuilding.floors.map((floor) => (
|
{selectedBuilding.floors
|
||||||
<option key={floor.id} value={floor.id}>
|
?.slice()
|
||||||
{floor.floorName}
|
.sort((a, b) => a.floorName.localeCompare(b.floorName))
|
||||||
</option>
|
.map((floor) => (
|
||||||
))}
|
<option key={floor.id} value={floor.id}>
|
||||||
|
{floor.floorName}
|
||||||
|
</option>
|
||||||
|
))}
|
||||||
</select>
|
</select>
|
||||||
{errors.floorId && <span>{errors.floorId.message}</span>}
|
{errors.floorId && <span>{errors.floorId.message}</span>}
|
||||||
</div>
|
</div>
|
||||||
@ -178,14 +200,13 @@ const WorkAreaModel = ({ project, onSubmit, clearTrigger, onClearComplete, onClo
|
|||||||
{floorId !== "0" && (
|
{floorId !== "0" && (
|
||||||
<>
|
<>
|
||||||
<div className="col-12 col-md-12">
|
<div className="col-12 col-md-12">
|
||||||
<label className="form-label" >Select Work Area</label>
|
<label className="form-label">Select Work Area</label>
|
||||||
<select
|
<select
|
||||||
id="workAreaId"
|
id="workAreaId"
|
||||||
name="workAreaId"
|
name="workAreaId"
|
||||||
className="select2 form-select form-select-sm"
|
className="select2 form-select form-select-sm"
|
||||||
{...register("id")}
|
{...register("id")}
|
||||||
onChange={handleWorkAreaChange}
|
onChange={handleWorkAreaChange}
|
||||||
|
|
||||||
>
|
>
|
||||||
<option value="0">Create New Work Area</option>
|
<option value="0">Create New Work Area</option>
|
||||||
{selectedFloor?.workAreas?.map((workArea) => (
|
{selectedFloor?.workAreas?.map((workArea) => (
|
||||||
@ -200,7 +221,9 @@ const WorkAreaModel = ({ project, onSubmit, clearTrigger, onClearComplete, onClo
|
|||||||
{/* Work Area Name Input */}
|
{/* Work Area Name Input */}
|
||||||
<div className="col-12 col-md-12">
|
<div className="col-12 col-md-12">
|
||||||
<label className="form-label" htmlFor="areaName">
|
<label className="form-label" htmlFor="areaName">
|
||||||
{watch("id") === "0" ? "Enter Work Area Name" : "Modify Work Area Name"}
|
{watch("id") === "0"
|
||||||
|
? "Enter Work Area Name"
|
||||||
|
: "Modify Work Area Name"}
|
||||||
</label>
|
</label>
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
@ -210,15 +233,28 @@ const WorkAreaModel = ({ project, onSubmit, clearTrigger, onClearComplete, onClo
|
|||||||
placeholder="Work Area"
|
placeholder="Work Area"
|
||||||
{...register("areaName")}
|
{...register("areaName")}
|
||||||
/>
|
/>
|
||||||
{errors.areaName && <span className="danger-text">{errors.areaName.message}</span>}
|
{errors.areaName && (
|
||||||
|
<span className="danger-text">
|
||||||
|
{errors.areaName.message}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Submit and Cancel Buttons */}
|
{/* Submit and Cancel Buttons */}
|
||||||
<div className="col-12 text-center">
|
<div className="col-12 text-center">
|
||||||
<button type="submit" className="btn btn-sm btn-primary me-3">
|
<button
|
||||||
|
type="submit"
|
||||||
|
className="btn btn-sm btn-primary me-3"
|
||||||
|
>
|
||||||
{watch("id") === "0" ? "Add Work Area" : "Edit Work Area"}
|
{watch("id") === "0" ? "Add Work Area" : "Edit Work Area"}
|
||||||
</button>
|
</button>
|
||||||
<button type="button" className="btn btn-sm btn-label-secondary" onClick={handleCancel} data-bs-dismiss="modal" aria-label="Close">
|
<button
|
||||||
|
type="button"
|
||||||
|
className="btn btn-sm btn-label-secondary"
|
||||||
|
onClick={handleCancel}
|
||||||
|
data-bs-dismiss="modal"
|
||||||
|
aria-label="Close"
|
||||||
|
>
|
||||||
Cancel
|
Cancel
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
@ -8,6 +8,7 @@ const WorkItem = ({ workItem, forBuilding, forFloor, forWorkArea }) => {
|
|||||||
const [itemName, setItemName] = useState("");
|
const [itemName, setItemName] = useState("");
|
||||||
const [NewWorkItem, setNewWorkItem] = useState();
|
const [NewWorkItem, setNewWorkItem] = useState();
|
||||||
const [isModalOpen, setIsModalOpen] = useState(false);
|
const [isModalOpen, setIsModalOpen] = useState(false);
|
||||||
|
const [showModal, setShowModal] = useState(false);
|
||||||
|
|
||||||
const openModal = () => setIsModalOpen(true);
|
const openModal = () => setIsModalOpen(true);
|
||||||
const closeModal = () => setIsModalOpen(false);
|
const closeModal = () => setIsModalOpen(false);
|
||||||
@ -38,6 +39,8 @@ const WorkItem = ({ workItem, forBuilding, forFloor, forWorkArea }) => {
|
|||||||
tooltipTriggerList.forEach((el) => new bootstrap.Tooltip(el));
|
tooltipTriggerList.forEach((el) => new bootstrap.Tooltip(el));
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
const showModal1 = () => setShowModal(true);
|
||||||
|
const closeModal1 = () => setShowModal(false);
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div
|
<div
|
||||||
@ -50,6 +53,33 @@ const WorkItem = ({ workItem, forBuilding, forFloor, forWorkArea }) => {
|
|||||||
<AssignRoleModel assignData={assigndata} onClose={closeModal} />
|
<AssignRoleModel assignData={assigndata} onClose={closeModal} />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div
|
||||||
|
className={`modal fade ${showModal ? "show" : ""}`}
|
||||||
|
tabIndex="-1"
|
||||||
|
role="dialog"
|
||||||
|
style={{ display: showModal ? "block" : "none" }}
|
||||||
|
aria-hidden={!showModal}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
className="modal-dialog modal-lg modal-simple mx-sm-auto mx-1 edit-project-modal"
|
||||||
|
role="document"
|
||||||
|
>
|
||||||
|
<div className="modal-content">
|
||||||
|
<div className="modal-body p-sm-4 p-0">
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="btn-close"
|
||||||
|
onClick={closeModal1}
|
||||||
|
aria-label="Close"
|
||||||
|
></button>
|
||||||
|
<div className="container my-1"></div>
|
||||||
|
|
||||||
|
<h6>Comming Soon</h6>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td className="text-start table-cell-small">
|
<td className="text-start table-cell-small">
|
||||||
<i className="bx bx-right-arrow-alt"></i>
|
<i className="bx bx-right-arrow-alt"></i>
|
||||||
@ -119,6 +149,7 @@ const WorkItem = ({ workItem, forBuilding, forFloor, forWorkArea }) => {
|
|||||||
aria-label="Modify"
|
aria-label="Modify"
|
||||||
type="button"
|
type="button"
|
||||||
className="btn p-0 dropdown-toggle hide-arrow"
|
className="btn p-0 dropdown-toggle hide-arrow"
|
||||||
|
onClick={showModal1}
|
||||||
>
|
>
|
||||||
<i
|
<i
|
||||||
className="bx bxs-edit me-2 text-primary"
|
className="bx bxs-edit me-2 text-primary"
|
||||||
@ -132,6 +163,7 @@ const WorkItem = ({ workItem, forBuilding, forFloor, forWorkArea }) => {
|
|||||||
aria-label="Delete"
|
aria-label="Delete"
|
||||||
type="button"
|
type="button"
|
||||||
className="btn p-0 dropdown-toggle hide-arrow"
|
className="btn p-0 dropdown-toggle hide-arrow"
|
||||||
|
onClick={showModal1}
|
||||||
>
|
>
|
||||||
<i
|
<i
|
||||||
className="bx bx-trash me-1 text-danger"
|
className="bx bx-trash me-1 text-danger"
|
||||||
@ -154,11 +186,11 @@ const WorkItem = ({ workItem, forBuilding, forFloor, forWorkArea }) => {
|
|||||||
|
|
||||||
<div className="dropdown-menu dropdown-menu-end m-0">
|
<div className="dropdown-menu dropdown-menu-end m-0">
|
||||||
{" "}
|
{" "}
|
||||||
<a className="dropdown-item ">
|
<a className="dropdown-item " onClick={showModal1}>
|
||||||
{" "}
|
{" "}
|
||||||
<i className="bx bxs-edit me-2 text-primary"></i>Edit
|
<i className="bx bxs-edit me-2 text-primary"></i>Edit
|
||||||
</a>
|
</a>
|
||||||
<a className="dropdown-item">
|
<a className="dropdown-item" onClick={showModal1}>
|
||||||
{" "}
|
{" "}
|
||||||
<i className="bx bx-trash me-1 text-danger"></i>Delete
|
<i className="bx bx-trash me-1 text-danger"></i>Delete
|
||||||
</a>
|
</a>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user