feat: allow changing opportunity type via PATCH#731
Open
nadavosa wants to merge 4 commits into
Open
Conversation
Add volunteerType to the PATCH /opportunity/:id body schema and parser so coordinators can change an opportunity's type (accompanying / regular / events) after it was submitted. Depends on SDK PR need4deed-org/sdk#138 being merged and published before upgrading need4deed-sdk in this repo. Closes #730 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
7 tasks
| numberVolunteers: body.numberVolunteers, | ||
| info: body.description, | ||
| infoConfidential: body.description, | ||
| type: body.volunteerType as unknown as OpportunityType | undefined, |
Collaborator
There was a problem hiding this comment.
.claude/shared-rules.md says:
API changes go through the SDK contract first
- you need to update
ApiOpportunityPatchon SDK first - you shouldn't shortcut type checking by
as unknown as ...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
volunteerTypetoApiVolunteerOpportunityPatchJSON schema so Fastify accepts it in PATCH requestsparseOpportunityto extractbody.volunteerTypeand map it to thetypecolumn on theOpportunityentityDependency
Requires SDK PR need4deed-org/sdk#138 to be merged and published first.
Once that SDK version is on npm, upgrade
need4deed-sdkin this repo and the TypeScript cast inparser-opportunity-patch-data.tscan be removed.Scope
Handles type changes between
regularandeventscleanly, and fromaccompanyingto another type. Changing toaccompanyingwhen no accompanying record exists requires the coordinator to also provideaccompanyingDetailsin the same PATCH request — the existing accompanying-patch logic handles creation.Closes #730
Test plan
/opportunity/:idwith{ "volunteerType": "regular" }updates the opportunity type in the DB{ "volunteerType": "events" }also worksvolunteerTypefield leaves the type unchanged🤖 Generated with Claude Code