Skip to content

Commit fef8b9f

Browse files
authored
Merge pull request #2599 from IntersectMBO/fix/2535-400-bad-request-error-when-switching-to-governance-action-page
fix(#2535): fix bad request on ga list
2 parents 8d13f33 + 8fc7608 commit fef8b9f

File tree

5 files changed

+15
-1
lines changed

5 files changed

+15
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ changes.
1717
### Fixed
1818

1919
- Fix CIP-129 DRep view identifier for script based DReps [Issue 2583](https://github.com/IntersectMBO/govtool/issues/2583)
20+
- Fix bad request on passing the random sorting to GA list request [Issue 2535](https://github.com/IntersectMBO/govtool/issues/2535)
2021

2122
### Changed
2223

govtool/frontend/src/components/organisms/DashboardGovernanceActions.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ const StyledTab = styled((props: StyledTabProps) => (
6767
}));
6868

6969
export const DashboardGovernanceActions = () => {
70-
const { debouncedSearchText, ...dataActionsBarProps } = useDataActionsBar();
70+
const { debouncedSearchText, isAdjusting, ...dataActionsBarProps } =
71+
useDataActionsBar();
7172
const { chosenFilters, chosenSorting } = dataActionsBarProps;
7273
const { voter } = useGetVoterInfo();
7374
const { isMobile } = useScreenDimension();
@@ -81,6 +82,7 @@ export const DashboardGovernanceActions = () => {
8182
filters: queryFilters,
8283
sorting: chosenSorting,
8384
searchPhrase: debouncedSearchText,
85+
enabled: !isAdjusting,
8486
});
8587

8688
const { state } = useLocation();

govtool/frontend/src/context/dataActionsBar.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { useLocation } from "react-router-dom";
1414
import { useDebounce } from "@hooks";
1515

1616
interface DataActionsBarContextType {
17+
isAdjusting: boolean;
1718
chosenFilters: string[];
1819
chosenFiltersLength: number;
1920
chosenSorting: string;
@@ -40,6 +41,7 @@ interface ProviderProps {
4041
}
4142

4243
const DataActionsBarProvider: FC<ProviderProps> = ({ children }) => {
44+
const [isAdjusting, setIsAdjusting] = useState<boolean>(true);
4345
const [searchText, setSearchText] = useState<string>("");
4446
const debouncedSearchText = useDebounce(searchText, 300);
4547
const [filtersOpen, setFiltersOpen] = useState<boolean>(false);
@@ -62,6 +64,7 @@ const DataActionsBarProvider: FC<ProviderProps> = ({ children }) => {
6264
setSearchText("");
6365
setChosenFilters([]);
6466
setChosenSorting("");
67+
setIsAdjusting(false);
6568
}, []);
6669

6770
const userMovedToDifferentAppArea =
@@ -74,6 +77,7 @@ const DataActionsBarProvider: FC<ProviderProps> = ({ children }) => {
7477
pathname.includes("governance_actions/category");
7578

7679
useEffect(() => {
80+
setIsAdjusting(true);
7781
if (
7882
(!pathname.includes("drep_directory") &&
7983
userMovedToDifferentAppArea &&
@@ -90,6 +94,7 @@ const DataActionsBarProvider: FC<ProviderProps> = ({ children }) => {
9094

9195
const contextValue = useMemo(
9296
() => ({
97+
isAdjusting,
9398
chosenFilters,
9499
chosenFiltersLength: chosenFilters.length,
95100
chosenSorting,
@@ -106,6 +111,7 @@ const DataActionsBarProvider: FC<ProviderProps> = ({ children }) => {
106111
sortOpen,
107112
}),
108113
[
114+
isAdjusting,
109115
chosenFilters,
110116
chosenSorting,
111117
debouncedSearchText,

govtool/frontend/src/hooks/queries/useGetProposalsQuery.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export const useGetProposalsQuery = ({
1010
filters = [],
1111
searchPhrase,
1212
sorting,
13+
enabled,
1314
}: GetProposalsArguments) => {
1415
const { dRepID, pendingTransaction } = useCardano();
1516
const { voter } = useGetVoterInfo();
@@ -42,6 +43,9 @@ export const useGetProposalsQuery = ({
4243
pendingTransaction.vote?.transactionHash,
4344
],
4445
fetchProposals,
46+
{
47+
enabled,
48+
},
4549
);
4650

4751
const proposals = Object.values(groupByType(data) ?? []);

govtool/frontend/src/services/requests/getProposals.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export type GetProposalsArguments = {
1414
pageSize?: number;
1515
sorting?: string;
1616
searchPhrase?: string;
17+
enabled?: boolean;
1718
};
1819

1920
export const getProposals = async ({

0 commit comments

Comments
 (0)