Skip to content

Commit

Permalink
minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
andresgnlez committed Dec 12, 2024
1 parent 332f3bf commit adb5369
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 11 deletions.
9 changes: 4 additions & 5 deletions client/src/components/ui/score-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@ import { cn } from "@/lib/utils";
interface ScoreIndicatorProps {
className?: string;
children?: React.ReactNode;
bgColorClasses?: Record<PROJECT_SCORE, string>;
}

export const DEFAULT_BG_CLASSES = {
high: "bg-high",
medium: "bg-medium",
low: "bg-low",
export const DEFAULT_BG_CLASSES: Record<PROJECT_SCORE, string> = {
[PROJECT_SCORE.HIGH]: "bg-high",
[PROJECT_SCORE.MEDIUM]: "bg-medium",
[PROJECT_SCORE.LOW]: "bg-low",
};

export const ScoreIndicator = ({
Expand Down
2 changes: 1 addition & 1 deletion client/src/containers/overview/filters/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export default function ProjectsFilters() {
setFiltersOpen((prev) => ({ ...prev, filtersOpen: false }));
};

const { queryKey } = queryKeys.tables.countries;
const { queryKey } = queryKeys.countries.all;
const { data: countryOptions } = client.projects.getProjectCountries.useQuery(
queryKey,
{},
Expand Down
6 changes: 2 additions & 4 deletions client/src/containers/overview/table/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { z } from "zod";

import { filtersSchema } from "@/app/(overview)/url-store";

import { scorecardFiltersSchema } from "./view/scorecard-prioritization/schema";
import { scorecardFiltersSchema } from "@/containers/overview/table/view/scorecard-prioritization/schema";

export const NO_DATA = [];

Expand All @@ -16,8 +16,7 @@ const OMITTED_FIELDS = [
export const filtersToQueryParams = (
filters: z.infer<typeof filtersSchema | typeof scorecardFiltersSchema>,
) => {
debugger;
const queryParams = Object.keys(filters)
return Object.keys(filters)
.filter((key) => !OMITTED_FIELDS.includes(key))
.reduce(
(acc, key) => ({
Expand All @@ -28,5 +27,4 @@ export const filtersToQueryParams = (
}),
{},
);
return queryParams;
};
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { PROJECT_SCORE } from "@shared/entities/project-score.enum";
import { z } from "zod";

// todo: replace this schema with the one coming from create-custom-project.schema.ts once implemented there.
export const scorecardFiltersSchema = z.object({
availabilityOfExperiencedLabor: z.nativeEnum(PROJECT_SCORE).optional(),
availabilityOfAlternatingFunding: z.nativeEnum(PROJECT_SCORE).optional(),
Expand Down
6 changes: 5 additions & 1 deletion client/src/lib/query-keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ export const geometriesKeys = createQueryKeys("geometries", {
all: (filters: z.infer<typeof filtersSchema>) => [filters],
});

export const countriesKeys = createQueryKeys("countries", {
all: null,
});

export const tableKeys = createQueryKeys("tables", {
all: <TFilters extends z.ZodTypeAny>(
tableView: (typeof TABLE_VIEWS)[number],
Expand All @@ -32,12 +36,12 @@ export const tableKeys = createQueryKeys("tables", {
},
) => ["all", tableView, filters],
id: (id: string) => [id],
countries: null,
});

export const queryKeys = mergeQueryKeys(
authKeys,
userKeys,
geometriesKeys,
tableKeys,
countriesKeys,
);

0 comments on commit adb5369

Please sign in to comment.