ImagesTable: Fix version filter

This fixes the "All versions" / "Newest" filter in the blueprint images table.
This commit is contained in:
regexowl 2025-01-08 13:33:04 +01:00 committed by Klara Simickova
parent add30905ab
commit d3e76c6d49

View file

@ -65,6 +65,7 @@ import {
ComposesResponseItem,
ComposeStatus,
GetBlueprintComposesApiArg,
GetBlueprintsApiArg,
useGetBlueprintComposesQuery,
useGetComposesQuery,
useGetComposeStatusQuery,
@ -89,12 +90,17 @@ const ImagesTable = () => {
const blueprintsOffset = useAppSelector(selectOffset) || PAGINATION_OFFSET;
const blueprintsLimit = useAppSelector(selectLimit) || PAGINATION_LIMIT;
const searchParamsGetBlueprints: GetBlueprintsApiArg = {
limit: blueprintsLimit,
offset: blueprintsOffset,
};
if (blueprintSearchInput) {
searchParamsGetBlueprints.search = blueprintSearchInput;
}
const { selectedBlueprintVersion } = useGetBlueprintsQuery(
{
search: blueprintSearchInput,
limit: blueprintsLimit,
offset: blueprintsOffset,
},
searchParamsGetBlueprints,
{
selectFromResult: ({ data }) => ({
selectedBlueprintVersion: data?.data?.find(
@ -110,14 +116,15 @@ const ImagesTable = () => {
setPerPage(perPage);
};
const searchParams: GetBlueprintComposesApiArg = {
const searchParamsGetBlueprintComposes: GetBlueprintComposesApiArg = {
id: selectedBlueprintId as string,
limit: perPage,
offset: perPage * (page - 1),
};
if (blueprintVersionFilterAPI) {
searchParams.blueprintVersion = blueprintVersionFilterAPI;
searchParamsGetBlueprintComposes.blueprintVersion =
blueprintVersionFilterAPI;
}
const {
@ -125,7 +132,7 @@ const ImagesTable = () => {
isSuccess: isBlueprintsSuccess,
isLoading: isLoadingBlueprintsCompose,
isError: isBlueprintsError,
} = useGetBlueprintComposesQuery(searchParams, {
} = useGetBlueprintComposesQuery(searchParamsGetBlueprintComposes, {
skip: !selectedBlueprintId,
});