Skip to content

feat: add MerchantApplicationModal and integrate into MerchantSection#35

Open
Obiajulu-gif wants to merge 4 commits intoPACTO-LAT:developfrom
Obiajulu-gif:feature/refactor_merchant
Open

feat: add MerchantApplicationModal and integrate into MerchantSection#35
Obiajulu-gif wants to merge 4 commits intoPACTO-LAT:developfrom
Obiajulu-gif:feature/refactor_merchant

Conversation

@Obiajulu-gif
Copy link

@Obiajulu-gif Obiajulu-gif commented Jan 30, 2026

Close #29
This pull request introduces a merchant application workflow to the user profile section, allowing users to apply to become merchants and view the status of their application. The main changes include a new modal for merchant applications, updates to the profile UI to handle application states, and backend adjustments to set the initial verification status.

Merchant Application Workflow Implementation:

  • Added a new MerchantApplicationModal component that provides a form for users to apply as merchants, including validation, submission handling, and user feedback.
  • Updated the MerchantSection component to:
    • Display an "Apply to Become a Merchant" button that opens the modal if the user is not a merchant.
    • Show merchant status badges (e.g., "Application Pending", "Application Rejected", "Access Revoked") based on the user's verification status.
    • Integrate the new modal and handle loading/application state transitions. [1] [2] [3] [4]

Backend Integration:

  • Modified the Supabase merchant adapter to ensure new merchant applications are created with a verification_status of 'pending'.

Summary by CodeRabbit

  • New Features

    • Merchant application modal with biography form, validation, loading state, toast feedback, and reset/close behavior
    • Merchant section shows conditional actions and verification status badges; includes apply and browse flows
    • New merchant applications are created with a pending verification status
  • Documentation

    • Added descriptive JSDoc for admin forms and transaction card components
  • Refactor

    • Made environment-aware, lazily-initialized client for backend interactions (improves reliability and error messaging)

✏️ Tip: You can customize this high-level summary in your review settings.

@vercel
Copy link

vercel bot commented Jan 30, 2026

@Obiajulu-gif is attempting to deploy a commit to the Trustless Work Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link

coderabbitai bot commented Jan 30, 2026

📝 Walkthrough

Walkthrough

Adds a merchant application modal and integrates it into the MerchantSection; new merchant inserts set verification_status: 'pending'. Introduces a lazy, environment-validated Supabase client export with helper functions and a cached client getter.

Changes

Cohort / File(s) Summary
Merchant Application Modal
apps/web/components/merchant/MerchantApplicationModal.tsx
New client React modal using react-hook-form + zod for a biography field; derives display_name/slug from user context, calls useUpsertMerchantProfile, shows toasts, prevents close while submitting, resets and closes on success.
Merchant Section Integration
apps/web/components/profile/MerchantSection.tsx
Adds useMeMerchant, local open state, conditional rendering of Apply CTA vs dashboard/links, loading state for Apply, and mounts MerchantApplicationModal.
Merchant Adapter
apps/web/lib/adapters/merchant.supabase.ts
upsertMyMerchantProfile insert path now includes verification_status: 'pending' when creating new merchant records.
Supabase client & env helpers
apps/web/lib/supabase.ts
Reworked to lazily initialize/cache SupabaseClient via getSupabaseClient() and a Proxy supabase export; added get/require env helpers and clearer server-client fallback logic. (Public export shape changed.)
Docs / JSDoc additions
apps/web/components/admin/BurnForm.tsx, apps/web/components/admin/MintForm.tsx, apps/web/components/admin/TransactionCard.tsx
Added JSDoc comment blocks above exported components; no behavioral changes.

Sequence Diagram

sequenceDiagram
    participant User as User
    participant Modal as MerchantApplicationModal
    participant Form as Form (react-hook-form)
    participant Hook as useUpsertMerchantProfile
    participant Adapter as merchant.supabase
    participant DB as Database

    User->>Modal: Click "Apply to Become a Merchant"
    Modal->>User: Open dialog
    User->>Form: Fill biography and submit
    Form->>Form: Validate bio (zod: min length)
    Form->>Modal: Submit payload (includes derived display_name/slug)
    Modal->>Hook: Trigger mutation with payload
    Hook->>Adapter: upsertMyMerchantProfile(payload)
    Adapter->>Adapter: Ensure insertPayload includes verification_status: 'pending'
    Adapter->>DB: Insert merchant record
    DB-->>Adapter: Insert success
    Adapter-->>Hook: Return result
    Hook-->>Modal: Mutation success
    Modal->>User: Show success toast, close and reset modal
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Suggested reviewers

  • Bran18

Poem

🐰 A modal pops up, twitchy and spry,
I type my bio beneath the sky,
Submitted, marked "pending", a carrot cheer,
The rabbit hops off — the dashboard's near! 🥕

🚥 Pre-merge checks | ✅ 3 | ❌ 2
❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning Changes to BurnForm, MintForm, TransactionCard, and supabase.ts are unrelated to the merchant application workflow objective and appear to be out-of-scope. Remove documentation-only changes to BurnForm, MintForm, TransactionCard, and the Supabase client refactoring; focus the PR on merchant application implementation.
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and accurately summarizes the primary changes: introducing MerchantApplicationModal and integrating it into MerchantSection.
Linked Issues check ✅ Passed The PR successfully implements all core requirements from issue #29: modal form with bio validation, auto-population of user fields, pending status on creation, success feedback, and conditional UI in MerchantSection.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@Obiajulu-gif
Copy link
Author

@aguilar1x review the code and remember to allocate compliments point... Thank you

…iable handling

- Introduced functions to retrieve and validate Supabase environment variables.
- Implemented a caching mechanism for the Supabase client to avoid redundant initializations.
- Used a Proxy to dynamically access Supabase client methods and properties.
- Updated server client creation to utilize the new environment variable handling.
- Added error handling for missing environment variables with a descriptive message.
@Obiajulu-gif
Copy link
Author

@aguilar1x review my code

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.

Refactor the Merchant Application Form (Modal from Profile → Merchant Tab)

1 participant

Comments