From 715d1339147c0d07f16ea81e02e967136daf23f6 Mon Sep 17 00:00:00 2001 From: John Nguyen Date: Fri, 22 Mar 2024 18:24:16 -0400 Subject: [PATCH 1/3] initial commit --- .../(routes)/(protected)/dashboard/page.tsx | 51 ++++++++++++++++--- src/server/dao/team.ts | 34 +++++++++++++ .../protected/team/getTeamInfoProcedure.ts | 16 ++++++ src/server/routers/team.ts | 2 + 4 files changed, 96 insertions(+), 7 deletions(-) create mode 100644 src/server/procedures/protected/team/getTeamInfoProcedure.ts diff --git a/src/app/(main)/(routes)/(protected)/dashboard/page.tsx b/src/app/(main)/(routes)/(protected)/dashboard/page.tsx index f3d1fb93..5067484f 100644 --- a/src/app/(main)/(routes)/(protected)/dashboard/page.tsx +++ b/src/app/(main)/(routes)/(protected)/dashboard/page.tsx @@ -1,3 +1,13 @@ +import { + Card, + CardContent, + CardDescription, + CardHeader, + CardTitle, +} from "@/app/_components/ui/card"; +import { serverTRPC } from "@/app/_trpc/server"; +import { composeServerComponentClient } from "@/server/lib/supabase/server"; +import { getUser } from "@/shared/supabase/auth"; import { type Metadata } from "next"; export const metadata: Metadata = { @@ -5,14 +15,41 @@ export const metadata: Metadata = { description: "Overview your progress within the competition.", }; -export default function DashboardPage() { +export default async function DashboardPage() { + const supabase = composeServerComponentClient(); + + const user = await getUser(supabase); + const { team_name, team_join_code, team_points, team_members } = + await serverTRPC.team.get_team_info.query({ + user_uuid: user.id, + }); + return ( -
-
-

- Dashboard -

-
+
+ + + User + + + + + Team + + +

General Information

+

Team Name: {team_name}

+

Team Code: {team_join_code}

+

Points: {team_points}

+
+ +

Members

+ {team_members.map((member, index) => ( +

+ {member.user_display_name} +

+ ))} +
+
); } diff --git a/src/server/dao/team.ts b/src/server/dao/team.ts index 9e51b34a..405ea93b 100644 --- a/src/server/dao/team.ts +++ b/src/server/dao/team.ts @@ -142,3 +142,37 @@ export async function joinTeam( }); } } + +export async function getTeamInfo(db: Database, user_uuid: string) { + try { + const teamUUID = await db.query.app_user_profile.findFirst({ + columns: { user_team_uuid: true }, + where: (user_data, { eq }) => eq(user_data.user_uuid, user_uuid), + }); + + const teamGeneralInfo = await db.query.app_team.findFirst({ + columns: { + team_name: true, + team_join_code: true, + team_points: true, + }, + where: (team_data, { eq }) => + eq(team_data.team_uuid, teamUUID!.user_team_uuid!), + }); + + const teamMembers = await db.query.app_user_profile.findMany({ + columns: { + user_display_name: true, + }, + where: (user_data, { eq }) => + eq(user_data.user_team_uuid, teamUUID!.user_team_uuid!), + }); + + return { teamGeneralInfo, teamMembers }; + } catch (error) { + throw new TRPCError({ + message: "The database has encountered some issues.", + code: "INTERNAL_SERVER_ERROR", + }); + } +} diff --git a/src/server/procedures/protected/team/getTeamInfoProcedure.ts b/src/server/procedures/protected/team/getTeamInfoProcedure.ts new file mode 100644 index 00000000..f7e8bead --- /dev/null +++ b/src/server/procedures/protected/team/getTeamInfoProcedure.ts @@ -0,0 +1,16 @@ +import { getTeamInfo } from "@/server/dao/team"; +import { protectedProcedure } from "@/server/trpc"; +import { LookupUserSchema } from "@/server/zod-schemas/user"; + +export default protectedProcedure + .input(LookupUserSchema) + .query(async ({ ctx, input }) => { + const result = await getTeamInfo(ctx.db, input.user_uuid); + + return { + team_name: result.teamGeneralInfo?.team_name, + team_join_code: result.teamGeneralInfo?.team_join_code, + team_points: result.teamGeneralInfo?.team_points, + team_members: result.teamMembers, + }; + }); diff --git a/src/server/routers/team.ts b/src/server/routers/team.ts index a221bf7c..834d371d 100644 --- a/src/server/routers/team.ts +++ b/src/server/routers/team.ts @@ -1,8 +1,10 @@ import createTeamProcedure from "../procedures/protected/team/createTeamProcedure"; +import getTeamInfoProcedure from "../procedures/protected/team/getTeamInfoProcedure"; import joinTeamProcedure from "../procedures/protected/team/joinTeamProcedure"; import { createTRPCRouter } from "../trpc"; export const teamRouter = createTRPCRouter({ join_team: joinTeamProcedure, create_team: createTeamProcedure, + get_team_info: getTeamInfoProcedure, }); From cae2e819c72a13b326309eb7f9b39f46ce3ff150 Mon Sep 17 00:00:00 2001 From: John Nguyen Date: Fri, 22 Mar 2024 20:47:45 -0400 Subject: [PATCH 2/3] remove user card --- .../(routes)/(protected)/dashboard/page.tsx | 37 +++++++++---------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/src/app/(main)/(routes)/(protected)/dashboard/page.tsx b/src/app/(main)/(routes)/(protected)/dashboard/page.tsx index 5067484f..0668b8db 100644 --- a/src/app/(main)/(routes)/(protected)/dashboard/page.tsx +++ b/src/app/(main)/(routes)/(protected)/dashboard/page.tsx @@ -1,7 +1,6 @@ import { Card, CardContent, - CardDescription, CardHeader, CardTitle, } from "@/app/_components/ui/card"; @@ -25,29 +24,27 @@ export default async function DashboardPage() { }); return ( -
- - - User - - +
Team - -

General Information

-

Team Name: {team_name}

-

Team Code: {team_join_code}

-

Points: {team_points}

-
- -

Members

- {team_members.map((member, index) => ( -

- {member.user_display_name} -

- ))} + +
+

General Information

+

Team Name: {team_name}

+

Team Code: {team_join_code}

+

Points: {team_points}

+
+ +
+

Members

+ {team_members.map((member, index) => ( +

+ {member.user_display_name} +

+ ))} +
From d7bbb321d189cb29cef999825035e259b24854fd Mon Sep 17 00:00:00 2001 From: Dinesh Umasankar Date: Sat, 23 Mar 2024 00:18:10 -0400 Subject: [PATCH 3/3] Remove unused imports --- src/app/_components/onboarding/support-us-form.tsx | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/app/_components/onboarding/support-us-form.tsx b/src/app/_components/onboarding/support-us-form.tsx index 820a4e09..b214ef7a 100644 --- a/src/app/_components/onboarding/support-us-form.tsx +++ b/src/app/_components/onboarding/support-us-form.tsx @@ -21,7 +21,6 @@ import { FormLabel, } from "../ui/form"; import { cn } from "@/app/_lib/client-utils"; -import NumberStepper from "./number-stepper"; import { Switch } from "../ui/switch"; import { Button } from "../ui/button"; import { Icons } from "../ui/icons"; @@ -85,7 +84,7 @@ export default function SupportUsForm({ control={form.control} name="user_support_administrative" render={({ field }) => ( - +
Administrative @@ -107,7 +106,7 @@ export default function SupportUsForm({ control={form.control} name="user_support_technical" render={({ field }) => ( - +
Technical @@ -131,7 +130,7 @@ export default function SupportUsForm({ disabled={form.formState.isSubmitting} > {form.formState.isSubmitting && ( - + )} Next