@@ -7,36 +7,72 @@ import { SessionTile } from "@/components/session";
7
7
import ListCard from "@/components/ListCard" ;
8
8
import List from "@/components/List" ;
9
9
import 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" ;
10
17
11
18
const N_SESSION_TILES = 3 ;
12
19
const N_COMPANY_TILES = 6 ;
13
20
const N_SPEAKER_TILES = 6 ;
21
+ const SPIN_WHEEL_MAXIMUM = 10 ;
14
22
15
23
export default async function Home ( ) {
24
+ const session = ( await getServerSession ( authOptions ) ) ! ;
25
+ const user = await UserService . getMe ( session . cannonToken ) ;
26
+ if ( ! user ) return < UserSignOut /> ;
27
+
16
28
const eventSessions = await SessionService . getSessions ( ) ;
17
29
const companies = await CompanyService . getCompanies ( ) ;
18
30
const speakers = await SpeakerService . getSpeakers ( ) ;
19
31
20
32
// choose upcoming sessions
21
- let upcomingSessions : SINFOSession [ ] = eventSessions
33
+ const upcomingSessions : SINFOSession [ ] = eventSessions
22
34
? eventSessions
23
35
. filter ( ( s ) => new Date ( s . date ) >= new Date ( ) )
24
36
. sort ( ( a , b ) => new Date ( a . date ) . getTime ( ) - new Date ( b . date ) . getTime ( ) )
25
37
. slice ( 0 , N_SESSION_TILES )
26
38
: [ ] ;
27
39
28
40
// choose random companies
29
- let highlightedCompanies : Company [ ] = companies
41
+ const highlightedCompanies : Company [ ] = companies
30
42
? companies . sort ( ( ) => Math . random ( ) - 0.5 ) . slice ( 0 , N_COMPANY_TILES )
31
43
: [ ] ;
32
44
33
45
// choose random speakers
34
- let highlightedSpeakers : Speaker [ ] = speakers
46
+ const highlightedSpeakers : Speaker [ ] = speakers
35
47
? speakers . sort ( ( ) => Math . random ( ) - 0.5 ) . slice ( 0 , N_SPEAKER_TILES )
36
48
: [ ] ;
37
49
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
+
38
56
return (
39
57
< 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
+
40
76
{ /* Upcoming Sessions */ }
41
77
< List title = "Next Up" link = "/schedule?day=today" linkText = "See all" >
42
78
{ upcomingSessions . length > 0 ? (
@@ -45,6 +81,7 @@ export default async function Home() {
45
81
< ListCard title = "Nothing to show" />
46
82
) }
47
83
</ List >
84
+
48
85
{ /* Highlighted Companies */ }
49
86
< GridList
50
87
title = "Companies"
@@ -60,6 +97,7 @@ export default async function Home() {
60
97
< ListCard title = "Nothing to show" />
61
98
) }
62
99
</ GridList >
100
+
63
101
{ /* Highlighted Speakers */ }
64
102
< GridList title = "Speakers" link = "/speakers" linkText = "See all" scrollable >
65
103
{ highlightedSpeakers . length > 0 ? (
0 commit comments