fixed employee name show whenever update expense - for paid by
This commit is contained in:
parent
7872e21477
commit
638c033705
@ -327,6 +327,7 @@ const ManageExpense = ({ closeModal, expenseToEdit = null }) => {
|
|||||||
control={control}
|
control={control}
|
||||||
name="paidById"
|
name="paidById"
|
||||||
projectId={null}
|
projectId={null}
|
||||||
|
forAll={expenseToEdit ? true : false}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -23,7 +23,7 @@ const OrganizationsList = ({searchText}) => {
|
|||||||
label: "Organization Name",
|
label: "Organization Name",
|
||||||
getValue: (org) => (
|
getValue: (org) => (
|
||||||
<div className="d-flex gap-2 py-1 ">
|
<div className="d-flex gap-2 py-1 ">
|
||||||
<i class="bx bx-buildings"></i>
|
<i className="bx bx-buildings"></i>
|
||||||
<span
|
<span
|
||||||
className="text-truncate d-inline-block "
|
className="text-truncate d-inline-block "
|
||||||
style={{ maxWidth: "150px" }}
|
style={{ maxWidth: "150px" }}
|
||||||
|
@ -4,10 +4,13 @@ import { useDebounce } from "../../utils/appUtils";
|
|||||||
import { useController } from "react-hook-form";
|
import { useController } from "react-hook-form";
|
||||||
import Avatar from "./Avatar";
|
import Avatar from "./Avatar";
|
||||||
|
|
||||||
|
const EmployeeSearchInput = ({
|
||||||
|
control,
|
||||||
|
name,
|
||||||
const EmployeeSearchInput = ({ control, name, projectId,placeholder }) => {
|
projectId,
|
||||||
|
placeholder,
|
||||||
|
forAll,
|
||||||
|
}) => {
|
||||||
const {
|
const {
|
||||||
field: { onChange, value, ref },
|
field: { onChange, value, ref },
|
||||||
fieldState: { error },
|
fieldState: { error },
|
||||||
@ -17,17 +20,20 @@ const EmployeeSearchInput = ({ control, name, projectId,placeholder }) => {
|
|||||||
const [showDropdown, setShowDropdown] = useState(false);
|
const [showDropdown, setShowDropdown] = useState(false);
|
||||||
const debouncedSearch = useDebounce(search, 500);
|
const debouncedSearch = useDebounce(search, 500);
|
||||||
|
|
||||||
const {
|
const { data: employees, isLoading } = useEmployeesName(
|
||||||
data: employees,
|
projectId,
|
||||||
isLoading,
|
debouncedSearch,
|
||||||
} = useEmployeesName(projectId, debouncedSearch);
|
forAll
|
||||||
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (value && !search) {
|
if (value && employees?.data) {
|
||||||
const found = employees?.data?.find((emp) => emp.id === value);
|
const found = employees.data.find((emp) => emp.id === value);
|
||||||
if (found) setSearch(found.firstName + " " + found.lastName);
|
if (found && forAll) {
|
||||||
|
setSearch(found.firstName + " " + found.lastName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}, [value, employees]);
|
}, [value, employees?.data]);
|
||||||
|
|
||||||
const handleSelect = (employee) => {
|
const handleSelect = (employee) => {
|
||||||
onChange(employee.id);
|
onChange(employee.id);
|
||||||
@ -46,7 +52,7 @@ const EmployeeSearchInput = ({ control, name, projectId,placeholder }) => {
|
|||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
setSearch(e.target.value);
|
setSearch(e.target.value);
|
||||||
setShowDropdown(true);
|
setShowDropdown(true);
|
||||||
onChange("");
|
onChange("");
|
||||||
}}
|
}}
|
||||||
onFocus={() => {
|
onFocus={() => {
|
||||||
if (search) setShowDropdown(true);
|
if (search) setShowDropdown(true);
|
||||||
@ -61,28 +67,27 @@ const EmployeeSearchInput = ({ control, name, projectId,placeholder }) => {
|
|||||||
{isLoading ? (
|
{isLoading ? (
|
||||||
<li className="list-group-item">
|
<li className="list-group-item">
|
||||||
<a>Searching...</a>
|
<a>Searching...</a>
|
||||||
|
|
||||||
</li>
|
</li>
|
||||||
) : (
|
) : (
|
||||||
employees?.data?.map((emp) => (
|
employees?.data?.map((emp) => (
|
||||||
<li
|
<li
|
||||||
key={emp.id}
|
key={emp.id}
|
||||||
className="list-group-item list-group-item-action py-1 px-1"
|
className="list-group-item list-group-item-action py-1 px-1"
|
||||||
style={{ cursor: "pointer" }}
|
style={{ cursor: "pointer" }}
|
||||||
onClick={() => handleSelect(emp)}
|
onClick={() => handleSelect(emp)}
|
||||||
>
|
>
|
||||||
<div className="d-flex align-items-center px-0">
|
<div className="d-flex align-items-center px-0">
|
||||||
<Avatar
|
<Avatar
|
||||||
size="xs"
|
size="xs"
|
||||||
classAvatar="m-0 me-2"
|
classAvatar="m-0 me-2"
|
||||||
firstName={emp.firstName}
|
firstName={emp.firstName}
|
||||||
lastName={emp.lastName}
|
lastName={emp.lastName}
|
||||||
/>
|
/>
|
||||||
<span className="text-muted">
|
<span className="text-muted">
|
||||||
{`${emp?.firstName} ${emp?.lastName}`.trim()}
|
{`${emp?.firstName} ${emp?.lastName}`.trim()}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
))
|
))
|
||||||
)}
|
)}
|
||||||
</ul>
|
</ul>
|
||||||
|
@ -184,11 +184,11 @@ export const useEmployeeProfile = (employeeId) => {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export const useEmployeesName = (projectId, search) => {
|
export const useEmployeesName = (projectId, search,allEmployee) => {
|
||||||
return useQuery({
|
return useQuery({
|
||||||
queryKey: ["employees", projectId, search],
|
queryKey: ["employees", projectId, search,allEmployee],
|
||||||
queryFn: async () =>
|
queryFn: async () =>
|
||||||
await EmployeeRepository.getEmployeeName(projectId, search),
|
await EmployeeRepository.getEmployeeName(projectId, search,allEmployee),
|
||||||
|
|
||||||
staleTime: 5 * 60 * 1000, // Optional: cache for 5 minutes
|
staleTime: 5 * 60 * 1000, // Optional: cache for 5 minutes
|
||||||
});
|
});
|
||||||
|
@ -86,7 +86,7 @@ const SwitchTenant = () => {
|
|||||||
<button
|
<button
|
||||||
className={` ${currentTenant === tenant.id ? "badge bg-label-primary w-50" :"btn btn-primary btn-sm mt-2 align-self-start" }`}
|
className={` ${currentTenant === tenant.id ? "badge bg-label-primary w-50" :"btn btn-primary btn-sm mt-2 align-self-start" }`}
|
||||||
onClick={() => handleTenantselection(tenant?.id)}
|
onClick={() => handleTenantselection(tenant?.id)}
|
||||||
disabled={isPending && pendingTenant === tenant.id || currentTenant === tenant.id }
|
disabled={isPending && pendingTenant === tenant.id || currentTenant === tenant.id || isPending}
|
||||||
>
|
>
|
||||||
{currentTenant === tenant.id ? "Active Tenant" :isPending && pendingTenant === tenant.id
|
{currentTenant === tenant.id ? "Active Tenant" :isPending && pendingTenant === tenant.id
|
||||||
? "Please Wait.."
|
? "Please Wait.."
|
||||||
|
@ -11,11 +11,12 @@ const EmployeeRepository = {
|
|||||||
// deleteEmployee: ( id ) => api.delete( `/users/${ id }` ),
|
// deleteEmployee: ( id ) => api.delete( `/users/${ id }` ),
|
||||||
getEmployeeProfile: (id) => api.get(`/api/employee/profile/get/${id}`),
|
getEmployeeProfile: (id) => api.get(`/api/employee/profile/get/${id}`),
|
||||||
deleteEmployee: (id,active) => api.delete(`/api/employee/${id}?active=${active}`),
|
deleteEmployee: (id,active) => api.delete(`/api/employee/${id}?active=${active}`),
|
||||||
getEmployeeName: (projectId, search) => {
|
getEmployeeName: (projectId, search,allEmployee) => {
|
||||||
const params = new URLSearchParams();
|
const params = new URLSearchParams();
|
||||||
|
|
||||||
if (projectId) params.append("projectId", projectId);
|
if (projectId) params.append("projectId", projectId);
|
||||||
if (search) params.append("searchString", search);
|
if (search) params.append("searchString", search);
|
||||||
|
if(allEmployee) params.append("allEmployee",allEmployee)
|
||||||
|
|
||||||
const query = params.toString();
|
const query = params.toString();
|
||||||
return api.get(`/api/Employee/basic${query ? `?${query}` : ""}`);
|
return api.get(`/api/Employee/basic${query ? `?${query}` : ""}`);
|
||||||
|
@ -59,7 +59,7 @@ const attemptTokenRefresh = async (storedRefreshToken) => {
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Token refresh failed:", error);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user