From 02c1165640847a47bd91c3b0cec08b2ba9036223 Mon Sep 17 00:00:00 2001 From: Jiong Yan Yap Date: Sat, 9 Nov 2024 00:16:47 -0800 Subject: [PATCH] Redirect participants + volunteers, sponsor invites --- apps/dashboard/pages/index.tsx | 8 +++++++- apps/sso/pages/api/update-role/[userId].ts | 10 +++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/apps/dashboard/pages/index.tsx b/apps/dashboard/pages/index.tsx index 31495e11..4cb361b0 100644 --- a/apps/dashboard/pages/index.tsx +++ b/apps/dashboard/pages/index.tsx @@ -97,6 +97,9 @@ export function Index({ appsOpen, waitlistOpen }: ServerSideProps) { !rsvpFormOpen ) { return ; + } else if (user.attendanceConfirmed === true) { + router.push('/leaderboard'); + return <>; } return ( @@ -107,7 +110,10 @@ export function Index({ appsOpen, waitlistOpen }: ServerSideProps) { } else if (user.role === HibiscusRole.JUDGE) { window.location.replace('https://podium.hacksc.com'); return <>; - } else if (user.role === HibiscusRole.VOLUNTEER) return ; + } else if (user.role === HibiscusRole.VOLUNTEER) { + router.push('/identity-portal/attendee-event-scan'); + return <>; + } }; return ( diff --git a/apps/sso/pages/api/update-role/[userId].ts b/apps/sso/pages/api/update-role/[userId].ts index f11cffa0..db1c3cf6 100644 --- a/apps/sso/pages/api/update-role/[userId].ts +++ b/apps/sso/pages/api/update-role/[userId].ts @@ -1,4 +1,5 @@ import { HibiscusSupabaseClient } from '@hibiscus/hibiscus-supabase-client'; +import { HibiscusRole } from '@hibiscus/types'; import { NextApiHandler } from 'next'; import { container } from 'tsyringe'; @@ -29,7 +30,7 @@ const handler: NextApiHandler = async (req, res) => { const resRole = await supabase .getClient() .from('user_invites') - .select('role') + .select('role, sponsor_company') .eq('email', email); if (resRole.error != null) { @@ -54,6 +55,13 @@ const handler: NextApiHandler = async (req, res) => { return res.status(500).json({ message: resUpdate.error.message }); } + if (role === 3 /* SPONSOR */) { + await supabase.getClient().from('sponsor_user_bridge_company').insert({ + user_id: userIdString, + company_id: resRole.data[0].sponsor_company, + }); + } + return res.status(200).json({ message: 'Success' }); } else { return res.status(405).json({ message: 'Invalid request type.' });