Skip to content

feat(discovery): Discovery 2.0 quick filters, home highlight strips, and card statement freshness - #326

Merged
JOY (JOY) merged 1 commit into
devfrom
antigravity/give-318-discovery-v2
Nov 22, 2026
Merged

JOY (JOY) merged 1 commit into
devfrom
antigravity/give-318-discovery-v2

Conversation

@JOY

@JOY JOY (JOY) commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Refs #318

Depends on Phase 1 DB migration DOS/DOS.Me#1886 (20261202120000_give_discovery_v2_filters.sql, merged & verified on Supabase Beta 37ef37820ff89ad93a0e75f0f3a3e2e11d229bd6).

Summary

  1. Data layer (apps/web/src/lib/campaigns.ts):
    • Extended DiscoverySort and DISCOVERY_SORTS with "ending_soon" (Sắp hết hạn), "almost_funded" (Sắp đạt mục tiêu), and "recently_audited" (Mới cập nhật sao kê), plus DISCOVERY_HIGHLIGHT_PILLS and isDiscoveryHighlightSort.
    • Added batched, fail-closed listCampaignStatementFreshness(db, campaignIds) over give.public_campaign_statement_freshness(uuid[]) (deduplicates IDs, chunks by 100, validates timestamps, fails closed on RPC error).
  2. Discovery /campaigns (apps/web/src/app/campaigns/page.tsx):
    • Added quick-filter pills (FilterNav + ScrollRow + TagLink) and sort menu options for "Sắp hết hạn", "Sắp đạt mục tiêu", and "Mới cập nhật sao kê".
    • Smart status pairing (live-only pills pair with live; recently_audited pairs with all or preserves ended; re-clicking active pill toggles back to featured), nameFrom="xl" on the sort menu so 1024px never overflows, filtered EmptyState for highlight modes, and verified statement freshness fetched only on recently_audited (excluding approved/prelaunch).
  3. Home / (apps/web/src/app/page.tsx):
    • Added dynamic "Sắp đạt mục tiêu" (/campaigns?sort=almost_funded) and "Minh bạch sao kê gần đây" (/campaigns?status=all&sort=recently_audited) strips, cleanly hidden when empty, with parallelized queries, deduplicated totals, distinct aria-label links, and defense-in-depth exclusion of approved prelaunch rows.
  4. CampaignCard (apps/web/src/components/CampaignCard.tsx):
    • Added optional lastStatementAt displaying "Sao kê mới nhất: DD/MM/YYYY" (text-sm text-primary tabular-nums), strictly suppressed on prelaunch (status === "approved") cards and invalid dates.

Verification

  • pnpm format:check: PASS
  • pnpm lint: PASS
  • pnpm typecheck: PASS
  • pnpm test: PASS (201/201 test files, expanded unit/component/RSC coverage in campaigns.test.ts, CampaignCard.test.ts, campaigns/page.test.ts, page.test.ts)
  • pnpm build: PASS
  • Fresh-context code/DESIGN.md review: 0 P0/P1; all 2 P2 + 3 P3 findings addressed.

📌 TL;DR

This PR introduces "Discovery 2.0" by adding three new campaign sorting modes (ending_soon, almost_funded, recently_audited) and a new FilterNav component for quick-filter pills on the campaigns page. It also enhances the homepage with dynamic highlight strips for these new categories and adds a lastStatementAt property to CampaignCard to display verified bank statement freshness dates.

🎯 Type of Change

  • 🚀 New feature
  • 🐛 Bugfix
  • 🧹 Refactor
  • ⚡ Performance
  • 📚 Documentation
  • ⚙️ CI / Configuration

🔍 Changes Walkthrough

File Summary of Changes
apps/web/src/lib/campaigns.ts Added new DiscoverySort types and DISCOVERY_HIGHLIGHT_PILLS constants. Implemented listCampaignStatementFreshness to fetch verified statement timestamps via RPC, including chunking and fail-closed error handling.
apps/web/src/lib/campaigns.test.ts Added tests for the new sort parsing, highlight pill constants, and the listCampaignStatementFreshness function (including edge cases like empty IDs, chunking, and error handling).
apps/web/src/components/CampaignCard.tsx Added lastStatementAt prop. Logic to validate the date and strictly suppress the display for pre-launch (approved) campaigns. Renders "Sao kê mới nhất: [date]" if valid.
apps/web/src/components/CampaignCard.test.ts Added tests verifying statement date rendering, timezone handling, invalid date suppression, and pre-launch suppression.
apps/web/src/app/campaigns/page.tsx Integrated FilterNav for quick-filter pills. Updated data fetching to include statement freshness when sorting by recently_audited. Adjusted hasFilter logic to account for highlight sorts.
apps/web/src/app/campaigns/page.test.ts Updated tests to cover the new filter pills, their active states, and the statement freshness data flow on the campaigns page.
apps/web/src/app/page.tsx Refactored homepage to fetch data for the new highlight strips (almost_funded, recently_audited) in parallel. Extracted CampaignStrip component to reuse the card grid layout for the new sections.
apps/web/src/app/page.test.ts Updated homepage tests to verify the new highlight strips, data deduplication, and exclusion of pre-launch campaigns from public totals.

