@@ -7,36 +7,72 @@ import { SessionTile } from "@/components/session";
77import ListCard from "@/components/ListCard" ;
88import List from "@/components/List" ;
99import GridList from "@/components/GridList" ;
10+ import ProgressBar from "@/components/ProgressBar" ;
11+ import Link from "next/link" ;
12+ import { getServerSession } from "next-auth" ;
13+ import authOptions from "@/app/api/auth/[...nextauth]/authOptions" ;
14+ import { UserService } from "@/services/UserService" ;
15+ import { isCompany , isToday } from "@/utils/utils" ;
16+ import UserSignOut from "@/components/UserSignOut" ;
1017
1118const N_SESSION_TILES = 3 ;
1219const N_COMPANY_TILES = 6 ;
1320const N_SPEAKER_TILES = 6 ;
21+ const SPIN_WHEEL_MAXIMUM = 10 ;
1422
1523export default async function Home ( ) {
24+ const session = ( await getServerSession ( authOptions ) ) ! ;
25+ const user = await UserService . getMe ( session . cannonToken ) ;
26+ if ( ! user ) return < UserSignOut /> ;
27+
1628 const eventSessions = await SessionService . getSessions ( ) ;
1729 const companies = await CompanyService . getCompanies ( ) ;
1830 const speakers = await SpeakerService . getSpeakers ( ) ;
1931
2032 // choose upcoming sessions
21- let upcomingSessions : SINFOSession [ ] = eventSessions
33+ const upcomingSessions : SINFOSession [ ] = eventSessions
2234 ? eventSessions
2335 . filter ( ( s ) => new Date ( s . date ) >= new Date ( ) )
2436 . sort ( ( a , b ) => new Date ( a . date ) . getTime ( ) - new Date ( b . date ) . getTime ( ) )
2537 . slice ( 0 , N_SESSION_TILES )
2638 : [ ] ;
2739
2840 // choose random companies
29- let highlightedCompanies : Company [ ] = companies
41+ const highlightedCompanies : Company [ ] = companies
3042 ? companies . sort ( ( ) => Math . random ( ) - 0.5 ) . slice ( 0 , N_COMPANY_TILES )
3143 : [ ] ;
3244
3345 // choose random speakers
34- let highlightedSpeakers : Speaker [ ] = speakers
46+ const highlightedSpeakers : Speaker [ ] = speakers
3547 ? speakers . sort ( ( ) => Math . random ( ) - 0.5 ) . slice ( 0 , N_SPEAKER_TILES )
3648 : [ ] ;
3749
50+ const spinWheelData = user . signatures ?. find (
51+ ( s ) => s . edition === process . env . EVENT_EDITION && isToday ( s . day )
52+ ) ;
53+ const showSpinWheelSection =
54+ ! isCompany ( user . role ) && ! spinWheelData ?. redeemed ;
55+
3856 return (
3957 < div className = "container mx-auto" >
58+ { /* Spin the Wheel Section */ }
59+ { showSpinWheelSection && (
60+ < ProgressBar
61+ current = { spinWheelData ?. signatures . length ?? 0 }
62+ maximum = { SPIN_WHEEL_MAXIMUM }
63+ title = "Companies Visited Today"
64+ className = "pb-2"
65+ >
66+ < div className = "text-xs text-gray-600" >
67+ Visit { SPIN_WHEEL_MAXIMUM } companies for a chance to spin the wheel
68+ and win exciting prizes!
69+ < Link href = { "/spin" } className = "text-link" >
70+ See more
71+ </ Link >
72+ </ div >
73+ </ ProgressBar >
74+ ) }
75+
4076 { /* Upcoming Sessions */ }
4177 < List title = "Next Up" link = "/schedule?day=today" linkText = "See all" >
4278 { upcomingSessions . length > 0 ? (
@@ -45,6 +81,7 @@ export default async function Home() {
4581 < ListCard title = "Nothing to show" />
4682 ) }
4783 </ List >
84+
4885 { /* Highlighted Companies */ }
4986 < GridList
5087 title = "Companies"
@@ -60,6 +97,7 @@ export default async function Home() {
6097 < ListCard title = "Nothing to show" />
6198 ) }
6299 </ GridList >
100+
63101 { /* Highlighted Speakers */ }
64102 < GridList title = "Speakers" link = "/speakers" linkText = "See all" scrollable >
65103 { highlightedSpeakers . length > 0 ? (
0 commit comments