fixed elapsed timer on clue page cannot fix it on admin page. I am done. now to move on to the styling to match UI

This commit is contained in:
bobbert committed 2025-03-18 23:09:57 +00:00
1 parent 4cd449c0cf
commit 8fd2cabbe0
10 files changed
+226 -136

No files matched your search

+32 -32
View File
@@ -1,38 +1,38 @@
'use client';
import { useSession } from 'next-auth/react';
import { useState, useEffect } from 'react';
"use client";
import { useSession } from "next-auth/react";
import { useState, useEffect } from "react";
export default function TeamHeader() {
const { data: session } = useSession();
const [teamName, setTeamName] = useState(null);
const { data: session } = useSession();
const [teamName, setTeamName] = useState(null);
useEffect(() => {
// Only fetch team info if user is logged in and not an admin
if (session?.user?.teamId && session?.user?.role !== 'admin') {
fetchTeamInfo();
}
}, [session]);
const fetchTeamInfo = async () => {
try {
const response = await fetch(`/api/teams/${session.user.teamId}`);
if (response.ok) {
const data = await response.json();
setTeamName(data.name);
}
} catch (error) {
console.error('Failed to fetch team info:', error);
}
};
// Don't render anything if no team name or user is admin
if (!teamName || session?.user?.role === 'admin') {
return null;
useEffect(() => {
// Only fetch team info if user is logged in and not an admin
if (session?.user?.teamId && session?.user?.role !== "admin") {
fetchTeamInfo();
}
}, [session]);
return (
<div className="team-header">
<div className="team-name">{teamName}</div>
</div>
);
const fetchTeamInfo = async () => {
try {
const response = await fetch(`/api/teams/${session.user.teamId}`);
if (response.ok) {
const data = await response.json();
setTeamName(data.name);
}
} catch (error) {
console.error("Failed to fetch team info:", error);
}
};
// Don't render anything if no team name or user is admin
if (!teamName || session?.user?.role === "admin") {
return null;
}
return (
<div className="team-header">
<div className="team-name">Team Name: {teamName}</div>
</div>
);
}