diff --git a/components/admin/competition-management.tsx b/components/admin/competition-management.tsx index b2107aa..4c81222 100644 --- a/components/admin/competition-management.tsx +++ b/components/admin/competition-management.tsx @@ -1141,19 +1141,23 @@ export function CompetitionManagement() { // 使用選擇的隊長 ID,如果沒有選擇則保持原有的隊長 ID const leaderId = newTeam.leader_id || (selectedTeam as any).leader_id || '0b844fb6-1a63-4e0c-a15a-416e9b0ec8c7' - const teamData = { + // 根據當前標籤頁決定發送哪些字段 + const teamData: any = { name: newTeam.name, leader_id: leaderId, department: newTeam.department, contact_email: newTeam.contactEmail, - description: newTeam.description, - members: newTeam.members.map(member => ({ - user_id: member.user_id || member.id, // 確保使用正確的 user_id - role: member.role || 'member' - })), - apps: newTeam.apps // 添加應用 ID 列表 + description: newTeam.description } + // 只有在成員標籤頁或應用標籤頁時才發送對應的數據 + // 這裡我們總是發送成員和應用數據,因為用戶可能在任何標籤頁點擊更新 + teamData.members = newTeam.members.map(member => ({ + user_id: member.user_id || member.id, // 確保使用正確的 user_id + role: member.role || 'member' + })) + teamData.apps = newTeam.apps // 添加應用 ID 列表 + const success = await updateTeamInDb(selectedTeam.id, teamData) if (success) { setSuccess("團隊更新成功!") @@ -1232,6 +1236,7 @@ export function CompetitionManagement() { const member = { id: newMember.user_id, // 使用用戶 ID + user_id: newMember.user_id, // 確保 user_id 字段存在 name: newMember.name, department: newMember.department, role: newMember.role, @@ -5201,7 +5206,7 @@ export function CompetitionManagement() {
創作者:{participant.creator}
-提交日期:{participant.submissionDate}
+提交日期:{participant.submissionDate || participant.created_at || '未知'}
) @@ -5270,10 +5275,13 @@ export function CompetitionManagement() { checked={isSelected} onCheckedChange={(checked) => { if (checked) { - setNewCompetition({ - ...newCompetition, - participatingTeams: [...newCompetition.participatingTeams, participant.id], - }) + // 檢查是否已經存在,避免重複添加 + if (!newCompetition.participatingTeams.includes(participant.id)) { + setNewCompetition({ + ...newCompetition, + participatingTeams: [...newCompetition.participatingTeams, participant.id], + }) + } } else { setNewCompetition({ ...newCompetition, @@ -5294,11 +5302,11 @@ export function CompetitionManagement() {{participant.description}
)} -提交日期:{participant.submissionDate}
+提交日期:{participant.submissionDate || participant.created_at || '未知'}
) @@ -7440,7 +7448,7 @@ export function CompetitionManagement() {