File tree Expand file tree Collapse file tree 7 files changed +48
-22
lines changed Expand file tree Collapse file tree 7 files changed +48
-22
lines changed Original file line number Diff line number Diff line change @@ -11,19 +11,19 @@ export default function StandDetails({ standDetails }: StandDetailsProps) {
11
11
{ standDetails ? (
12
12
< >
13
13
< div
14
- className = { `flex flex-col items-center justify-center text-xs ${ standDetails . chairs ? "text-sinfo-primary" : "text-gray-300" } ` }
14
+ className = { `w-[25%] flex flex-col items-center justify-center text-xs ${ standDetails . chairs ? "text-sinfo-primary" : "text-gray-300" } ` }
15
15
>
16
16
< Armchair size = { 48 } strokeWidth = { standDetails . chairs > 0 ? 2 : 1 } />
17
17
< span > { standDetails . chairs } Chairs</ span >
18
18
</ div >
19
19
< div
20
- className = { `flex flex-col items-center justify-center text-xs ${ standDetails . table ? "text-sinfo-primary" : "text-gray-300" } ` }
20
+ className = { `w-[25%] flex flex-col items-center justify-center text-xs ${ standDetails . table ? "text-sinfo-primary" : "text-gray-300" } ` }
21
21
>
22
22
< Dock size = { 48 } strokeWidth = { standDetails . table ? 2 : 1 } />
23
23
< span > { standDetails . table ? "Want table" : "No table" } </ span >
24
24
</ div >
25
25
< div
26
- className = { `flex flex-col items-center justify-center text-xs ${ standDetails . lettering ? "text-sinfo-primary" : "text-gray-300" } ` }
26
+ className = { `w-[25%] flex flex-col items-center justify-center text-xs ${ standDetails . lettering ? "text-sinfo-primary" : "text-gray-300" } ` }
27
27
>
28
28
< Construction
29
29
size = { 48 }
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ import Link from "next/link";
12
12
import { getServerSession } from "next-auth" ;
13
13
import authOptions from "@/app/api/auth/[...nextauth]/authOptions" ;
14
14
import { UserService } from "@/services/UserService" ;
15
- import { isCompany , isToday } from "@/utils/utils" ;
15
+ import { getUserActiveSignatureData , isAttendee } from "@/utils/utils" ;
16
16
import UserSignOut from "@/components/UserSignOut" ;
17
17
import { SPIN_WHEEL_MAXIMUM } from "@/constants" ;
18
18
import { EventService } from "@/services/EventService" ;
@@ -49,11 +49,9 @@ export default async function Home() {
49
49
? speakers . sort ( ( ) => Math . random ( ) - 0.5 ) . slice ( 0 , N_SPEAKER_TILES )
50
50
: [ ] ;
51
51
52
- const spinWheelData = user . signatures ?. find (
53
- ( s ) => s . edition === event ?. id && isToday ( s . day )
54
- ) ;
52
+ const spinWheelData = getUserActiveSignatureData ( user , event ?. id ?? `` ) ;
55
53
const showSpinWheelSection =
56
- ! isCompany ( user . role ) && ! spinWheelData ?. redeemed ;
54
+ isAttendee ( user . role ) && ! spinWheelData ?. redeemed ;
57
55
58
56
return (
59
57
< div className = "container mx-auto" >
Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ export default async function Profile() {
25
25
26
26
const achievements = await AchievementService . getAchievements ( ) ;
27
27
const userAchievements = achievements ?. filter ( ( a ) =>
28
- a . users ?. includes ( user . id ) ,
28
+ a . users ?. includes ( user . id )
29
29
) ;
30
30
31
31
const userConnections = await UserService . getConnections ( session . cannonToken ) ;
@@ -70,10 +70,9 @@ export default async function Profile() {
70
70
) : (
71
71
< ListCard
72
72
title = "Start winning achievements"
73
- subtitle = "Click here to know more"
73
+ subtitle = "Click to know more"
74
74
link = "/profile/achievements"
75
75
icon = { Award }
76
- extraClassName = "!bg-sinfo-primary !text-white"
77
76
/>
78
77
) }
79
78
</ GridList >
Original file line number Diff line number Diff line change @@ -8,24 +8,22 @@ import { SPIN_WHEEL_MAXIMUM } from "@/constants";
8
8
import { CompanyService } from "@/services/CompanyService" ;
9
9
import { EventService } from "@/services/EventService" ;
10
10
import { UserService } from "@/services/UserService" ;
11
- import { isCompany , isToday } from "@/utils/utils" ;
11
+ import { getUserActiveSignatureData , isAttendee } from "@/utils/utils" ;
12
12
import { getServerSession } from "next-auth" ;
13
13
14
14
export default async function Spin ( ) {
15
15
const session = ( await getServerSession ( authOptions ) ) ! ;
16
16
const user = await UserService . getMe ( session . cannonToken ) ;
17
17
if ( ! user ) return < UserSignOut /> ;
18
18
19
- if ( isCompany ( user . role ) ) {
19
+ if ( ! isAttendee ( user . role ) ) {
20
20
return (
21
21
< BlankPageWithMessage message = "You're not eligible to spin the wheel." />
22
22
) ;
23
23
}
24
24
25
25
const event = await EventService . getLatest ( ) ;
26
- const spinWheelData = user . signatures ?. find (
27
- ( s ) => s . edition === event ?. id && isToday ( s . day )
28
- ) ;
26
+ const spinWheelData = getUserActiveSignatureData ( user , event ?. id ?? `` ) ;
29
27
30
28
if ( spinWheelData ?. redeemed ) {
31
29
return (
Original file line number Diff line number Diff line change 1
1
"use client" ;
2
2
3
- import { isCompany , isMember , isToday } from "@/utils/utils" ;
3
+ import {
4
+ getUserActiveSignatureData ,
5
+ isAttendee ,
6
+ isMember ,
7
+ } from "@/utils/utils" ;
4
8
import { FerrisWheel } from "lucide-react" ;
5
9
import { ProfileButtonProps } from "." ;
6
10
import { UserService } from "@/services/UserService" ;
@@ -18,14 +22,12 @@ export default function ValidateSpinButton({
18
22
if (
19
23
user . id === otherUser . id ||
20
24
! isMember ( user . role ) ||
21
- isCompany ( otherUser . role )
25
+ ! isAttendee ( otherUser . role )
22
26
) {
23
27
return < > </ > ;
24
28
}
25
29
26
- const spinWheelData = otherUser . signatures ?. find (
27
- ( s ) => s . edition === edition && isToday ( s . day )
28
- ) ;
30
+ const spinWheelData = getUserActiveSignatureData ( otherUser , edition ?? `` ) ;
29
31
30
32
const isEligible =
31
33
( spinWheelData &&
Original file line number Diff line number Diff line change @@ -125,7 +125,7 @@ export default function CurriculumVitae({
125
125
< >
126
126
< MessageCard
127
127
type = "info"
128
- content = "By submitting your CV you are accepting the Terms and Conditions. Click here to know more."
128
+ content = "By submitting your CV you are accepting the Terms and Conditions. Click to know more."
129
129
onClick = { ( ) => router . push ( "/terms-and-conditions/cv" ) }
130
130
/>
131
131
< div className = "relative flex flex-col justify-center items-center text-center p-4 gap-y-2 rounded-md outline-dashed outline-sinfo-primary text-sinfo-primary mt-2" >
Original file line number Diff line number Diff line change @@ -14,6 +14,11 @@ export function convertToAppRole(role: string): UserRole {
14
14
}
15
15
}
16
16
17
+ export function isAttendee ( role : string ) : boolean {
18
+ const appRole = convertToAppRole ( role ) ;
19
+ return appRole === "Attendee" ;
20
+ }
21
+
17
22
export function isMember ( role : string ) : boolean {
18
23
const appRole = convertToAppRole ( role ) ;
19
24
return appRole === "Member" || appRole === "Admin" ;
@@ -146,3 +151,27 @@ export function getSessionColor(sessionKind: string) {
146
151
return "#000" ;
147
152
}
148
153
}
154
+
155
+ export function getUserActiveSignatureData ( user : User , edition : string ) {
156
+ let relevantSignatures = user . signatures ?. find (
157
+ ( s ) => s . edition === edition && isToday ( s . day )
158
+ ) ;
159
+ if ( ! relevantSignatures ) return null ;
160
+
161
+ const singatureMap : { [ key : string ] : SINFOSignature } = { } ;
162
+ relevantSignatures . signatures . map ( ( s ) => {
163
+ const curr = singatureMap [ s . companyId ] ;
164
+ if ( ! curr ) {
165
+ singatureMap [ s . companyId ] = s ;
166
+ return ;
167
+ }
168
+ if ( new Date ( s . date ) < new Date ( curr . date ) ) {
169
+ singatureMap [ s . date ] = s ;
170
+ }
171
+ } ) ;
172
+
173
+ return {
174
+ ...relevantSignatures ,
175
+ signatures : Object . values ( singatureMap ) ,
176
+ } ;
177
+ }
You can’t perform that action at this time.
0 commit comments