修正團體管理的 BUG

This commit is contained in:
2025-09-19 18:36:35 +08:00
parent 95c0c4cb23
commit 8ec5ead183
11 changed files with 367 additions and 137 deletions

View File

@@ -563,7 +563,13 @@ export function CompetitionManagement() {
contactEmail: teamDetails.contact_email || '',
leaderPhone: teamDetails.leader_phone || '',
description: teamDetails.description || '',
members: teamDetails.members || [],
members: (teamDetails.members || []).map((member: any) => ({
id: member.user_id || member.id,
user_id: member.user_id || member.id,
name: member.name,
department: member.department,
role: member.role || '成員'
})),
apps: teamDetails.apps ? teamDetails.apps.map((app: any) => app.id || app) : [],
submittedAppCount: teamDetails.apps?.length || 0,
}
@@ -1142,7 +1148,7 @@ export function CompetitionManagement() {
contact_email: newTeam.contactEmail,
description: newTeam.description,
members: newTeam.members.map(member => ({
user_id: member.id, // 現在 member.id 就是 user_id
user_id: member.user_id || member.id, // 確保使用正確的 user_id
role: member.role || 'member'
})),
apps: newTeam.apps // 添加應用 ID 列表
@@ -1164,7 +1170,7 @@ export function CompetitionManagement() {
contact_email: newTeam.contactEmail,
description: newTeam.description,
members: newTeam.members.map(member => ({
user_id: member.id, // 現在 member.id 就是 user_id
user_id: member.user_id || member.id, // 確保使用正確的 user_id
role: member.role || 'member'
})),
apps: newTeam.apps // 添加應用 ID 列表
@@ -2136,6 +2142,19 @@ export function CompetitionManagement() {
}
}
const getCompetitionTypeColor = (type: string) => {
switch (type) {
case "individual":
return "bg-blue-100 text-blue-800 border-blue-200"
case "team":
return "bg-purple-100 text-purple-800 border-purple-200"
case "mixed":
return "bg-orange-100 text-orange-800 border-orange-200"
default:
return "bg-gray-100 text-gray-800 border-gray-200"
}
}
const getScoreLabelText = (key: string) => {
switch (key) {
case "innovation":
@@ -2464,13 +2483,13 @@ export function CompetitionManagement() {
<Table>
<TableHeader>
<TableRow>
<TableHead></TableHead>
<TableHead></TableHead>
<TableHead></TableHead>
<TableHead></TableHead>
<TableHead></TableHead>
<TableHead></TableHead>
<TableHead></TableHead>
<TableHead className="w-[300px]"></TableHead>
<TableHead className="w-[120px]"></TableHead>
<TableHead className="w-[150px]"></TableHead>
<TableHead className="w-[100px]"></TableHead>
<TableHead className="w-[120px]"></TableHead>
<TableHead className="w-[150px]"></TableHead>
<TableHead className="w-[80px]"></TableHead>
</TableRow>
</TableHeader>
<TableBody>
@@ -2506,9 +2525,9 @@ export function CompetitionManagement() {
</div>
</TableCell>
<TableCell>
<div className="flex items-center space-x-2">
<div className="flex items-center space-x-2 min-w-[100px]">
{getCompetitionTypeIcon(competition.type)}
<Badge variant="outline" className="text-xs">
<Badge variant="outline" className={`text-xs px-2 py-1 whitespace-nowrap ${getCompetitionTypeColor(competition.type)}`}>
{getCompetitionTypeText(competition.type)}
</Badge>
</div>
@@ -2527,34 +2546,37 @@ export function CompetitionManagement() {
</div>
</TableCell>
<TableCell>
<Badge variant="outline" className={getStatusColor(competition.status)}>
{getStatusText(competition.status)}
</Badge>
</TableCell>
<TableCell>
<div className="flex items-center space-x-1">
{getCompetitionTypeIcon(competition.type)}
<span>{participantCount} </span>
<div className="min-w-[80px]">
<Badge variant="outline" className={`text-xs px-2 py-1 whitespace-nowrap ${getStatusColor(competition.status)}`}>
{getStatusText(competition.status)}
</Badge>
</div>
</TableCell>
<TableCell>
<div className="space-y-1">
<div className="flex items-center space-x-1 min-w-[100px]">
{getCompetitionTypeIcon(competition.type)}
<span className="text-sm whitespace-nowrap">{participantCount} </span>
</div>
</TableCell>
<TableCell>
<div className="space-y-1 min-w-[140px]">
<div className="flex items-center space-x-2">
<Progress value={scoringProgress.percentage} className="w-16 h-2" />
<span className="text-xs text-gray-500">
<span className="text-xs text-gray-500 whitespace-nowrap">
{scoringProgress.completed}/{scoringProgress.total}
</span>
</div>
<p className="text-xs text-gray-500">{scoringProgress.percentage}% </p>
<p className="text-xs text-gray-500 whitespace-nowrap">{scoringProgress.percentage}% </p>
</div>
</TableCell>
<TableCell>
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button variant="ghost" size="sm" disabled={isLoading}>
<MoreHorizontal className="w-4 h-4" />
</Button>
</DropdownMenuTrigger>
<div className="flex justify-center min-w-[60px]">
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button variant="ghost" size="sm" disabled={isLoading}>
<MoreHorizontal className="w-4 h-4" />
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="end">
<DropdownMenuItem onClick={() => handleViewCompetition(competition)}>
<Eye className="w-4 h-4 mr-2" />
@@ -2598,7 +2620,8 @@ export function CompetitionManagement() {
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
</DropdownMenu>
</div>
</TableCell>
</TableRow>
)
@@ -2771,7 +2794,7 @@ export function CompetitionManagement() {
</div>
<div className="flex items-center space-x-2 text-gray-600">
<Trophy className="w-3 h-3" />
<span>{team.submittedAppCount} </span>
<span>{team.app_count || 0} </span>
</div>
</div>
@@ -6603,7 +6626,7 @@ export function CompetitionManagement() {
<div className="flex-1">
<div className="flex items-center space-x-2">
<p className="font-medium text-gray-900">{member.name}</p>
{member.user_id === selectedTeam.leader_id && (
{member.role === '隊長' && (
<Badge variant="default" className="text-xs bg-orange-100 text-orange-800">
</Badge>