feat(admin): show country context in submission review UI (#925)#937
feat(admin): show country context in submission review UI (#925)#937ericsocrat merged 1 commit intomainfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Bundle Size Report
✅ Bundle size is within acceptable limits. |
There was a problem hiding this comment.
Pull request overview
Adds country context to the admin submissions review flow so admins can see (and filter by) the submission’s scan/suggested country end-to-end (DB RPC → frontend UI → tests/i18n).
Changes:
- Extend
api_admin_get_submissionsto returnscan_country/suggested_countryand include acountry_filterin the response envelope, plus an optionalp_countryfilter param. - Update the admin submissions page to display a country chip per submission and add a country filter dropdown.
- Add backend SQL tests, frontend unit tests, and i18n strings for the new UI.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
supabase/tests/scanner_functions.test.sql |
Adds SQL assertions for country_filter key presence and p_country acceptance. |
supabase/migrations/20260321000100_admin_submissions_country_context.sql |
Introduces new RPC signature/response fields and filtering logic for country context. |
frontend/src/lib/types.ts |
Extends admin submission/response types with country fields and country_filter. |
frontend/src/app/app/admin/submissions/page.tsx |
Adds country filter UI and renders a CountryChip on submission cards. |
frontend/src/app/app/admin/submissions/page.test.tsx |
Adds tests for country chip behavior and country filter RPC param. |
frontend/messages/en.json / de.json / pl.json |
Adds translation keys for country filter UI. |
| CREATE OR REPLACE FUNCTION public.api_admin_get_submissions( | ||
| p_status text DEFAULT 'pending', | ||
| p_page integer DEFAULT 1, | ||
| p_page_size integer DEFAULT 20, | ||
| p_country text DEFAULT NULL | ||
| ) |
| v_offset := (GREATEST(p_page, 1) - 1) * LEAST(p_page_size, 50); | ||
|
|
| 'total', v_total, | ||
| 'page', GREATEST(p_page, 1), | ||
| 'pages', GREATEST(CEIL(v_total::numeric / LEAST(p_page_size, 50)), 1), | ||
| 'page_size', LEAST(p_page_size, 50), | ||
| 'status_filter', p_status, |
| COMMENT ON FUNCTION public.api_admin_get_submissions IS | ||
| 'Purpose: List product submissions with trust enrichment and country context | ||
| Auth: authenticated (SECURITY DEFINER) | ||
| Params: p_status (default pending), p_page (default 1), p_page_size (default 20, max 50), p_country (optional country filter) | ||
| Returns: JSONB {api_version, total, page, pages, page_size, status_filter, country_filter, submissions: [...]} | ||
| Country filter: matches scan_country OR suggested_country | ||
| Backward compatible: new p_country param defaults to NULL (no filter)'; |
| {/* Country filter */} | ||
| <div className="flex items-center gap-2"> | ||
| <span className="text-sm text-foreground-secondary"> | ||
| {t("admin.countryLabel")} | ||
| </span> | ||
| <select | ||
| value={countryFilter ?? ""} | ||
| onChange={(e) => { | ||
| setCountryFilter(e.target.value || null); | ||
| setPage(1); | ||
| }} | ||
| className="rounded-lg border bg-surface px-2 py-1 text-sm text-foreground" | ||
| data-testid="country-filter" |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 438827d10f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| CREATE OR REPLACE FUNCTION public.api_admin_get_submissions( | ||
| p_status text DEFAULT 'pending', | ||
| p_page integer DEFAULT 1, | ||
| p_page_size integer DEFAULT 20, | ||
| p_country text DEFAULT NULL |
There was a problem hiding this comment.
Drop old api_admin_get_submissions overload
This migration creates a new 4-parameter api_admin_get_submissions but never removes the existing 3-parameter version from 20260315000600_admin_submission_dashboard.sql, so 3-arg callers keep executing the old implementation and won’t receive country_filter/country fields or country filtering behavior. That breaks backward-compatibility expectations for existing callers that still pass only (p_status, p_page, p_page_size) and is already visible in this commit’s own SQL test usage of the 3-arg call.
Useful? React with 👍 / 👎.
Summary
Shows country context in the admin submission review queue, enabling reviewers to see which country a scan originated from and filter by country.
Changes
api_admin_get_submissionsRPC to includescan_countryandsuggested_countryin response, addedp_countryfilter paramscan_country,suggested_countrytoAdminSubmission;country_filtertoAdminSubmissionsResponseCountryChipbadge on each submission card + country filter dropdowncountryLabelandallCountrieskeys (en/pl/de)country_filterkey, lives_ok with country filter param) — plan 70->72Verification
npx tsc --noEmit— 0 errorsnpx vitest run— 5,743/5,743 pass (32 in admin submissions file, 5 new)Closes #925