Skip to content

add residential listing limit#88

Merged
dnywh merged 1 commit into
mainfrom
dnywh/residential-listing-limit
May 15, 2026
Merged

add residential listing limit#88
dnywh merged 1 commit into
mainfrom
dnywh/residential-listing-limit

Conversation

@dnywh
Copy link
Copy Markdown
Owner

@dnywh dnywh commented May 15, 2026

Summary

  • keep the 12 total listing cap and add a 3 residential listing cap for non-admin users
  • hide capped residential creation paths in the listing chooser while keeping direct form submissions protected by RLS
  • update listing-limit copy so it no longer references “current three” listings
  • add hidden seed fixtures and focused Playwright coverage for the capped residential chooser state

Validation

  • npm run check
  • npm run typecheck
  • NEXT_PUBLIC_SUPABASE_URL=http://127.0.0.1:54331 NEXT_PUBLIC_SUPABASE_ANON_KEY=... npx playwright test e2e/listings.spec.ts -g "listing type chooser hides residential option"
  • Applied the new migration SQL locally with psql and checked the key RLS cases in rollback transactions.

Note: supabase migration up --local is blocked by a pre-existing local migration history mismatch for remote migration 20260514043101, so I validated this migration directly against the local database instead.

@vercel
Copy link
Copy Markdown

vercel Bot commented May 15, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
peels Ready Ready Preview, Comment May 15, 2026 6:26am

@supabase
Copy link
Copy Markdown

supabase Bot commented May 15, 2026

Updates to Preview Branch (dnywh/residential-listing-limit) ↗︎

Deployments Status Updated
Database Fri, 15 May 2026 06:24:54 UTC
Services Fri, 15 May 2026 06:24:54 UTC
APIs Fri, 15 May 2026 06:24:54 UTC

Tasks are run on every commit but only new migration files are pushed.
Close and reopen this PR if you want to apply changes from existing seed or migration files.

Tasks Status Updated
Configurations Fri, 15 May 2026 06:25:01 UTC
Migrations Fri, 15 May 2026 06:25:23 UTC
Seeding Fri, 15 May 2026 06:25:32 UTC
Edge Functions Fri, 15 May 2026 06:25:47 UTC

View logs for this Workflow Run ↗︎.
Learn more about Supabase for Git ↗︎.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a per-user residential-listing cap (3) on top of the existing 12-listing total cap. Enforces the cap via an updated RLS insert policy backed by a new count_user_listings_by_type helper, hides the residential option in the listing-type chooser when the cap is reached, and updates the too-many-listings copy. Seeds two extra hidden residential demo listings (bringing the demo donor to 3 residential listings) and adds Playwright coverage for the capped chooser state.

Changes:

  • New migration replaces the listings INSERT RLS policy to add a 3-residential cap (admins bypass) and adds a (owner_id, type) index plus a count_user_listings_by_type function.
  • Server-rendered chooser page filters out the residential (and total-capped) options and renders an empty-state message; ListingTypeChooser now accepts emptyMessage.
  • Listing-limit copy across all locales is generalised, a new Listings.new.noAvailableOptions key is added, the MAX_LISTINGS magic number is extracted to src/config/listingLimits.ts, and Playwright/seed fixtures cover the capped scenario.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated no comments.

Show a summary per file
File Description
supabase/migrations/20260515061033_add_residential_listing_limit.sql New RLS insert policy adding residential cap + supporting function and index
supabase/seed.sql Adds two hidden residential demo listings (1007, 1008) for the donor and updates seq/slugs
src/config/listingLimits.ts New constants for total and residential per-user limits
src/app/(forms)/profile/listings/new/page.tsx Fetches user listings/profile and filters chooser options by cap
src/components/ListingTypeChooser.tsx Renders emptyMessage when no options are available
src/components/ProfileListings/ProfileListings.tsx Uses the new shared MAX_LISTINGS_PER_USER constant
messages/{en,de,es,fr,pt-BR}.json Generalises tooManyListings copy and adds noAvailableOptions
e2e/listings.spec.ts Adds Playwright test for the capped residential chooser state

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@dnywh dnywh merged commit b986a86 into main May 15, 2026
11 checks passed
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