diff --git a/src/app/api/user/portal/route.ts b/src/app/api/user/portal/route.ts index eb0ad9c..9caefbd 100644 --- a/src/app/api/user/portal/route.ts +++ b/src/app/api/user/portal/route.ts @@ -42,6 +42,16 @@ export async function GET() { [userId] ); + // Get weather + let weather = undefined; + try { + const weatherRes = await fetch('http://localhost:3000/api/weather'); + if (weatherRes.ok) { + const weatherData = await weatherRes.json(); + weather = weatherData.data; + } + } catch { /* ignore */ } + return NextResponse.json({ reservations, coupons, @@ -49,6 +59,7 @@ export async function GET() { benefits: benefits.map((b: { text: string }) => b.text), wifiPassword, trips, + weather, }); } catch (error) { if ((error as Error).message === 'Unauthorized') { diff --git a/src/app/user/page.tsx b/src/app/user/page.tsx index 6e63268..7bd00bd 100644 --- a/src/app/user/page.tsx +++ b/src/app/user/page.tsx @@ -20,10 +20,16 @@ interface Message { created_at: string; } +interface Weather { + current: { celsius: number; fahrenheit: number; summary: string; windspeed: number; weathercode: number }; + today: { maxC: number; minC: number; maxF: number; minF: number; summary: string; weathercode: number }; +} + interface PortalData { trips: Trip[]; wifiPassword: string; messages: Message[]; + weather?: Weather; } const gold = '#E8A849'; @@ -123,10 +129,39 @@ export default function UserPage() { return (
-

+

Your Portal

+ {/* Weather Widget - Always visible below navbar */} + {data.weather && ( +
+
+
+ {data.weather.current.weathercode <= 1 ? '☀️' : data.weather.current.weathercode === 2 ? '⛅' : data.weather.current.weathercode === 3 ? '☁️' : data.weather.current.weathercode >= 51 && data.weather.current.weathercode <= 55 ? '🌧️' : data.weather.current.weathercode >= 61 ? '🌧️' : '☀️'} +
+
+
{data.weather.current.celsius}°C
+
{data.weather.current.summary}
+
+
+
+
+
High
+
{data.weather.today.maxC}°
+
+
+
Low
+
{data.weather.today.minC}°
+
+
+
Wind
+
{data.weather.current.windspeed} km/h
+
+
+
+ )} + {/* Welcome Message - Show on reservation day */} {activeTrip && (