Skip to content

Commit 4b36507

Browse files
authored
Hmt fixes 2 (#222)
1 parent d95bc1a commit 4b36507

File tree

6 files changed

+29
-39
lines changed

6 files changed

+29
-39
lines changed

src/components/Dashboard/UserBasedNav.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import Link from "next/link";
44
import { useState } from "react";
5-
import { useUser } from "@/components/contexts/UserContext";
5+
import { useUserDetails } from "@/components/contexts/UserDetailsContext";
66

77
interface NavItem {
88
name: string;
@@ -98,13 +98,13 @@ function GenericNav({ navItems }: { navItems: NavItem[] }) {
9898
}
9999

100100
export default function UserBasedNav() {
101-
const { currentUser } = useUser();
101+
const { userDetails } = useUserDetails();
102102

103-
if (!currentUser) {
103+
if (!userDetails) {
104104
return <div className="p-4 text-center">Loading...</div>;
105105
}
106106

107-
const role = currentUser?.role || "Participant";
107+
const role = userDetails?.role || "Participant";
108108
const navItems = navigationMap[role] || navigationMap.Participant;
109109

110110
return <GenericNav navItems={navItems} />;

src/components/LandingPage/AboutEventTile.tsx

Lines changed: 19 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,6 @@ import Image from "next/image";
22
import type { ReactNode } from "react";
33
import { fetchContent } from "@/app/actions";
44

5-
const EVENT_DETAILS_SECTION_STYLES =
6-
"flex w-full flex-col items-center bg-white";
7-
const EVENT_DETAILS_CONTENT_STYLES =
8-
"bg-pastel-pink border-4 border-dark-pink rounded-3xl mt-4 mb-8 xl:mt-8 xl:mb-12 flex flex-col xl:flex-row w-4/5 shadow-[15px_15px_0px_0px_dark-pink]";
9-
const EVENT_IMAGE_CONTAINER_STYLES =
10-
"bg-dark-grey border-b-4 border-dark-pink size-full xl:size-1/2 rounded-t-2xl xl:rounded-tr-none xl:rounded-l-2xl xl:border-b-0 xl:border-r-4 ";
11-
const EVENT_IMAGE_STYLES =
12-
"w-full h-full object-cover rounded-bl-none rounded-t-2xl xl:rounded-tr-none xl:rounded-l-2xl";
13-
const EVENT_DETAILS_CONTAINER_STYLES =
14-
"flex items-center w-full xl:w-1/2 rounded-b-20 md:rounded-bl-none md:rounded-r-2xl";
15-
const EVENT_DETAIL_STYLES = "flex items-center ml-10";
16-
const EVENT_DETAIL_TITLE_STYLES =
17-
"text-lg text-dark-grey font-extrabold leading-tight";
18-
const ICON_CONTAINER_STYLES = "bg-white rounded-xl p-1 m-4";
19-
205
const icons = {
216
date: "/svgs/aboutEventTile/date_icon.svg",
227
location: "/svgs/aboutEventTile/location_icon.svg",
@@ -30,15 +15,20 @@ interface EventDetailProps {
3015
children: ReactNode;
3116
}
3217

33-
const EventDetail = (props: EventDetailProps) => {
34-
const { iconSrc, iconName, children } = props;
35-
18+
const EventDetail = ({ iconSrc, iconName, children }: EventDetailProps) => {
3619
return (
37-
<div className={EVENT_DETAIL_STYLES}>
38-
<div className={ICON_CONTAINER_STYLES}>
39-
<Image src={iconSrc} alt={`${iconName} icon`} width={35} height={35} />
20+
<div className="ml-10 flex items-center">
21+
<div className="m-4 rounded-xl bg-white p-1">
22+
<Image
23+
src={iconSrc || "/placeholder.svg"}
24+
alt={`${iconName} icon`}
25+
width={35}
26+
height={35}
27+
/>
4028
</div>
41-
<h2 className={EVENT_DETAIL_TITLE_STYLES}>{children}</h2>
29+
<h2 className="text-lg font-extrabold leading-tight text-dark-grey">
30+
{children}
31+
</h2>
4232
</div>
4333
);
4434
};
@@ -54,22 +44,22 @@ export default async function AboutEventTile() {
5444
});
5545

5646
return (
57-
<div className={EVENT_DETAILS_SECTION_STYLES}>
58-
<div className={EVENT_DETAILS_CONTENT_STYLES}>
59-
<div className={EVENT_IMAGE_CONTAINER_STYLES}>
47+
<div className="flex w-full flex-col items-center bg-white">
48+
<div className="z-100 mb-8 mt-4 flex w-4/5 flex-row rounded-3xl border-4 border-dark-pink bg-pastel-pink shadow-[15px_15px_0px_0px_dark-pink] xl:mb-12 xl:mt-8">
49+
<div className="relative flex aspect-[16/9] w-full max-w-xl items-center justify-center overflow-hidden rounded-l-2xl bg-dark-grey">
6050
<Image
61-
className={EVENT_IMAGE_STYLES}
6251
src={
6352
eventDetails.locationImage.fields.file?.url
6453
?.toString()
6554
.replace("//", "https://") ?? ""
6655
}
6756
alt={eventDetails.locationName}
68-
width={500}
69-
height={500}
57+
fill
58+
sizes="(max-width: 768px) 100vw, 345px"
59+
priority
7060
/>
7161
</div>
72-
<div className={EVENT_DETAILS_CONTAINER_STYLES}>
62+
<div className="flex w-full items-center rounded-b-20 md:rounded-r-2xl md:rounded-bl-none xl:w-1/2">
7363
<div>
7464
<EventDetail iconSrc={icons.date} iconName="date">
7565
{formattedDate}

src/components/UserProfile/ProfileHeader.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ const RIGHT_SQUIGGLE_STYLES =
1818
export default function ProfileHeader() {
1919
const user = useUser().currentUser;
2020

21-
// console.log(user);
22-
2321
return (
2422
<div className={CONTAINER_STYLES}>
2523
<div className={PROFILE_CONTAINER}>

src/components/contexts/Provider.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ export default function Provider({
2626
},
2727
},
2828
queryCache: new QueryCache({
29-
onError: (error, query) => {
29+
onError: (error) => {
3030
console.error("Query Boundary Caught:", error);
31-
toast.error(`Error loading: ${query.queryKey[0]}`);
31+
// toast.error(`Error loading: ${query.queryKey[0]}`);
3232
},
3333
// onSuccess(data, query) {
3434
// toast.success(`${query.queryKey[0]} loaded`);

src/components/contexts/UserContext.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,11 @@ export function UserContextProvider({ children }: Props) {
6767
const userRole = (
6868
user.tokens?.idToken?.payload["cognito:groups"] as UserType[]
6969
).filter((group) => Object.keys(UserType).includes(group))?.[0];
70-
7170
if (!userRole) {
7271
// Logout User if not in group
7372
signOut();
74-
console.error("User not in group");
7573
}
74+
7675
if (!user.userSub) {
7776
throw new Error("No user");
7877
}

src/components/contexts/UserDetailsContext.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ export function UserDetailsProvider({
2323
const queryKey = ["User"];
2424

2525
async function fetchUserDetails(): Promise<UserDetailsNoFunctions> {
26+
// migh tneed to remove this is a scuffed fix
27+
const currentUser = await getCurrentUser();
28+
if (!currentUser?.userId) return null;
2629
const resp = await fetch("/api/user");
2730
if (!resp || !resp.ok) throw new Error("Failed to fetch user details");
2831
return await resp.json();

0 commit comments

Comments
 (0)