前台競賽功能修復
This commit is contained in:
@@ -122,21 +122,29 @@ export function CompetitionProvider({ children }: { children: ReactNode }) {
|
||||
const [teams, setTeams] = useState<Team[]>(mockTeams)
|
||||
const [proposals, setProposals] = useState<Proposal[]>(mockProposals)
|
||||
|
||||
// 載入當前競賽
|
||||
// 載入所有競賽和當前競賽
|
||||
useEffect(() => {
|
||||
const loadCurrentCompetition = async () => {
|
||||
const loadCompetitions = async () => {
|
||||
try {
|
||||
const response = await fetch('/api/competitions/current')
|
||||
const data = await response.json()
|
||||
if (data.success && data.data) {
|
||||
setCurrentCompetition(data.data)
|
||||
// 載入所有競賽
|
||||
const competitionsResponse = await fetch('/api/competitions')
|
||||
const competitionsData = await competitionsResponse.json()
|
||||
if (competitionsData.success && competitionsData.data) {
|
||||
setCompetitions(competitionsData.data)
|
||||
}
|
||||
|
||||
// 載入當前競賽
|
||||
const currentResponse = await fetch('/api/competitions/current')
|
||||
const currentData = await currentResponse.json()
|
||||
if (currentData.success && currentData.data) {
|
||||
setCurrentCompetition(currentData.data)
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('載入當前競賽失敗:', error)
|
||||
console.error('載入競賽數據失敗:', error)
|
||||
}
|
||||
}
|
||||
|
||||
loadCurrentCompetition()
|
||||
loadCompetitions()
|
||||
}, [])
|
||||
|
||||
// Load judge scores from localStorage
|
||||
|
Reference in New Issue
Block a user