📊 Architectural Flow

sequenceDiagram
    participant Client as Browser
    participant Page as Campaigns/Home Page
    participant Lib as campaigns.ts
    participant DB as Supabase RPC

    Note over Client,Page: User navigates to /campaigns or /
    
    alt Campaigns Page
        Client->>Page: Request /campaigns?sort=recently_audited
        Page->>Lib: listPublicCampaigns(...)
        Lib->>DB: rpc:discover_campaigns
        DB-->>Lib: Campaign IDs
        Lib-->>Page: Campaigns
        par Fetch Totals & Freshness
            Page->>Lib: listMoneyTotals(...)
            Lib->>DB: public_campaigns
            DB-->>Lib: Totals
            Lib-->>Page: Totals Map
        and
            Page->>Lib: listCampaignStatementFreshness(ids)
            Lib->>DB: rpc:public_campaign_statement_freshness
            DB-->>Lib: Timestamps
            Lib-->>Page: Freshness Map
        end
        Page-->>Client: Render Cards with "Sao kê mới nhất"
    else Homepage
        Client->>Page: Request /
        Page->>Lib: listPublicCampaigns (newest, almost_funded, recently_audited)
        Lib->>DB: rpc:discover_campaigns (x3)
        DB-->>Lib: IDs for each strip
        Lib-->>Page: Campaigns
        Page->>Lib: listMoneyTotals & listCampaignStatementFreshness
        Lib->>DB: public_campaigns & rpc:public_campaign_statement_freshness
        DB-->>Lib: Data
        Lib-->>Page: Maps
        Page-->>Client: Render Highlight Strips
    end
Loading

@JOY JOY (JOY) added line:campaigns Product line: campaigns po:agy Owned by Antigravity PO (mutual-exclusion parallel PO label) labels Nov 22, 2026

@claude claude Bot 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.

⚠️ Code review skipped — your organization has no extra usage available to pay for this review.

If your organization's extra usage balance is empty, an organization admin can add extra usage credits at claude.ai/admin-settings/usage. If its monthly spend limit was reached, an admin can raise it on the same page. If neither applies, contact Anthropic support.

Once extra usage is available, someone with write access to this repository can comment @claude review on this pull request to trigger a review.

@vercel

vercel Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
give Ready Ready Preview Nov 22, 2026 3:58pm UTC

Request Review

@coderabbitai

coderabbitai Bot commented Nov 22, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c77e583b-6385-4407-bebd-54d998841904

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

dos[bot]
dos Bot approved these changes Nov 22, 2026

@dos dos Bot 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.

⏱️ Code Review completed (8 eligible files · 45,745 chars · 1 model call(s) · 2 PR unit(s))

Whole diff with bounded context at base 5ef3bb1 / head e2a6923.

✅ CLEAN_PASS: Complete diff reviewed

@JOY

Copy link
Copy Markdown
Contributor Author

PO acceptance: merge at e2a6923

Independent PO flagship review (901637c1-aefe-4c17-867c-f2b800df8fc5): APPROVE (0 P0/P1/P2 findings).

  • Verified RPC parity with 20261202120000_give_discovery_v2_filters.sql, 100-ID chunking & fail-closed statement freshness, strict prelaunch suppression on cards/discovery/home strips, DESIGN.md & WCAG accessibility, and green CI/DOScout/Vercel.
  • 3 minor P3 nits noted (non-blocking).

@JOY
JOY (JOY) merged commit d71631c into dev Nov 22, 2026
6 checks passed
@JOY
JOY (JOY) deleted the antigravity/give-318-discovery-v2 branch November 22, 2026 16:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

line:campaigns Product line: campaigns po:agy Owned by Antigravity PO (mutual-exclusion parallel PO label)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant