Skip to content

Commit

Permalink
Merge pull request #306 from virtualidentityag/OB-5616
Browse files Browse the repository at this point in the history
fix: loading 10k users on every edit and new click
  • Loading branch information
web-mi authored Aug 16, 2023
2 parents d339828 + cefd7d2 commit e376a2d
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions src/api/counselor/editCounselorData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { putAgenciesForCounselor } from '../agency/putAgenciesForCounselor';

/**
* edit counselor
* @param counselorData - newly fetched consultant data from backend
* @param id - id of counselor to save
* @param formData - input data from form
* @return data
*/
Expand All @@ -20,9 +20,9 @@ export const editCounselorData = async (id: string, formData: CounselorData): Pr
lastname,
formalLanguage,
email,
absent,
absent: !!absent,
username: encodeUsername(username),
absenceMessage: absent ? absenceMessage : null,
...(absent ? { absenceMessage } : {}),
twoFactorAuth,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ interface ConsultantsDataProps extends UseQueryOptions<ResponseList<CounselorDat
const DEFAULT_SORT = 'FIRSTNAME';
const DEFAULT_ORDER = 'ASC';

export const useConsultantOrAgencyAdminsData = (
export const useConsultantsOrAdminsData = (
{ search, current, sortBy, order, pageSize, typeOfUser, ...options }: ConsultantsDataProps = {
typeOfUser: TypeOfUser.Consultants,
},
Expand Down
8 changes: 4 additions & 4 deletions src/pages/users/Edit/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { Resource } from '../../../enums/Resource';
import { TypeOfUser } from '../../../enums/TypeOfUser';
import { useAddOrUpdateConsultantOrAdmin } from '../../../hooks/useAddOrUpdateConsultantOrAgencyAdmin';
import { useAgenciesData } from '../../../hooks/useAgencysData';
import { useConsultantOrAgencyAdminsData } from '../../../hooks/useConsultantOrAdminsData';
import { useConsultantsOrAdminsData } from '../../../hooks/useConsultantsOrAdminsData';
import { useUserPermissions } from '../../../hooks/useUserPermission';
import { convertToOptions } from '../../../utils/convertToOptions';
import { decodeUsername } from '../../../utils/encryptionHelpers';
Expand All @@ -27,10 +27,10 @@ export const UserEditOrAdd = () => {
const { can } = useUserPermissions();
const { t } = useTranslation();
const { typeOfUsers, id } = useParams<{ id: string; typeOfUsers: TypeOfUser }>();
// Todo: Temporary solution(VIC-2135)
const { data: consultantsResponse, isLoading: isLoadingConsultants } = useConsultantOrAgencyAdminsData({
pageSize: 10000,
const { data: consultantsResponse, isLoading: isLoadingConsultants } = useConsultantsOrAdminsData({
search: id,
typeOfUser: typeOfUsers,
enabled: !!id,
});
const { data: agenciesData, isLoading } = useAgenciesData({ pageSize: 10000 });
const isEditing = id !== 'add';
Expand Down
4 changes: 2 additions & 2 deletions src/pages/users/List/components/UsersTableData/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import CustomChevronUpIcon from '../../../../../components/CustomIcons/ChevronUp
import EditButtons from '../../../../../components/EditableTable/EditButtons';
import StatusIcons from '../../../../../components/EditableTable/StatusIcons';
import SearchInput from '../../../../../components/SearchInput/SearchInput';
import { useConsultantOrAgencyAdminsData } from '../../../../../hooks/useConsultantOrAdminsData';
import { useConsultantsOrAdminsData } from '../../../../../hooks/useConsultantsOrAdminsData';
import { AgencyData } from '../../../../../types/agency';
import { CounselorData } from '../../../../../types/counselor';
import { Status } from '../../../../../types/status';
Expand Down Expand Up @@ -45,7 +45,7 @@ export const UsersTableData = () => {
data: responseList,
isLoading,
refetch,
} = useConsultantOrAgencyAdminsData({
} = useConsultantsOrAdminsData({
search,
...tableState,
typeOfUser: typeOfUsers,
Expand Down
4 changes: 2 additions & 2 deletions src/pages/users/List/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Page } from '../../../components/Page';
import { PermissionAction } from '../../../enums/PermissionAction';
import { Resource } from '../../../enums/Resource';
import { TypeOfUser } from '../../../enums/TypeOfUser';
import { useConsultantOrAgencyAdminsData } from '../../../hooks/useConsultantOrAdminsData';
import { useConsultantsOrAdminsData } from '../../../hooks/useConsultantsOrAdminsData';
import { useTenantData } from '../../../hooks/useTenantData.hook';
import { useTenantAdminsData } from '../../../hooks/useTenantUserAdminsData';
import { useUserPermissions } from '../../../hooks/useUserPermission';
Expand All @@ -22,7 +22,7 @@ export const UsersList = () => {
const isTenantAdmins = typeOfUsers === TypeOfUser.TenantAdmins;

const { data } = useTenantAdminsData({ current: 1, enabled: isTenantAdmins });
const { data: responseList } = useConsultantOrAgencyAdminsData({
const { data: responseList } = useConsultantsOrAdminsData({
typeOfUser: typeOfUsers,
enabled:
typeOfUsers === TypeOfUser.Consultants
Expand Down

0 comments on commit e376a2d

Please sign in to comment.