Skip to content

Commit

Permalink
Move types to universal types file
Browse files Browse the repository at this point in the history
  • Loading branch information
canjalal committed Nov 4, 2024
1 parent a326e47 commit a19c064
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/pages/benchmarks/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,23 @@ import { useState } from "react";
import $button from "../../components/design_system/button/Button.module.css";
import noBenchmarks from "../../public/img/no-benchmarks.png";
import SearchIcon from "@mui/icons-material/Search";

type SortProperty = "first_name";
type SortDirection = "asc" | "desc";
import { SortDirection, SortProperty } from "@/types/global";

function Benchmarks() {
const [isPara, setIsPara] = useState(false);

const [sortProperty, setSortProperty] = useState<SortProperty>("first_name");
const [sortDirection, setSortDirection] = useState<SortDirection>("asc");

const { data: tasksData, isLoading, error } = trpc.para.getMyTasks.useQuery();
const { data: tasksData, isLoading } = trpc.para.getMyTasks.useQuery();

const handleTogglePara = () => {
setIsPara(!isPara);
};

const getSortedTasks = () => {
if (!tasksData) return [];

return [...tasksData].sort((a, b) => {
if (a[sortProperty] < b[sortProperty])
return sortDirection === "asc" ? -1 : 1;
Expand Down
3 changes: 3 additions & 0 deletions src/types/global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ export type Goal = SelectableForTable<"goal">;
export type Benchmark = SelectableForTable<"benchmark">;
export type ChangeEvent = React.ChangeEvent<HTMLInputElement>;
export type FormEvent = React.FormEvent<HTMLFormElement>;

export type SortProperty = "first_name";
export type SortDirection = "asc" | "desc";

0 comments on commit a19c064

Please sign in to comment.