Skip to content

fix(shifts): return assigned guard details#357

Open
LoopyB wants to merge 1 commit intomainfrom
louisabest/fix/shift-assigned-guards-response
Open

fix(shifts): return assigned guard details#357
LoopyB wants to merge 1 commit intomainfrom
louisabest/fix/shift-assigned-guards-response

Conversation

@LoopyB
Copy link
Copy Markdown
Collaborator

@LoopyB LoopyB commented May 8, 2026

Summary

This PR updates the GET /api/v1/shifts response so the frontend Shift Schedule View can display assigned guard names.

The backend already stores guard assignment data using:

  • guardIds for pre-selected guards
  • acceptedBy for the approved/assigned guard

However, the shift list response was not populating either field with guard details, and it did not expose a frontend-friendly assignedGuards field.

Changes

  • Populates guardIds with guard name and email
  • Populates acceptedBy with guard name and email
  • Adds assignedGuards array to each shift response item
  • Preserves existing applicants, applicantCount, and hasApplicants behaviour
  • Keeps the fix scoped to GET /api/v1/shifts

Frontend impact

The frontend can now read:

shift.assignedGuards

Testing

  • Ran ESLint on touched file:
npx eslint src/controllers/shift.controller.js
  • Started backend locally on port 5001:
PORT=5001 npm run dev
  • Verified GET /api/v1/shifts with an employer Bearer token returns 200 OK
  • Confirmed response now includes populated assignedGuards objects with _id, name, and email
  • Confirmed existing paginated response shape is preserved: page, limit, total, items

@uppalkrish
Copy link
Copy Markdown
Collaborator

show the output on swagger

@LoopyB
Copy link
Copy Markdown
Collaborator Author

LoopyB commented May 11, 2026

Certainly @uppalkrish

I’ve tested the PR branch through Swagger.

GET /api/v1/shifts?page=1&limit=20 returns 200 OK, and the response now includes the new assignedGuards array populated with guard _id, name, and email.

Swagger output screenshot showing the response body:

swagger

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants