Adding condition if single or no project assigned then dropdown is not shown

This commit is contained in:
Kartik Sharma 2025-09-19 19:13:02 +05:30
parent 7d17422681
commit 1da587d010

View File

@ -37,6 +37,7 @@ const Teams = () => {
const [deleteEmployee, setDeleteEmplyee] = useState(null); const [deleteEmployee, setDeleteEmplyee] = useState(null);
const [searchTerm, setSearchTerm] = useState(""); // State for search term const [searchTerm, setSearchTerm] = useState(""); // State for search term
const { data: assignedServices, isLoading: servicesLoading } = useProjectAssignedServices(projectId); const { data: assignedServices, isLoading: servicesLoading } = useProjectAssignedServices(projectId);
const handleToggleActive = e => setActiveEmployee(e.target.checked);
const [selectedService, setSelectedService] = useState(""); const [selectedService, setSelectedService] = useState("");
@ -262,22 +263,10 @@ const Teams = () => {
<div className="card-body"> <div className="card-body">
<div className="row d-flex justify-content-between mb-4"> <div className="row d-flex justify-content-between mb-4">
<div className="col-md-6 col-12 d-flex align-items-center"> <div className="col-md-6 col-12 d-flex align-items-center">
<div className="dataTables_filter d-inline-flex align-items-center ms-2"> <div className="dataTables_length text-start py-1 px-0 col-md-4 col-12">
<input {servicesLoading ? (
type="search" <span>Loading...</span>
className="form-control form-control-sm me-4" ) : assignedServices?.length > 1 ? (
placeholder="Search by Name or Role"
aria-controls="DataTables_Table_0"
value={searchTerm}
onChange={handleSearch}
/>
</div>
{/* Services-Dropdown */}
<div
className="dataTables_length text-start py-1 px-0 col-md-4 col-12"
id="DataTables_Table_0_length"
>
<label> <label>
<select <select
name="DataTables_Table_0_length" name="DataTables_Table_0_length"
@ -288,38 +277,58 @@ const Teams = () => {
onChange={handleServiceChange} onChange={handleServiceChange}
style={{ fontSize: "0.875rem", height: "32px", width: "190px" }} style={{ fontSize: "0.875rem", height: "32px", width: "190px" }}
> >
{servicesLoading && <option>Loading...</option>} {assignedServices.map((service) => (
{assignedServices?.map((service) => (
<option key={service.id} value={service.id}> <option key={service.id} value={service.id}>
{service.name} {service.name}
</option> </option>
))} ))}
</select> </select>
</label> </label>
</div> ) : (
</div> <div
<div className="col-md-6 col-12 d-flex justify-content-end align-items-center"> style={{
<div fontSize: "0.875rem",
className="dataTables_length text-start py-2 px-2" height: "32px",
id="DataTables_Table_0_length" width: "190px",
> border: "1px solid #ced4da",
<label> borderRadius: "0.25rem",
<select padding: "4px 8px",
name="DataTables_Table_0_length" display: "flex",
aria-controls="DataTables_Table_0" alignItems: "center",
className="form-select form-select-sm" }}
onChange={handleFilterEmployee}
// value={false}
aria-label=""
defaultValue="true"
> >
<option value="true">Active Employee</option> {assignedServices?.length === 1
<option value="false">In-Active Employee</option> ? assignedServices[0].name
</select> : "No service available"}
</label> </div>
)}
</div> </div>
<div className="dataTables_filter d-inline-flex align-items-center ms-2">
<input
type="search"
className="form-control form-control-sm me-4"
placeholder="Search by Name or Role"
aria-controls="DataTables_Table_0"
value={searchTerm}
onChange={handleSearch}
/>
</div>
</div>
<div className="col-md-6 col-12 d-flex justify-content-end align-items-center">
<div className="form-check form-switch me-4 mt-2">
<input
type="checkbox"
className="form-check-input"
checked={activeEmployee}
onChange={handleToggleActive}
id="activeEmployeeSwitch"
/>
<label className="form-check-label ms-0 " htmlFor="activeEmployeeSwitch">
{activeEmployee ? "Active Employees" : "Inactive Employees"}
</label>
</div>
<button <button
type="button" type="button"