Skip to content

Commit

Permalink
OSN-551. Fix useCurrentEmployee hook to handle API edge cases by retu…
Browse files Browse the repository at this point in the history
…rning an empty object when currentEmployee is not available
  • Loading branch information
ek-hystax authored Jan 13, 2025
1 parent 0d72372 commit 463f03b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions ngui/ui/src/hooks/coreData/useCurrentEmployee.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ import { useOrganizationInfo } from "../useOrganizationInfo";
export const useCurrentEmployee = () => {
const { organizationId } = useOrganizationInfo();

const { data: { currentEmployee = {} } = {} } = useQuery(GET_CURRENT_EMPLOYEE, {
const { data } = useQuery(GET_CURRENT_EMPLOYEE, {
variables: {
organizationId
},
fetchPolicy: "cache-only"
});

return currentEmployee;
// The current user is not always returned by the API in some corner test cases
return data?.currentEmployee ?? {};
};

0 comments on commit 463f03b

Please sign in to comment.