修正團隊顯示 BUG

This commit is contained in:
2025-09-19 18:57:10 +08:00
parent 8ec5ead183
commit c5bbec5ca8
2 changed files with 32 additions and 20 deletions

View File

@@ -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() {
</Badge>
</div>
<p className="text-xs text-gray-600 mt-1">{participant.creator}</p>
<p className="text-xs text-gray-500">{participant.submissionDate}</p>
<p className="text-xs text-gray-500">{participant.submissionDate || participant.created_at || '未知'}</p>
</div>
</div>
)
@@ -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() {
<div className="flex items-center space-x-4 text-xs text-gray-600">
<div className="flex items-center space-x-1">
<User className="w-3 h-3" />
<span>{participant.leader}</span>
<span>{participant.leader_name || participant.leader || '未知'}</span>
</div>
<div className="flex items-center space-x-1">
<Users className="w-3 h-3" />
<span>{participant.memberCount}</span>
<span>{participant.member_count || participant.memberCount || 0}</span>
</div>
</div>
{participant.contactEmail && (
@@ -5310,7 +5318,7 @@ export function CompetitionManagement() {
{participant.description && (
<p className="text-xs text-gray-500 line-clamp-2">{participant.description}</p>
)}
<p className="text-xs text-gray-500">{participant.submissionDate}</p>
<p className="text-xs text-gray-500">{participant.submissionDate || participant.created_at || '未知'}</p>
</div>
</div>
)
@@ -7440,7 +7448,7 @@ export function CompetitionManagement() {
<SelectItem key={team.id} value={team.id}>
<div className="flex flex-col">
<span className="font-medium">{team.name}</span>
<span className="text-xs text-gray-500">{team.leader} {team.department} {team.memberCount}</span>
<span className="text-xs text-gray-500">{team.leader_name || team.leader || '未知'} {team.department} {team.member_count || team.memberCount || 0}</span>
</div>
</SelectItem>
))