From 001390711b27d4128040db6a898d42b19d9467af Mon Sep 17 00:00:00 2001 From: Anup Mantri <829820+amantri@users.noreply.github.com> Date: Wed, 14 Feb 2024 10:24:21 -0800 Subject: [PATCH] Add user to the staff list on the frontend instead of the backend (#266) * Add user to the staff list on the frontend instead of the backend * [Closes #221] Update dependencies, resolve all npm audit warnings (#259) * Ran npm audit fix * Remove deprecated @next/font * Replace mockery with rewiremock * Bump nextjs version * Bump typed-css-modules version * Staff page (#269) Co-authored-by: Brandon Cruz-Youll * Add breadcrumbs (#268) * changed placeholder to defaultValue on forms for edit student and edit staff (#276) * added placeholder files and instruction documentation for Design System components and their css modules (#275) * Update button module to override MUI styling and apply to all button instances (#277) * fix secondary button styling on button module and apply to edit button on student page * add button folder with button module to components * change imports for button module * fix edit, cancel, and save buttons on student page * replace button module file in design system button folder and delete previous button folder * replace import statements for button module * change subgoal button to inherit button module styling instead of goal module styling * change assign staff button styling in subgoal to inherit button module styling * update buttons on subgoal assignment modal to inherit button module styling * update border radius and secondary border color in button module * change all button stylings on staff page * changes to button module * prettier fix * update primary variable hex in global css file and update button color to be in accordance with DS * fix prettier in globalcss * remove sx from line 43 of staff/[user_id] and remove all instances of home.bold styling in buttons --------- * Fix cm student id page (#280) * add Goal and Iep components and css from feat-cm-edit-goal * remove css class in Goal.module.css for removed controlCarat class * add flexWrap: wrap to div containing benchmark info in goal to avoid pushing ArrowForwardIosIcon into Add Goal form * run prettier * remove additional unused code and imports from components/goal/Goal * Fix type error --------- Co-authored-by: Francis Li Co-authored-by: Brett Austin Eastman <76603041+BrettEastman@users.noreply.github.com> Co-authored-by: Brandon Cruz-Youll Co-authored-by: Hieu Ngo Co-authored-by: Brandon Cruz-Youll <42663258+BeeSeeWhy@users.noreply.github.com> Co-authored-by: Tessa Thornberry Co-authored-by: Hannah McGowan <73210740+hannahmcg@users.noreply.github.com> Co-authored-by: KCCPMG <39074889+KCCPMG@users.noreply.github.com> --- src/backend/routers/case_manager.test.ts | 12 ++++++------ src/backend/routers/case_manager.ts | 8 +------- src/components/subgoal/Subgoal-Assignment-Modal.tsx | 2 ++ src/pages/staff/index.tsx | 3 ++- 4 files changed, 11 insertions(+), 14 deletions(-) diff --git a/src/backend/routers/case_manager.test.ts b/src/backend/routers/case_manager.test.ts index 6c2ed64f..96fb9373 100644 --- a/src/backend/routers/case_manager.test.ts +++ b/src/backend/routers/case_manager.test.ts @@ -186,7 +186,7 @@ test("getMyParas", async (t) => { }); let myParas = await trpc.case_manager.getMyParas.query(); - t.is(myParas.length, 1); + t.is(myParas.length, 0); await db .insertInto("paras_assigned_to_case_manager") @@ -197,7 +197,7 @@ test("getMyParas", async (t) => { .execute(); myParas = await trpc.case_manager.getMyParas.query(); - t.is(myParas.length, 2); + t.is(myParas.length, 1); }); test("addPara", async (t) => { @@ -206,14 +206,14 @@ test("addPara", async (t) => { }); let myParas = await trpc.case_manager.getMyParas.query(); - t.is(myParas.length, 1); + t.is(myParas.length, 0); await trpc.case_manager.addPara.mutate({ para_id: seed.para.user_id, }); myParas = await trpc.case_manager.getMyParas.query(); - t.is(myParas.length, 2); + t.is(myParas.length, 1); }); test("removePara", async (t) => { @@ -230,12 +230,12 @@ test("removePara", async (t) => { .execute(); let myParas = await trpc.case_manager.getMyParas.query(); - t.is(myParas.length, 2); + t.is(myParas.length, 1); await trpc.case_manager.removePara.mutate({ para_id: seed.para.user_id, }); myParas = await trpc.case_manager.getMyParas.query(); - t.is(myParas.length, 1); + t.is(myParas.length, 0); }); diff --git a/src/backend/routers/case_manager.ts b/src/backend/routers/case_manager.ts index 801feda7..d739a523 100644 --- a/src/backend/routers/case_manager.ts +++ b/src/backend/routers/case_manager.ts @@ -141,12 +141,6 @@ export const case_manager = router({ getMyParas: authenticatedProcedure.query(async (req) => { const { userId } = req.ctx.auth; - const me = await req.ctx.db - .selectFrom("user") - .where("user_id", "=", userId) - .selectAll() - .executeTakeFirst(); - const result = await req.ctx.db .selectFrom("user") .innerJoin( @@ -158,7 +152,7 @@ export const case_manager = router({ .selectAll() .execute(); - return [me, ...result]; + return result; }), addPara: authenticatedProcedure diff --git a/src/components/subgoal/Subgoal-Assignment-Modal.tsx b/src/components/subgoal/Subgoal-Assignment-Modal.tsx index 496a09f6..ec56898d 100644 --- a/src/components/subgoal/Subgoal-Assignment-Modal.tsx +++ b/src/components/subgoal/Subgoal-Assignment-Modal.tsx @@ -33,6 +33,8 @@ interface ParaProps { 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; diff --git a/src/pages/staff/index.tsx b/src/pages/staff/index.tsx index 88b06071..10c39769 100644 --- a/src/pages/staff/index.tsx +++ b/src/pages/staff/index.tsx @@ -5,6 +5,7 @@ import PersonTable, { Para, ParaHeadCell } from "@/components/table/table"; const Staff = () => { const utils = trpc.useContext(); const { data: paras, isLoading } = trpc.case_manager.getMyParas.useQuery(); + const { data: me } = trpc.user.getMe.useQuery(); const createPara = trpc.para.createPara.useMutation({ onSuccess: async (data) => { @@ -59,7 +60,7 @@ const Staff = () => { return (