Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,6 @@ export const useGetAssignments = (
allAssignments: data,
};
},
staleTime: Infinity,
});
};
Original file line number Diff line number Diff line change
Expand Up @@ -155,18 +155,14 @@ type Props = {
currentType?: 'TEAM_OF_TEAMS' | 'TEAM_OF_USERS';
order?: string;
search?: string;
};

type PropsByOrgUnitTypeId = {
orgUnitTypeId?: number;
projectId?: number;
excludedOrgUnitParentIds?: string;
extraFilters?: Record<string, any>;
};

export const useGetOrgUnitsByOrgUnitTypeId = ({
orgUnitTypeId,
projectId,
excludedOrgUnitParentIds,
extraFilters = {},
}: PropsByOrgUnitTypeId): UseQueryResult<OrgUnit[], Error> => {
return useSnackQuery({
queryKey: [
Expand Down Expand Up @@ -204,6 +200,7 @@ export const useGetOrgUnits = ({
currentType,
order,
search,
extraFilters = {},
}: Props): UseQueryResult<Locations, Error> => {
const params: Record<string, any> = useMemo(
() => ({
Expand All @@ -213,13 +210,13 @@ export const useGetOrgUnits = ({
geography: 'any',
onlyDirectChildren: false,
page: 1,
withParents: true,
order,
orgUnitParentIds: orgUnitParentIds?.join(','),
orgUnitTypeId: baseOrgunitType,
search,
...extraFilters,
}),
[baseOrgunitType, order, orgUnitParentIds, search],
[baseOrgunitType, order, orgUnitParentIds, search, extraFilters],
);

const select = useCallback(
Expand Down Expand Up @@ -267,13 +264,15 @@ type ListProps = {
baseOrgunitType: string | undefined;
order?: string;
search?: string;
extraFilters?: Record<string, any>;
};

export const useGetOrgUnitsList = ({
orgUnitParentIds,
baseOrgunitType,
order,
search,
extraFilters = {},
}: ListProps): UseQueryResult<OrgUnit[], Error> => {
const params: Record<string, any> = useMemo(
() => ({
Expand All @@ -286,8 +285,9 @@ export const useGetOrgUnitsList = ({
orgUnitParentIds: orgUnitParentIds?.join(','),
orgUnitTypeId: baseOrgunitType,
search,
extraFilters,
}),
[baseOrgunitType, order, orgUnitParentIds, search],
[baseOrgunitType, order, orgUnitParentIds, search, extraFilters],
);

const select = useCallback(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ export const useGetPlanning = (
return useSnackQuery(queryKey, () => getPlanning(planningId), undefined, {
retry: false,
enabled: Boolean(planningId),
staleTime: Infinity,
});
};
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export const useGetProfiles = (): UseQueryResult<
});
},
enabled: Boolean(colors),
staleTime: Infinity,
},
});
};
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useMemo } from 'react';
import { Dispatch, SetStateAction, useMemo, useState } from 'react';

import {
OrgUnitTypeHierarchyDropdownValues,
Expand Down Expand Up @@ -66,6 +66,7 @@ type Result = {
isLoadingAssignments: boolean;
isTeamsFetched: boolean;
setProfiles: (profiles: ProfileWithColor[]) => void;
setExtraFilters: Dispatch<SetStateAction<Record<string, any>>>;
};

export const useGetAssignmentData = ({
Expand All @@ -77,6 +78,9 @@ export const useGetAssignmentData = ({
selectedItem,
search,
}: Props): Result => {
const [extraFilters, setExtraFilters] = useState<Record<string, string>>(
{},
);
const { data: dataProfiles = [] } = useGetProfiles();
const {
data: planning,
Expand Down Expand Up @@ -146,6 +150,7 @@ export const useGetAssignmentData = ({
currentType: currentTeam?.type,
order,
search,
extraFilters,
});
const { data: orgUnitsList, isFetching: isFetchingOrgUnitsList } =
useGetOrgUnitsList({
Expand All @@ -158,6 +163,7 @@ export const useGetAssignmentData = ({
baseOrgunitType,
order,
search,
extraFilters,
});
const [orgUnits] = useBoundState<Locations | undefined>(
undefined,
Expand Down Expand Up @@ -190,5 +196,6 @@ export const useGetAssignmentData = ({
isTeamsFetched,
saveMultiAssignments,
setProfiles,
setExtraFilters,
};
};
2 changes: 2 additions & 0 deletions hat/assets/js/apps/Iaso/domains/assignments/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ export const Assignments: FunctionComponent = () => {
isLoadingAssignments,
isTeamsFetched,
setProfiles,
setExtraFilters,
} = useGetAssignmentData({
planningId,
currentTeam,
Expand Down Expand Up @@ -306,6 +307,7 @@ export const Assignments: FunctionComponent = () => {
)}
orgunitTypes={orgunitTypes}
isFetchingOrgunitTypes={isFetchingOrgunitTypes}
setExtraFilters={setExtraFilters}
/>
)}
</Box>
Expand Down
4 changes: 4 additions & 0 deletions hat/assets/js/apps/Iaso/domains/assignments/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,10 @@ const MESSAGES = defineMessages({
id: 'iaso.assignment.emptyAssignments',
defaultMessage: 'Delete assignments',
},
progress: {
defaultMessage: 'Progress',
id: 'iaso.tasks.progress',
},
});

export default MESSAGES;
Loading
Loading