Skip to content

feat: add admin approve/reject adoption endpoints with validation and…#102

Open
Babigdk wants to merge 2 commits intoamina69:mainfrom
Babigdk:feat/admin-approve-reject-adoption
Open

feat: add admin approve/reject adoption endpoints with validation and…#102
Babigdk wants to merge 2 commits intoamina69:mainfrom
Babigdk:feat/admin-approve-reject-adoption

Conversation

@Babigdk
Copy link
Copy Markdown

@Babigdk Babigdk commented Apr 2, 2026

Closes #22

🚀 Admin Approval & Rejection for Adoptions

📋 Overview

This PR introduces admin-controlled approval and rejection of adoption requests.


✅ Features Implemented

1. Approve Adoption

  • Endpoint: PATCH /adoption/:id/approve
  • Only accessible by ADMIN
  • Validates adoption is PENDING
  • Updates status → APPROVED
  • Returns updated adoption with relations

2. Reject Adoption

  • Endpoint: PATCH /adoption/:id/reject
  • Only accessible by ADMIN
  • Validates adoption is PENDING
  • Updates status → REJECTED
  • Accepts optional rejection reason
  • Uses Prisma transaction for safety

🔒 Validation & Authorization

  • ADMIN role required (JwtAuthGuard + RolesGuard)
  • Prevents invalid transitions (non-PENDING)
  • Returns:
    • 404 if not found
    • 400 if invalid state
    • 403 if unauthorized

⚠️ Notes

  • No schema changes were made (as required)
  • approvedAt and pet status updates were not implemented due to schema limitations

🧪 Testing

  • Approval flow tested (success + failure cases)
  • Rejection flow tested (with/without reason)
  • Authorization checks verified

📦 Files Changed

  • adoption.controller.ts
  • adoption.service.ts
  • dto/reject-adoption.dto.ts

✅ Status

Ready for review 🚀

@Babigdk
Copy link
Copy Markdown
Author

Babigdk commented Apr 3, 2026

Hi I have created a new pull request for this assigned issue kindly merge. Thanks

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.

Admin Approval

1 participant