diff --git a/src/app/(authenticated)/companies/[id]/StandDetails.tsx b/src/app/(authenticated)/companies/[id]/StandDetails.tsx index e4067d7..b5ed2aa 100644 --- a/src/app/(authenticated)/companies/[id]/StandDetails.tsx +++ b/src/app/(authenticated)/companies/[id]/StandDetails.tsx @@ -11,19 +11,19 @@ export default function StandDetails({ standDetails }: StandDetailsProps) { {standDetails ? ( <>
0 ? 2 : 1} /> {standDetails.chairs} Chairs
{standDetails.table ? "Want table" : "No table"}
Math.random() - 0.5).slice(0, N_SPEAKER_TILES) : []; - const spinWheelData = user.signatures?.find( - (s) => s.edition === event?.id && isToday(s.day) - ); + const spinWheelData = getUserActiveSignatureData(user, event?.id ?? ``); const showSpinWheelSection = - !isCompany(user.role) && !spinWheelData?.redeemed; + isAttendee(user.role) && !spinWheelData?.redeemed; return (
diff --git a/src/app/(authenticated)/profile/edit/EditProfileForm.tsx b/src/app/(authenticated)/profile/edit/EditProfileForm.tsx index 7a6a081..78aa970 100644 --- a/src/app/(authenticated)/profile/edit/EditProfileForm.tsx +++ b/src/app/(authenticated)/profile/edit/EditProfileForm.tsx @@ -590,11 +590,9 @@ export default function EditProfileForm({
- ); diff --git a/src/app/(authenticated)/profile/page.tsx b/src/app/(authenticated)/profile/page.tsx index c5d5e8b..0ee7855 100644 --- a/src/app/(authenticated)/profile/page.tsx +++ b/src/app/(authenticated)/profile/page.tsx @@ -25,7 +25,7 @@ export default async function Profile() { const achievements = await AchievementService.getAchievements(); const userAchievements = achievements?.filter((a) => - a.users?.includes(user.id), + a.users?.includes(user.id) ); const userConnections = await UserService.getConnections(session.cannonToken); @@ -70,10 +70,9 @@ export default async function Profile() { ) : ( )} diff --git a/src/app/(authenticated)/spin/page.tsx b/src/app/(authenticated)/spin/page.tsx index 9d5c993..8557735 100644 --- a/src/app/(authenticated)/spin/page.tsx +++ b/src/app/(authenticated)/spin/page.tsx @@ -8,7 +8,7 @@ import { SPIN_WHEEL_MAXIMUM } from "@/constants"; import { CompanyService } from "@/services/CompanyService"; import { EventService } from "@/services/EventService"; import { UserService } from "@/services/UserService"; -import { isCompany, isToday } from "@/utils/utils"; +import { getUserActiveSignatureData, isAttendee } from "@/utils/utils"; import { getServerSession } from "next-auth"; export default async function Spin() { @@ -16,16 +16,14 @@ export default async function Spin() { const user = await UserService.getMe(session.cannonToken); if (!user) return ; - if (isCompany(user.role)) { + if (!isAttendee(user.role)) { return ( ); } const event = await EventService.getLatest(); - const spinWheelData = user.signatures?.find( - (s) => s.edition === event?.id && isToday(s.day) - ); + const spinWheelData = getUserActiveSignatureData(user, event?.id ?? ``); if (spinWheelData?.redeemed) { return ( diff --git a/src/app/(authenticated)/users/[id]/buttons/ValidateSpinButton.tsx b/src/app/(authenticated)/users/[id]/buttons/ValidateSpinButton.tsx index c1666ba..4caaab4 100644 --- a/src/app/(authenticated)/users/[id]/buttons/ValidateSpinButton.tsx +++ b/src/app/(authenticated)/users/[id]/buttons/ValidateSpinButton.tsx @@ -1,6 +1,10 @@ "use client"; -import { isCompany, isMember, isToday } from "@/utils/utils"; +import { + getUserActiveSignatureData, + isAttendee, + isMember, +} from "@/utils/utils"; import { FerrisWheel } from "lucide-react"; import { ProfileButtonProps } from "."; import { UserService } from "@/services/UserService"; @@ -18,14 +22,12 @@ export default function ValidateSpinButton({ if ( user.id === otherUser.id || !isMember(user.role) || - isCompany(otherUser.role) + !isAttendee(otherUser.role) ) { return <>; } - const spinWheelData = otherUser.signatures?.find( - (s) => s.edition === edition && isToday(s.day) - ); + const spinWheelData = getUserActiveSignatureData(otherUser, edition ?? ``); const isEligible = (spinWheelData && diff --git a/src/components/Toolbar/Sidebar.tsx b/src/components/Toolbar/Sidebar.tsx index d4d26ba..b79393f 100644 --- a/src/components/Toolbar/Sidebar.tsx +++ b/src/components/Toolbar/Sidebar.tsx @@ -46,17 +46,19 @@ export default function Sidebar({ show, onClose }: SidebarProps) {
+ + Venue + Speakers Companies - - Venue + + Prizes
-
diff --git a/src/components/user/CurriculumVitae.tsx b/src/components/user/CurriculumVitae.tsx index fbff76d..8036fd9 100644 --- a/src/components/user/CurriculumVitae.tsx +++ b/src/components/user/CurriculumVitae.tsx @@ -125,7 +125,7 @@ export default function CurriculumVitae({ <> router.push("/terms-and-conditions/cv")} />
diff --git a/src/styles/globals.css b/src/styles/globals.css index a87e5cf..57fca3d 100644 --- a/src/styles/globals.css +++ b/src/styles/globals.css @@ -45,11 +45,11 @@ transform: translate(-150%, -150%); opacity: 0; } - 5% { + 10% { transform: translate(150%, 150%); opacity: 1; } - 10% { + 20% { opacity: 0; } 100% { @@ -74,5 +74,5 @@ ); transform: translate(-150%, -150%); opacity: 0; - animation: shine 30s infinite linear; + animation: shine 15s infinite linear; } diff --git a/src/utils/utils.ts b/src/utils/utils.ts index 44d2197..7c315a9 100644 --- a/src/utils/utils.ts +++ b/src/utils/utils.ts @@ -14,6 +14,11 @@ export function convertToAppRole(role: string): UserRole { } } +export function isAttendee(role: string): boolean { + const appRole = convertToAppRole(role); + return appRole === "Attendee"; +} + export function isMember(role: string): boolean { const appRole = convertToAppRole(role); return appRole === "Member" || appRole === "Admin"; @@ -146,3 +151,27 @@ export function getSessionColor(sessionKind: string) { return "#000"; } } + +export function getUserActiveSignatureData(user: User, edition: string) { + let relevantSignatures = user.signatures?.find( + (s) => s.edition === edition && isToday(s.day) + ); + if (!relevantSignatures) return null; + + const singatureMap: { [key: string]: SINFOSignature } = {}; + relevantSignatures.signatures.map((s) => { + const curr = singatureMap[s.companyId]; + if (!curr) { + singatureMap[s.companyId] = s; + return; + } + if (new Date(s.date) < new Date(curr.date)) { + singatureMap[s.date] = s; + } + }); + + return { + ...relevantSignatures, + signatures: Object.values(singatureMap), + }; +}