新增競賽前台呈現、刪除競賽、修改競賽狀態
This commit is contained in:
@@ -122,6 +122,23 @@ export function CompetitionProvider({ children }: { children: ReactNode }) {
|
||||
const [teams, setTeams] = useState<Team[]>(mockTeams)
|
||||
const [proposals, setProposals] = useState<Proposal[]>(mockProposals)
|
||||
|
||||
// 載入當前競賽
|
||||
useEffect(() => {
|
||||
const loadCurrentCompetition = async () => {
|
||||
try {
|
||||
const response = await fetch('/api/competitions/current')
|
||||
const data = await response.json()
|
||||
if (data.success && data.data) {
|
||||
setCurrentCompetition(data.data)
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('載入當前競賽失敗:', error)
|
||||
}
|
||||
}
|
||||
|
||||
loadCurrentCompetition()
|
||||
}, [])
|
||||
|
||||
// Load judge scores from localStorage
|
||||
const [judgeScores, setJudgeScores] = useState<JudgeScore[]>(() => {
|
||||
if (typeof window !== "undefined") {
|
||||
@@ -186,6 +203,7 @@ export function CompetitionProvider({ children }: { children: ReactNode }) {
|
||||
}
|
||||
}, [awards])
|
||||
|
||||
|
||||
const addJudge = (judge: Omit<Judge, "id">) => {
|
||||
const newJudge: Judge = {
|
||||
...judge,
|
||||
|
Reference in New Issue
Block a user