- {coupons.map((c) => (
+ {data.coupons.map((c) => (
Offers
- {offers.map((o) => (
- -
- {o.title} — {o.desc}
+ {data.offers.map((o) => (
+
-
+ {o.title} — {o.description}
))}
@@ -115,14 +129,14 @@ export default function UserPage() {
fontSize: '1.25rem',
}}
>
- LaHuascaGuest2026
+ {data.wifiPassword}
Member Benefits
- {benefits.map((b) => (
+ {data.benefits.map((b) => (
- {b}
))}
diff --git a/src/components/MeasuredText.tsx b/src/components/MeasuredText.tsx
index bd3b52d..380621e 100644
--- a/src/components/MeasuredText.tsx
+++ b/src/components/MeasuredText.tsx
@@ -1,7 +1,7 @@
'use client';
import { useEffect, useRef, useState } from 'react';
-import { measureText } from '@chenglou/pretext';
+import { prepare, layout } from '@chenglou/pretext';
interface MeasuredTextProps {
text: string;
@@ -9,21 +9,17 @@ interface MeasuredTextProps {
export default function MeasuredText({ text }: MeasuredTextProps) {
const ref = useRef(null);
- const [width, setWidth] = useState(null);
+ const [height, setHeight] = useState(null);
useEffect(() => {
if (!ref.current) return;
const style = window.getComputedStyle(ref.current);
- const measured = measureText(text, {
- font: {
- family: style.fontFamily.split(',')[0].replace(/['"]/g, ''),
- size: parseFloat(style.fontSize),
- weight: style.fontWeight,
- },
- });
+ const font = `${style.fontWeight} ${style.fontSize} ${style.fontFamily.split(',')[0].replace(/['"]/g, '')}`;
+ const prepared = prepare(text, font);
+ const { height } = layout(prepared, ref.current.offsetWidth, parseFloat(style.lineHeight) || parseFloat(style.fontSize) * 1.2);
- setWidth(measured.width);
+ setHeight(height);
}, [text]);
return (
@@ -31,8 +27,8 @@ export default function MeasuredText({ text }: MeasuredTextProps) {
{text}
- {width !== null && (
- Measured width: {width.toFixed(2)}px
+ {height !== null && (
+ Measured height: {height.toFixed(2)}px
)}
);
diff --git a/src/components/Navbar.tsx b/src/components/Navbar.tsx
index 2d50ecd..a0b463d 100644
--- a/src/components/Navbar.tsx
+++ b/src/components/Navbar.tsx
@@ -2,7 +2,7 @@
import Link from 'next/link';
import { useRouter } from 'next/navigation';
-import { useAuth } from '@/hooks/useAuth';
+import { useEffect, useState } from 'react';
const links = [
{ href: '/', label: 'Home' },
@@ -13,11 +13,19 @@ const links = [
];
export default function Navbar() {
- const { isLoggedIn, logout } = useAuth();
+ const [auth, setAuth] = useState<{ authenticated: boolean; role?: string } | null>(null);
const router = useRouter();
- const handleLogout = () => {
- logout();
+ useEffect(() => {
+ fetch('/api/auth/me', { credentials: 'same-origin' })
+ .then((res) => (res.ok ? res.json() : { authenticated: false }))
+ .then((data) => setAuth(data))
+ .catch(() => setAuth({ authenticated: false }));
+ }, []);
+
+ const handleLogout = async () => {
+ await fetch('/api/auth/logout', { method: 'POST', credentials: 'same-origin' });
+ setAuth({ authenticated: false });
router.push('/login');
};
@@ -47,7 +55,7 @@ export default function Navbar() {
{link.label}
))}
- {isLoggedIn ? (
+ {auth?.authenticated ? (