Refine admin panel workflows

This commit is contained in:
AzuTear
2026-06-18 14:29:40 +02:00
parent f4512eba2e
commit d015fcbe6f
14 changed files with 481 additions and 598 deletions
+16 -2
View File
@@ -216,6 +216,20 @@ const emptyAdminSeasonDetail: AdminSeasonDetailResponse = {
clipSubmissions: [],
}
/**
* Guarantee the array fields exist even if a (possibly older) backend omits them,
* so views can safely read `.length`/`.filter` without crashing the render.
*/
function normalizeSeasonDetail(detail: AdminSeasonDetailResponse): AdminSeasonDetailResponse {
return {
...detail,
categories: detail.categories ?? [],
candidates: detail.candidates ?? [],
pendingNominations: detail.pendingNominations ?? [],
clipSubmissions: detail.clipSubmissions ?? [],
}
}
export const useAwardsStore = defineStore('awards', {
state: () => ({
overview: fallbackOverview as OverviewResponse,
@@ -259,7 +273,7 @@ export const useAwardsStore = defineStore('awards', {
}
if (this.adminSelectedSeasonId) {
this.adminSeasonDetail = await api.getAdminSeasonDetail(this.adminSelectedSeasonId)
this.adminSeasonDetail = normalizeSeasonDetail(await api.getAdminSeasonDetail(this.adminSelectedSeasonId))
}
this.apiMode = 'api'
} catch {
@@ -272,7 +286,7 @@ export const useAwardsStore = defineStore('awards', {
async loadAdminSeasonDetail(seasonId: number) {
try {
this.adminSelectedSeasonId = seasonId
this.adminSeasonDetail = await api.getAdminSeasonDetail(seasonId)
this.adminSeasonDetail = normalizeSeasonDetail(await api.getAdminSeasonDetail(seasonId))
this.apiMode = 'api'
} catch {
this.adminSeasonDetail = emptyAdminSeasonDetail