diff --git a/src/components/Expenses/ManageExpense.jsx b/src/components/Expenses/ManageExpense.jsx
index 4ae12c6c..9b14bfcf 100644
--- a/src/components/Expenses/ManageExpense.jsx
+++ b/src/components/Expenses/ManageExpense.jsx
@@ -327,6 +327,7 @@ const ManageExpense = ({ closeModal, expenseToEdit = null }) => {
control={control}
name="paidById"
projectId={null}
+ forAll={expenseToEdit ? true : false}
/>
diff --git a/src/components/Organization/OrganizationsList.jsx b/src/components/Organization/OrganizationsList.jsx
index 6e170a2f..af981025 100644
--- a/src/components/Organization/OrganizationsList.jsx
+++ b/src/components/Organization/OrganizationsList.jsx
@@ -23,7 +23,7 @@ const OrganizationsList = ({searchText}) => {
label: "Organization Name",
getValue: (org) => (
-
+
{
+const EmployeeSearchInput = ({
+ control,
+ name,
+ projectId,
+ placeholder,
+ forAll,
+}) => {
const {
field: { onChange, value, ref },
fieldState: { error },
@@ -17,17 +20,20 @@ const EmployeeSearchInput = ({ control, name, projectId,placeholder }) => {
const [showDropdown, setShowDropdown] = useState(false);
const debouncedSearch = useDebounce(search, 500);
- const {
- data: employees,
- isLoading,
- } = useEmployeesName(projectId, debouncedSearch);
+ const { data: employees, isLoading } = useEmployeesName(
+ projectId,
+ debouncedSearch,
+ forAll
+ );
useEffect(() => {
- if (value && !search) {
- const found = employees?.data?.find((emp) => emp.id === value);
- if (found) setSearch(found.firstName + " " + found.lastName);
+ if (value && employees?.data) {
+ const found = employees.data.find((emp) => emp.id === value);
+ if (found && forAll) {
+ setSearch(found.firstName + " " + found.lastName);
+ }
}
- }, [value, employees]);
+ }, [value, employees?.data]);
const handleSelect = (employee) => {
onChange(employee.id);
@@ -46,7 +52,7 @@ const EmployeeSearchInput = ({ control, name, projectId,placeholder }) => {
onChange={(e) => {
setSearch(e.target.value);
setShowDropdown(true);
- onChange("");
+ onChange("");
}}
onFocus={() => {
if (search) setShowDropdown(true);
@@ -61,28 +67,27 @@ const EmployeeSearchInput = ({ control, name, projectId,placeholder }) => {
{isLoading ? (
Searching...
-
) : (
employees?.data?.map((emp) => (
- handleSelect(emp)}
- >
-
-
-
- {`${emp?.firstName} ${emp?.lastName}`.trim()}
-
-
-
+ handleSelect(emp)}
+ >
+
+
+
+ {`${emp?.firstName} ${emp?.lastName}`.trim()}
+
+
+
))
)}
diff --git a/src/hooks/useEmployees.js b/src/hooks/useEmployees.js
index 477b18f7..2b37e0de 100644
--- a/src/hooks/useEmployees.js
+++ b/src/hooks/useEmployees.js
@@ -184,11 +184,11 @@ export const useEmployeeProfile = (employeeId) => {
};
};
-export const useEmployeesName = (projectId, search) => {
+export const useEmployeesName = (projectId, search,allEmployee) => {
return useQuery({
- queryKey: ["employees", projectId, search],
+ queryKey: ["employees", projectId, search,allEmployee],
queryFn: async () =>
- await EmployeeRepository.getEmployeeName(projectId, search),
+ await EmployeeRepository.getEmployeeName(projectId, search,allEmployee),
staleTime: 5 * 60 * 1000, // Optional: cache for 5 minutes
});
diff --git a/src/pages/authentication/SwitchTenant.jsx b/src/pages/authentication/SwitchTenant.jsx
index b5a8652a..028414cb 100644
--- a/src/pages/authentication/SwitchTenant.jsx
+++ b/src/pages/authentication/SwitchTenant.jsx
@@ -86,7 +86,7 @@ const SwitchTenant = () => {