-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pull out ParaSelectionStep from BenchmarkAssignmentModal
We refactored BenchmarkAssignmentModal to separate out the para selection step. This will allow for more modular frontend unit testing.
- Loading branch information
Showing
3 changed files
with
68 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<AppRouter>; | ||
export type RouterInputs = inferRouterInputs<AppRouter>; | ||
export type RouterOutputs = inferRouterOutputs<AppRouter>; | ||
|
||
export const trpc = createTRPCReact<AppRouter>(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ( | ||
<Box> | ||
<p>Select one or more paras:</p> | ||
<Box | ||
sx={{ | ||
my: 2, | ||
maxHeight: "10rem", | ||
overflow: "auto", | ||
border: "1px solid var(--grey-70)", | ||
borderRadius: 1, | ||
}} | ||
> | ||
<List sx={{ p: 0 }} className={$benchmark.staffListItemText}> | ||
{myParas | ||
?.filter((para) => para !== undefined) | ||
.map((para) => ( | ||
<ListItem | ||
key={para.user_id} | ||
sx={{ | ||
px: 0, | ||
py: 0, | ||
}} | ||
> | ||
<DS_Checkbox | ||
onClickAction={handleParaToggle(para.user_id)} | ||
text={`${para.first_name} ${para.last_name}`} | ||
checked={selectedParaIds.includes(para.user_id)} | ||
/> | ||
</ListItem> | ||
))} | ||
</List> | ||
</Box> | ||
</Box> | ||
); | ||
}; |