Skip to content

bffc 34-stewards/admincan add plants to inventory - #65

Merged
saumyapalk23 merged 5 commits into
mainfrom
bffc-34-stewards/admin-can-add-plants-to-inventory
Nov 22, 2026
Merged

saumyapalk23 merged 5 commits into
mainfrom
bffc-34-stewards/admin-can-add-plants-to-inventory

Conversation

@ducan-le

@ducan-le ducan-le commented Nov 22, 2026 •

Copy link
Copy Markdown

ℹ️ Issue

Closes <#41>

📝 Description

Adds POST /plant so stewards and admins can add plants to a site's inventory and link them to sites. A plant is saved ks, so the site page and plantview always show complete records.

  1. Added CreatePlantDto. name is required. imageS3Key, description, flavor, harvestSeason, howToHarvest,re optional. Validation errorsname the field that failed (400).
  2. Added PlantsService.create, its site_plants rows in one
    transaction. An unknown site ID returns 404. Empty optional fields come back as null, and
    a plant with no sites returns `h
  3. Restricted the route to stewards and admins (401/403). Stewards can only link their own
    sites; admins can link any site.
  4. Added Swagger docs and unit tests for the cases listed in the ticket.

✔️ Verification

✔️ Verification

  1. Check out this branch and run yarn install.
  2. Run yarn test. All 245 testones in
    apps/backend/src/plants/.
  3. Run npx nx build backend an --base=main`. Both pass.
  4. Optional: set SWAGGER_ENABLED=true, run the backend, and try POST /api/plant from Swagger at /api.

no ui changes.

🏕️ (Optional) Future Work / Notes

  • This branch is built on piers/:id and RolesGuard`), so we gotta merge that PR first.
  • The steward-to-site check compusernamewith the site steward's email in Postgres. This only works becausecreateUsersets the username to the email. Storing the Cognitosubonusble link.

piersolh and others added 5 commits November 22, 2026 11:16
Adds a RolesGuard/@roles decorator (Cognito groups) for 403s, a validated
CreateAdminEventDto, service logic that 404s on unknown sites and inserts
into admin_events, extended response DTO, README docs and unit tests.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Returns the full plant record plus host sites via the site_plants join.
Malformed ids return 400, unknown ids return 404.
Creates a plant and links it to sites through site_plants in a single
transaction. Stewards can only link their own sites; admins can link any.
Validates the request body, returns 404 for unknown site IDs, and stores
empty optional text as null.
@github-actions
github-actions Bot requested a review from bodhiYG November 22, 2026 22:10
github-actions Bot added a commit that referenced this pull request Nov 22, 2026

@bodhiYG bodhiYG left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so swaggy 🔥

@saumyapalk23 saumyapalk23 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥

@saumyapalk23
saumyapalk23 merged commit d4301d5 into main Nov 22, 2026
7 checks passed
github-actions Bot added a commit that referenced this pull request Nov 22, 2026
github-actions Bot added a commit that referenced this pull request Nov 22, 2026
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.

4 participants