Skip to content

Commit

Permalink
fixes sync of cost value with query params
Browse files Browse the repository at this point in the history
  • Loading branch information
agnlez authored and Andrés González committed Nov 15, 2024
1 parent 42fbbd0 commit ae5dca1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
11 changes: 0 additions & 11 deletions client/src/containers/overview/filters/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,17 +140,6 @@ export default function ProjectsFilters() {
250,
);

useEffect(() => {
const resetCosts = async () => {
await setFilters((prev) => ({
...prev,
costRange: INITIAL_COST_RANGE[filters.costRangeSelector],
}));
};

resetCosts();
}, [filters.costRangeSelector, setFilters]);

useEffect(() => {
setCostValuesState([
filters.costRange[0] || INITIAL_COST_RANGE[filters.costRangeSelector][0],
Expand Down
10 changes: 9 additions & 1 deletion client/src/containers/overview/header/parameters/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import { FILTER_KEYS } from "@/app/(overview)/constants";
import { useGlobalFilters } from "@/app/(overview)/url-store";
import { filtersSchema } from "@/app/(overview)/url-store";

import { INITIAL_COST_RANGE } from "@/containers/overview/filters/constants";

import { Label } from "@/components/ui/label";
import {
Select,
Expand Down Expand Up @@ -76,7 +78,13 @@ export default function ParametersProjects() {
v: string,
parameter: keyof Omit<z.infer<typeof filtersSchema>, "keyword">,
) => {
await setFilters((prev) => ({ ...prev, [parameter]: v }));
await setFilters((prev) => ({
...prev,
[parameter]: v,
...(parameter === "costRangeSelector" && {
costRange: INITIAL_COST_RANGE[v as COST_TYPE_SELECTOR],
}),
}));
};

return (
Expand Down

0 comments on commit ae5dca1

Please sign in to comment.