Skip to content

Commit

Permalink
fix(#2535): fix bad request on ga list
Browse files Browse the repository at this point in the history
  • Loading branch information
MSzalowski committed Jan 3, 2025
1 parent 82ae303 commit a9c6932
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ changes.

### Fixed

-
- Fix bad request on passing the random sorting to GA list request [Issue 2535](https://github.com/IntersectMBO/govtool/issues/2535)

### Changed

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ const StyledTab = styled((props: StyledTabProps) => (
}));

export const DashboardGovernanceActions = () => {
const { debouncedSearchText, ...dataActionsBarProps } = useDataActionsBar();
const { debouncedSearchText, isAdjusting, ...dataActionsBarProps } =
useDataActionsBar();
const { chosenFilters, chosenSorting } = dataActionsBarProps;
const { voter } = useGetVoterInfo();
const { isMobile } = useScreenDimension();
Expand All @@ -81,6 +82,7 @@ export const DashboardGovernanceActions = () => {
filters: queryFilters,
sorting: chosenSorting,
searchPhrase: debouncedSearchText,
enabled: !isAdjusting,
});

const { state } = useLocation();
Expand Down
6 changes: 6 additions & 0 deletions govtool/frontend/src/context/dataActionsBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { useLocation } from "react-router-dom";
import { useDebounce } from "@hooks";

interface DataActionsBarContextType {
isAdjusting: boolean;
chosenFilters: string[];
chosenFiltersLength: number;
chosenSorting: string;
Expand All @@ -40,6 +41,7 @@ interface ProviderProps {
}

const DataActionsBarProvider: FC<ProviderProps> = ({ children }) => {
const [isAdjusting, setIsAdjusting] = useState<boolean>(true);
const [searchText, setSearchText] = useState<string>("");
const debouncedSearchText = useDebounce(searchText, 300);
const [filtersOpen, setFiltersOpen] = useState<boolean>(false);
Expand All @@ -62,6 +64,7 @@ const DataActionsBarProvider: FC<ProviderProps> = ({ children }) => {
setSearchText("");
setChosenFilters([]);
setChosenSorting("");
setIsAdjusting(false);
}, []);

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

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

const contextValue = useMemo(
() => ({
isAdjusting,
chosenFilters,
chosenFiltersLength: chosenFilters.length,
chosenSorting,
Expand All @@ -106,6 +111,7 @@ const DataActionsBarProvider: FC<ProviderProps> = ({ children }) => {
sortOpen,
}),
[
isAdjusting,
chosenFilters,
chosenSorting,
debouncedSearchText,
Expand Down
4 changes: 4 additions & 0 deletions govtool/frontend/src/hooks/queries/useGetProposalsQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export const useGetProposalsQuery = ({
filters = [],
searchPhrase,
sorting,
enabled,
}: GetProposalsArguments) => {
const { dRepID, pendingTransaction } = useCardano();
const { voter } = useGetVoterInfo();
Expand Down Expand Up @@ -42,6 +43,9 @@ export const useGetProposalsQuery = ({
pendingTransaction.vote?.transactionHash,
],
fetchProposals,
{
enabled,
},
);

const proposals = Object.values(groupByType(data) ?? []);
Expand Down
1 change: 1 addition & 0 deletions govtool/frontend/src/services/requests/getProposals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export type GetProposalsArguments = {
pageSize?: number;
sorting?: string;
searchPhrase?: string;
enabled?: boolean;
};

export const getProposals = async ({
Expand Down

0 comments on commit a9c6932

Please sign in to comment.