Skip to content

feat(admin): show country context in submission review UI (#925)#937

Merged
ericsocrat merged 1 commit intomainfrom
feat/925-admin-submission-country-context
Mar 17, 2026
Merged

feat(admin): show country context in submission review UI (#925)#937
ericsocrat merged 1 commit intomainfrom
feat/925-admin-submission-country-context

Conversation

@ericsocrat
Copy link
Owner

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

  • Migration (20260321000100): Updated api_admin_get_submissions RPC to include scan_country and suggested_country in response, added p_country filter param
  • Types: Added scan_country, suggested_country to AdminSubmission; country_filter to AdminSubmissionsResponse
  • UI: Added CountryChip badge on each submission card + country filter dropdown
  • i18n: Added countryLabel and allCountries keys (en/pl/de)
  • pgTAP: 2 new tests (response has country_filter key, lives_ok with country filter param) — plan 70->72
  • Vitest: 5 new unit tests (country chip display, preference logic, null handling, filter rendering, RPC param passing)

Verification

  • npx tsc --noEmit — 0 errors
  • npx vitest run — 5,743/5,743 pass (32 in admin submissions file, 5 new)

Closes #925

Copilot AI review requested due to automatic review settings March 17, 2026 13:41
@vercel
Copy link

vercel bot commented Mar 17, 2026

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

Project Deployment Actions Updated (UTC)
tryvit Ready Ready Preview, Comment Mar 17, 2026 1:42pm

@github-actions
Copy link

Bundle Size Report

Metric Value
Main baseline 0 KB
This PR 0 KB
Delta +0 KB (+0%)
JS chunks 0
Hard limit 4000 KB

✅ Bundle size is within acceptable limits.

Copy link

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 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_submissions to return scan_country/suggested_country and include a country_filter in the response envelope, plus an optional p_country filter 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.

Comment on lines +14 to +19
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
)
Comment on lines +31 to +32
v_offset := (GREATEST(p_page, 1) - 1) * LEAST(p_page_size, 50);

Comment on lines +95 to +99
'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 lines +110 to +116
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)';
Comment on lines +267 to +279
{/* 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"
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 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".

Comment on lines +14 to +18
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

Choose a reason for hiding this comment

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

P1 Badge 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 👍 / 👎.

@ericsocrat ericsocrat merged commit bd76ca6 into main Mar 17, 2026
21 of 23 checks passed
@ericsocrat ericsocrat deleted the feat/925-admin-submission-country-context branch March 17, 2026 14:03
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.

feat(frontend): show country context in admin submission review UI

2 participants