Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/app/(authenticated)/companies/[id]/StandDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@ export default function StandDetails({ standDetails }: StandDetailsProps) {
{standDetails ? (
<>
<div
className={`flex flex-col items-center justify-center text-xs ${standDetails.chairs ? "text-sinfo-primary" : "text-gray-300"}`}
className={`w-[25%] flex flex-col items-center justify-center text-xs ${standDetails.chairs ? "text-sinfo-primary" : "text-gray-300"}`}
>
<Armchair size={48} strokeWidth={standDetails.chairs > 0 ? 2 : 1} />
<span>{standDetails.chairs} Chairs</span>
</div>
<div
className={`flex flex-col items-center justify-center text-xs ${standDetails.table ? "text-sinfo-primary" : "text-gray-300"}`}
className={`w-[25%] flex flex-col items-center justify-center text-xs ${standDetails.table ? "text-sinfo-primary" : "text-gray-300"}`}
>
<Dock size={48} strokeWidth={standDetails.table ? 2 : 1} />
<span>{standDetails.table ? "Want table" : "No table"}</span>
</div>
<div
className={`flex flex-col items-center justify-center text-xs ${standDetails.lettering ? "text-sinfo-primary" : "text-gray-300"}`}
className={`w-[25%] flex flex-col items-center justify-center text-xs ${standDetails.lettering ? "text-sinfo-primary" : "text-gray-300"}`}
>
<Construction
size={48}
Expand Down
8 changes: 3 additions & 5 deletions src/app/(authenticated)/home/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import Link from "next/link";
import { getServerSession } from "next-auth";
import authOptions from "@/app/api/auth/[...nextauth]/authOptions";
import { UserService } from "@/services/UserService";
import { isCompany, isToday } from "@/utils/utils";
import { getUserActiveSignatureData, isAttendee } from "@/utils/utils";
import UserSignOut from "@/components/UserSignOut";
import { SPIN_WHEEL_MAXIMUM } from "@/constants";
import { EventService } from "@/services/EventService";
Expand Down Expand Up @@ -49,11 +49,9 @@ export default async function Home() {
? speakers.sort(() => 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 (
<div className="container mx-auto">
Expand Down
8 changes: 3 additions & 5 deletions src/app/(authenticated)/profile/edit/EditProfileForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -590,11 +590,9 @@ export default function EditProfileForm({
</fieldset>
</div>

<button
className="bg-sinfo-primary text-white rounded-full p-4 fixed mb-navbar bottom-4 right-4 disabled:opacity-75"
type="submit"
>
<Save size={32} />
<button className="button-primary" type="submit">
<Save size={16} />
Save profile
</button>
</form>
);
Expand Down
5 changes: 2 additions & 3 deletions src/app/(authenticated)/profile/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -70,10 +70,9 @@ export default async function Profile() {
) : (
<ListCard
title="Start winning achievements"
subtitle="Click here to know more"
subtitle="Click to know more"
link="/profile/achievements"
icon={Award}
extraClassName="!bg-sinfo-primary !text-white"
/>
)}
</GridList>
Expand Down
8 changes: 3 additions & 5 deletions src/app/(authenticated)/spin/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,22 @@ 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() {
const session = (await getServerSession(authOptions))!;
const user = await UserService.getMe(session.cannonToken);
if (!user) return <UserSignOut />;

if (isCompany(user.role)) {
if (!isAttendee(user.role)) {
return (
<BlankPageWithMessage message="You're not eligible to spin the wheel." />
);
}

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 (
Expand Down
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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 &&
Expand Down
8 changes: 5 additions & 3 deletions src/components/Toolbar/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,19 @@ export default function Sidebar({ show, onClose }: SidebarProps) {
</Link>
</div>
<div className="flex flex-col gap-2">
<Link href="/venue" onClick={onClose}>
Venue
</Link>
<Link href="/speakers" onClick={onClose}>
Speakers
</Link>
<Link href="/companies" onClick={onClose}>
Companies
</Link>
<Link href="/venue" onClick={onClose}>
Venue
<Link href="/prizes" onClick={onClose}>
Prizes
</Link>
</div>
<div></div>
</div>
<div className="flex-1" />

Expand Down
2 changes: 1 addition & 1 deletion src/components/user/CurriculumVitae.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export default function CurriculumVitae({
<>
<MessageCard
type="info"
content="By submitting your CV you are accepting the Terms and Conditions. Click here to know more."
content="By submitting your CV you are accepting the Terms and Conditions. Click to know more."
onClick={() => router.push("/terms-and-conditions/cv")}
/>
<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">
Expand Down
6 changes: 3 additions & 3 deletions src/styles/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@
transform: translate(-150%, -150%);
opacity: 0;
}
5% {
10% {
transform: translate(150%, 150%);
opacity: 1;
}
10% {
20% {
opacity: 0;
}
100% {
Expand All @@ -74,5 +74,5 @@
);
transform: translate(-150%, -150%);
opacity: 0;
animation: shine 30s infinite linear;
animation: shine 15s infinite linear;
}
29 changes: 29 additions & 0 deletions src/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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),
};
}