Skip to content

Commit 57be3c9

Browse files
committed
fix
1 parent f5f1117 commit 57be3c9

File tree

4 files changed

+16
-3
lines changed

4 files changed

+16
-3
lines changed

backend/app/schemas/task.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ class TaskResponse(BaseModel):
106106
participant_id: Optional[UUID]
107107
participant_name: Optional[str] = None
108108
participant_email: Optional[str] = None
109+
participant_role_id: Optional[int] = None
109110
type: TaskType
110111
priority: TaskPriority
111112
status: TaskStatus

backend/app/services/implementations/task_service.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,13 @@ async def get_task_by_id(self, task_id: UUID) -> TaskResponse:
7878
# Extract participant and assignee names
7979
participant_name = None
8080
participant_email = None
81+
participant_role_id = None
8182
if task.participant:
8283
first_name = task.participant.first_name or ""
8384
last_name = task.participant.last_name or ""
8485
participant_name = f"{first_name} {last_name}".strip() or task.participant.email
8586
participant_email = task.participant.email
87+
participant_role_id = task.participant.role_id
8688

8789
assignee_name = None
8890
assignee_email = None
@@ -97,6 +99,7 @@ async def get_task_by_id(self, task_id: UUID) -> TaskResponse:
9799
**{c.name: getattr(task, c.name) for c in task.__table__.columns},
98100
"participant_name": participant_name,
99101
"participant_email": participant_email,
102+
"participant_role_id": participant_role_id,
100103
"assignee_name": assignee_name,
101104
"assignee_email": assignee_email,
102105
}
@@ -151,14 +154,16 @@ async def get_all_tasks(
151154
# Build TaskResponse with participant and assignee names
152155
task_responses = []
153156
for task in tasks:
154-
# Extract participant name and email if available
157+
# Extract participant name, email, and role_id if available
155158
participant_name = None
156159
participant_email = None
160+
participant_role_id = None
157161
if task.participant:
158162
first_name = task.participant.first_name or ""
159163
last_name = task.participant.last_name or ""
160164
participant_name = f"{first_name} {last_name}".strip() or task.participant.email
161165
participant_email = task.participant.email
166+
participant_role_id = task.participant.role_id
162167

163168
# Extract assignee name and email if available
164169
assignee_name = None
@@ -174,6 +179,7 @@ async def get_all_tasks(
174179
**{c.name: getattr(task, c.name) for c in task.__table__.columns},
175180
"participant_name": participant_name,
176181
"participant_email": participant_email,
182+
"participant_role_id": participant_role_id,
177183
"assignee_name": assignee_name,
178184
"assignee_email": assignee_email,
179185
}

frontend/src/APIClients/taskAPIClient.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export interface BackendTask {
55
participantId: string | null;
66
participantName: string | null;
77
participantEmail: string | null;
8+
participantRoleId: number | null;
89
type: 'intake_form_review' | 'volunteer_app_review' | 'profile_update' | 'matching';
910
priority: 'no_status' | 'low' | 'medium' | 'high';
1011
status: 'pending' | 'in_progress' | 'completed';

frontend/src/pages/admin/tasks.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,14 @@ const mapAPITaskToFrontend = (
116116
? `${participant.firstName || ''} ${participant.lastName || ''}`.trim() || participant.email
117117
: 'Unknown Participant';
118118

119-
// Determine user type from participant's role (default to Participant if not available)
119+
// Determine user type from participant's role
120+
// Use role_id from API response if available, otherwise fall back to participant object
120121
const userType: 'Participant' | 'Volunteer' =
121-
participant && participant.roleId === 2 ? 'Volunteer' : 'Participant';
122+
apiTask.participantRoleId === 2
123+
? 'Volunteer'
124+
: participant && participant.roleId === 2
125+
? 'Volunteer'
126+
: 'Participant';
122127

123128
return {
124129
id: apiTask.id,

0 commit comments

Comments
 (0)