feat(merchants): add merchant discovery and location management#102
Open
ryzen-xp wants to merge 1 commit into
Open
feat(merchants): add merchant discovery and location management#102ryzen-xp wants to merge 1 commit into
ryzen-xp wants to merge 1 commit into
Conversation
- Add public `/merchants/available` endpoint to find merchants near caller within radius and amount constraints - Add authenticated `PATCH /merchants/me/location` endpoint for merchants to set/update their location and address - Add authenticated `GET /merchants/me/trades` endpoint for merchants to view their trades with optional state filtering - Add `useMerchantsAvailable` React hook for frontend merchant discovery queries - Add `getAvailableMerchants` service function with Haversine distance calculation in SQL - Extend `MerchantConfig` interface with latitude, longitude, and address_text fields - Add `AvailableMerchant` and `AvailableMerchantsQuery` interfaces for type safety - Create `002_merchant_discovery.sql` migration to add location columns to merchant_configs table - Update DepositMap and ExploreMap pages to use merchant discovery API - Update API service with merchant discovery endpoints - Enables location-based merchant matching for cashout and deposit flows
|
@ryzen-xp Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What was implemented
Backend (
micopay/backend)src/routes/merchants.ts— added 3 new endpoints:GET /merchants/available?lat&lng&radius_km&amount_mxn&flow— public, returns merchants sorted by haversine distance, filtered by amount range and availabilityPATCH /merchants/me/location— authenticated, lets a merchant set their lat/lng/addressGET /merchants/me/trades— authenticated, returns the merchant's trade history (was already called from frontend but missing from backend)src/services/merchant.service.ts— added:getAvailableMerchants()— haversine SQL query withLEAST(1.0, ...)guard to preventacosdomain errors, filters bymerchant_available, location not null, amount within min/max, distance within radiusgetOrCreateMerchantConfigandupdateMerchantConfigto includelatitude,longitude,address_textfieldssql/migrations/002_merchant_discovery.sql— createsmerchant_configstable (idempotent) and adds location columns withALTER TABLE … ADD COLUMN IF NOT EXISTSFrontend (
micopay/frontend)src/services/api.ts— added:getMerchantsAvailable(query)— callsGET /merchants/availableupdateMerchantLocation(token, lat, lng, address)— callsPATCH /merchants/me/locationAvailableMerchantandMerchantsAvailableQuerytypessrc/hooks/useMerchantsAvailable.ts— new hook that:location_deniedstateMerchantsStateunion:idle | loading | location_denied | error | empty | successrefetch()for retrysrc/pages/ExploreMap.tsx— fully rewritten:useMerchantsAvailablewithflow: 'cashout'DEFAULT_OFFERSarray removed entirelyonSelectOffer(offer.id)now passes the realseller_idUUIDsrc/pages/DepositMap.tsx— fully rewritten:useMerchantsAvailablewithflow: 'deposit'onSelectOfferpasses realseller_id