Skip to content

Commit

Permalink
adds query params to /scorecard endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
agnlez committed Dec 19, 2024
1 parent 1fb4958 commit 9fd053b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
5 changes: 0 additions & 5 deletions client/src/containers/overview/table/view/key-costs/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,6 @@ export function KeyCostsTable() {
{
query: {
...filtersToQueryParams(filters),
// fields: TABLE_COLUMNS.map((column) => column.accessorKey),
// ...(sorting.length > 0 && {
// sort: sorting.map((sort) => `${sort.desc ? "" : "-"}${sort.id}`),
// }),
// fields: [''],
pageNumber: pagination.pageIndex + 1,
pageSize: pagination.pageSize,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import { useState } from "react";

import { ChevronDownIcon, ChevronUpIcon } from "@radix-ui/react-icons";
import { projectScorecardQuerySchema } from "@shared/contracts/projects.contract";
import { ProjectScorecardView } from "@shared/entities/project-scorecard.view";
import { keepPreviousData } from "@tanstack/react-query";
import {
Expand All @@ -14,6 +15,7 @@ import {
} from "@tanstack/react-table";
import { useAtom } from "jotai";
import { ChevronsUpDownIcon } from "lucide-react";
import { z } from "zod";

import { client } from "@/lib/query-client";
import { queryKeys } from "@/lib/query-keys";
Expand Down Expand Up @@ -45,6 +47,8 @@ import TablePagination, {

import { scorecardFiltersSchema } from "./schema";

type sortFields = z.infer<typeof projectScorecardQuerySchema.shape.sort>;

export function ScoredCardPrioritizationTable() {
const [tableView] = useTableView();
const [filters] = useGlobalFilters();
Expand All @@ -70,7 +74,16 @@ export function ScoredCardPrioritizationTable() {
queryKey,
{
query: {
filter: filtersToQueryParams(filters),
...filtersToQueryParams(filters),
costRange: filters.costRange,
abatementPotentialRange: filters.abatementPotentialRange,
costRangeSelector: filters.costRangeSelector,
partialProjectName: filters.keyword,
...(sorting.length > 0 && {
sort: sorting.map(
(sort) => `${sort.desc ? "" : "-"}${sort.id}`,
) as sortFields,
}),
pageNumber: pagination.pageIndex + 1,
pageSize: pagination.pageSize,
},
Expand Down
4 changes: 1 addition & 3 deletions shared/contracts/projects.contract.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { ProjectScorecard } from "./../entities/project-scorecard.entity";
import { initContract } from "@ts-rest/core";
import { z } from "zod";
import {
Expand All @@ -17,7 +16,6 @@ import { ProjectScorecardDto } from "@shared/dtos/projects/project-scorecard.dto
const contract = initContract();

export type ProjectType = Omit<Project, keyof BaseEntity>;
export type ProjectScorecardType = Omit<ProjectScorecard, keyof BaseEntity>;

export const otherParams = z.object({
costRange: z.coerce.number().array().optional(),
Expand All @@ -28,7 +26,7 @@ export const otherParams = z.object({
});
export const projectsQuerySchema = generateEntityQuerySchema(Project);
export const projectScorecardQuerySchema =
generateEntityQuerySchema(ProjectScorecard);
generateEntityQuerySchema(ProjectScorecardView);

export const getProjectsQuerySchema = projectsQuerySchema.merge(otherParams);
export const getProjectScorecardQuerySchema =
Expand Down

0 comments on commit 9fd053b

Please sign in to comment.