修正獎勵評審資訊、評分資訊
This commit is contained in:
@@ -67,6 +67,7 @@ interface CompetitionContextType {
|
||||
addAward: (award: Omit<Award, "id">) => void
|
||||
getAwardsByYear: (year: number) => Award[]
|
||||
getAwardsByMonth: (year: number, month: number) => Award[]
|
||||
getAvailableYears: () => number[]
|
||||
|
||||
// Rankings
|
||||
getCompetitionRankings: (competitionId?: string) => Array<{
|
||||
@@ -527,11 +528,13 @@ export function CompetitionProvider({ children }: { children: ReactNode }) {
|
||||
const loadAwards = async () => {
|
||||
setLoadingAwards(true)
|
||||
try {
|
||||
console.log('🔍 開始載入前台獎項數據...')
|
||||
const response = await fetch('/api/admin/awards')
|
||||
const data = await response.json()
|
||||
|
||||
if (data.success) {
|
||||
console.log('📊 載入獎項數據:', data.data.length, '個')
|
||||
console.log('📋 獎項數據樣本:', data.data.slice(0, 2))
|
||||
setAwards(data.data)
|
||||
} else {
|
||||
console.error('載入獎項失敗:', data.message)
|
||||
@@ -572,6 +575,12 @@ export function CompetitionProvider({ children }: { children: ReactNode }) {
|
||||
return awards.filter((award) => award.year === year)
|
||||
}
|
||||
|
||||
// 獲取所有可用的年份
|
||||
const getAvailableYears = (): number[] => {
|
||||
const years = [...new Set(awards.map(award => award.year))].sort((a, b) => b - a)
|
||||
return years
|
||||
}
|
||||
|
||||
const getAwardsByMonth = (year: number, month: number): Award[] => {
|
||||
return awards.filter((award) => award.year === year && award.month === month)
|
||||
}
|
||||
@@ -836,6 +845,7 @@ export function CompetitionProvider({ children }: { children: ReactNode }) {
|
||||
addAward,
|
||||
getAwardsByYear,
|
||||
getAwardsByMonth,
|
||||
getAvailableYears,
|
||||
getCompetitionRankings,
|
||||
getAwardsByCompetitionType,
|
||||
getAwardsByCategory,
|
||||
|
Reference in New Issue
Block a user