diff --git a/src/client/lib/trpc.ts b/src/client/lib/trpc.ts index 10b65b63..32aea15e 100644 --- a/src/client/lib/trpc.ts +++ b/src/client/lib/trpc.ts @@ -1,4 +1,12 @@ -import { createTRPCReact } from "@trpc/react-query"; +import { + createTRPCReact, + type inferReactQueryProcedureOptions, +} from "@trpc/react-query"; +import type { inferRouterInputs, inferRouterOutputs } from "@trpc/server"; import { AppRouter } from "@/backend/routers/_app"; +export type ReactQueryOptions = inferReactQueryProcedureOptions; +export type RouterInputs = inferRouterInputs; +export type RouterOutputs = inferRouterOutputs; + export const trpc = createTRPCReact(); diff --git a/src/components/benchmarks/BenchmarkAssignmentModal.tsx b/src/components/benchmarks/BenchmarkAssignmentModal.tsx index 2d52868d..0da8e56f 100644 --- a/src/components/benchmarks/BenchmarkAssignmentModal.tsx +++ b/src/components/benchmarks/BenchmarkAssignmentModal.tsx @@ -4,20 +4,18 @@ import { Dialog, DialogTitle, Button, - List, - ListItem, DialogContent, DialogActions, } from "@mui/material"; import { useState, useRef } from "react"; -import $benchmark from "./BenchmarkAssignmentModal.module.css"; -import $button from "@/components/design_system/button/Button.module.css"; import { AssignmentDuration, DurationSelectionStep, } from "./Duration-Selection-Step"; -import DS_Checkbox from "../design_system/checkbox/Checkbox"; +import $button from "@/components/design_system/button/Button.module.css"; +import $benchmark from "./BenchmarkAssignmentModal.module.css"; +import { ParaSelectionStep } from "@/components/benchmarks/ParaSelectionStep"; interface BenchmarkAssignmentModalProps { isOpen: boolean; @@ -25,18 +23,6 @@ interface BenchmarkAssignmentModalProps { benchmark_id: string; } -interface ParaProps { - role: string; - first_name: string; - last_name: string; - email: string; - para_id: string; - case_manager_id: string; - user_id: string; - email_verified_at: Date | null; - image_url: string | null; -} - const STEPS = ["PARA_SELECTION", "DURATION_SELECTION"]; type Step = (typeof STEPS)[number]; @@ -143,38 +129,11 @@ export const BenchmarkAssignmentModal = ( ))} {currentModalSelection === "PARA_SELECTION" && ( - -

Select one or more paras:

- - - {myParas - ?.filter((para): para is ParaProps => para !== undefined) - .map((para) => ( - - - - ))} - - -
+ )} {currentModalSelection === "DURATION_SELECTION" && ( diff --git a/src/components/benchmarks/ParaSelectionStep.tsx b/src/components/benchmarks/ParaSelectionStep.tsx new file mode 100644 index 00000000..39f7a9a5 --- /dev/null +++ b/src/components/benchmarks/ParaSelectionStep.tsx @@ -0,0 +1,51 @@ +import { Box, List, ListItem } from "@mui/material"; +import $benchmark from "./BenchmarkAssignmentModal.module.css"; +import { RouterOutputs } from "@/client/lib/trpc"; +import DS_Checkbox from "@/components/design_system/checkbox/Checkbox"; + +interface ParaSelectionStepProps { + myParas: RouterOutputs["case_manager"]["getMyParas"] | undefined; + selectedParaIds: string[]; + handleParaToggle: (paraId: string) => () => void; +} + +export const ParaSelectionStep = ({ + myParas, + selectedParaIds, + handleParaToggle, +}: ParaSelectionStepProps) => { + return ( + +

Select one or more paras:

+ + + {myParas + ?.filter((para) => para !== undefined) + .map((para) => ( + + + + ))} + + +
+ ); +};