Refactor_Expenses #321

Merged
pramod.mahajan merged 249 commits from Refactor_Expenses into hotfix/MasterActivity 2025-08-01 13:14:59 +00:00
Showing only changes of commit 7b0cc6cdbe - Show all commits

View File

@ -48,6 +48,9 @@ const AssignTask = ({ assignData, onClose, setAssigned }) => {
const infoRef = useRef(null); const infoRef = useRef(null);
const infoRef1 = useRef(null); const infoRef1 = useRef(null);
// State for search term
const [searchTerm, setSearchTerm] = useState("");
useEffect(() => { useEffect(() => {
if (typeof bootstrap !== "undefined") { if (typeof bootstrap !== "undefined") {
if (infoRef.current) { if (infoRef.current) {
@ -129,12 +132,25 @@ const AssignTask = ({ assignData, onClose, setAssigned }) => {
setSelectedRole(event.target.value); setSelectedRole(event.target.value);
}; };
const filteredEmployees = const handleSearchChange = (event) => {
selectedRole === "all" setSearchTerm(event.target.value);
? employees };
: employees?.filter(
(emp) => String(emp.jobRoleId || "") === selectedRole // Filter employees first by role, then by search term AND job role name
); const filteredEmployees = employees?.filter((emp) => {
const matchesRole =
selectedRole === "all" || String(emp.jobRoleId || "") === selectedRole;
// Convert both first and last names and job role name to lowercase for case-insensitive matching
const fullName = `${emp.firstName} ${emp.lastName}`.toLowerCase();
const jobRoleName = jobRoleData?.find((role) => role.id === emp.jobRoleId)?.name?.toLowerCase() || "";
const searchLower = searchTerm.toLowerCase();
// Check if the full name OR job role name includes the search term
const matchesSearch = fullName.includes(searchLower) || jobRoleName.includes(searchLower);
return matchesRole && matchesSearch;
});
const onSubmit = (data) => { const onSubmit = (data) => {
const selectedEmployeeIds = data.selectedEmployees; const selectedEmployeeIds = data.selectedEmployees;
@ -159,6 +175,7 @@ const AssignTask = ({ assignData, onClose, setAssigned }) => {
reset(); reset();
onClose(); onClose();
}; };
return ( return (
<div className="fs-5 text-dark text-center d-flex align-items-center justify-content-center flex-wrap"> <div className="fs-5 text-dark text-center d-flex align-items-center justify-content-center flex-wrap">
<p className="align-items-center flex-wrap m-0 ">Assign Task</p> <p className="align-items-center flex-wrap m-0 ">Assign Task</p>
@ -191,7 +208,7 @@ const AssignTask = ({ assignData, onClose, setAssigned }) => {
<div className="col-12"> <div className="col-12">
<div className="form-text text-start"> <div className="form-text text-start">
<div className="d-flex align-items-center form-text fs-7"> <div className="d-flex align-items-center form-text fs-7">
<span className="text-dark">Select Team</span> <span className="text-dark me-2">Select Team</span>
<div className="me-2">{displayedSelection}</div> <div className="me-2">{displayedSelection}</div>
<a <a
className="dropdown-toggle hide-arrow cursor-pointer" className="dropdown-toggle hide-arrow cursor-pointer"
@ -232,6 +249,15 @@ const AssignTask = ({ assignData, onClose, setAssigned }) => {
</li> </li>
))} ))}
</ul> </ul>
{/* Search Field for Employees - Moved inline and pushed to the right */}
<input
type="text"
className="form-control form-control-sm ms-auto mb-2 mt-2" // Changed ms-3 to ms-auto
placeholder="Search employees or roles..."
value={searchTerm}
onChange={handleSearchChange}
style={{ maxWidth: '200px' }} // Optional: Limit search input width
/>
</div> </div>
</div> </div>
</div> </div>
@ -304,7 +330,7 @@ const AssignTask = ({ assignData, onClose, setAssigned }) => {
) : ( ) : (
<div className="col-12"> <div className="col-12">
<p className="text-center"> <p className="text-center">
No employees found for the selected role. No employees found for the selected role or search term.
</p> </p>
</div> </div>
)} )}
@ -439,11 +465,11 @@ const AssignTask = ({ assignData, onClose, setAssigned }) => {
id="defaultFormControlInput" id="defaultFormControlInput"
aria-describedby="defaultFormControlHelp" aria-describedby="defaultFormControlHelp"
/> />
<span style={{ paddingLeft: "6px" }}> <span style={{ paddingLeft: "6px", whiteSpace: "nowrap" }}>
{ <u> {
assignData?.workItem?.workItem?.activityMaster assignData?.workItem?.activityMaster
?.unitOfMeasurement ?.unitOfMeasurement
} }</u>
</span> </span>
<div <div
style={{ style={{