Skip to content

Commit

Permalink
Redirect participants + volunteers, sponsor invites
Browse files Browse the repository at this point in the history
  • Loading branch information
VictiniX888 committed Nov 9, 2024
1 parent 6df0199 commit 02c1165
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
8 changes: 7 additions & 1 deletion apps/dashboard/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ export function Index({ appsOpen, waitlistOpen }: ServerSideProps) {
!rsvpFormOpen
) {
return <RSVPClosedPlaceholder />;
} else if (user.attendanceConfirmed === true) {
router.push('/leaderboard');
return <></>;
}
return (
<HackerPortal isEventOpen={hackerPortalOpen} appsOpen={appsOpen} />
Expand All @@ -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 <IdentityPortal />;
} else if (user.role === HibiscusRole.VOLUNTEER) {
router.push('/identity-portal/attendee-event-scan');
return <></>;
}
};

return (
Expand Down
10 changes: 9 additions & 1 deletion apps/sso/pages/api/update-role/[userId].ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { HibiscusSupabaseClient } from '@hibiscus/hibiscus-supabase-client';
import { HibiscusRole } from '@hibiscus/types';
import { NextApiHandler } from 'next';
import { container } from 'tsyringe';

Expand Down Expand Up @@ -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) {
Expand All @@ -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.' });
Expand Down

0 comments on commit 02c1165

Please sign in to comment.