Tích hợp API
Tất cả HTTP calls nằm trong src/services/api.ts.
Base URL: {REACT_APP_API_BASE_URL} — mặc định http://localhost:3001/api
Auth header: Authorization: Bearer {agent_auth_token}
401 handling: Axios interceptor dispatch auth:unauthorized → logout.
Auth & Account
| Method | Endpoint | Function | Mục đích |
|---|---|---|---|
| POST | /agent-auth/login | loginWithUsernameOrEmail | Login agent |
| POST | /agent-auth/verify-otp | verifyPortalLoginOtp | Xác minh OTP login |
| POST | /agent-auth/forgot-password/request-otp | requestForgotPasswordOtp | Bước 1 quên mật khẩu |
| POST | /agent-auth/forgot-password/verify-otp | verifyForgotPasswordOtp | Bước 2 quên mật khẩu |
| POST | /agent-auth/forgot-password/confirm | confirmForgotPasswordReset | Bước 3 đặt mật khẩu mới |
| PATCH | /agent/settings/two-factor | patchPortalTwoFactor | Bật/tắt 2FA |
| PATCH | /agent/settings/low-balance-warning | patchAgentLowBalanceWarning | Cảnh báo số dư thấp |
| POST | /agent/verify/send-otp | sendAgentVerificationOtp | Gửi OTP xác minh agent |
| POST | /agent/verify/confirm | confirmAgentVerificationOtp | Xác nhận OTP agent |
Dashboard & Credits
| Method | Endpoint | Function | Mục đích |
|---|---|---|---|
| GET | /agent/dashboard | fetchDashboard | Số dư, thống kê shops/players |
| POST | /agent/credits/purchase | purchaseCredits | Mua credits (redirect payment) |
| POST | /agent/convert-balance-to-credits | convertBalanceToCredits | USD → credits |
| POST | /agent/credits/distribute | distributeCredits | Phân phối credit xuống shop |
| POST | /agent/shops/:shopId/credits/withdraw | withdrawCreditsFromShop | Rút credit từ shop về agent |
| GET | /agent/payments/zeroxprocessing/static-wallets | listZeroxStaticWallets | Danh sách ví crypto tĩnh |
| POST | /agent/payments/zeroxprocessing/static-wallets/init | initZeroxStaticWallets | Khởi tạo ví crypto |
Agent Transactions (Credit ledger)
| Method | Endpoint | Function | Mục đích |
|---|---|---|---|
| GET | /agent/transactions | fetchAgentTransactions | Credit ledger |
| GET | /agent/transactions/:id | fetchAgentCreditTransactionById | Chi tiết giao dịch |
| GET | /agent/transactions/export | exportAgentWalletTransactions | Export CSV |
Online Balance / USD Wallet
| Method | Endpoint | Function | Mục đích |
|---|---|---|---|
| GET | /agent/online-balance/ledger | fetchAgentOnlineBalanceLedger | USD ledger |
| GET | /agent/online-balance/ledger/:id | fetchAgentUsdLedgerEntryById | Chi tiết USD entry |
| GET | /agent/online-balance/ledger/export | exportAgentOnlineBalanceLedger | Export CSV |
| GET | /agent/online-balance/withdrawals/otp/eligibility | fetchAgentWithdrawalOtpEligibility | Kiểm tra OTP |
| POST | /agent/online-balance/withdrawals/otp/send | sendAgentWithdrawalOtp | Gửi OTP |
| POST | /agent/online-balance/withdrawals/otp/verify | verifyAgentWithdrawalOtp | Xác minh OTP |
| POST | /agent/online-balance/withdrawals | createAgentOnlineBalanceWithdrawal | Tạo rút USD |
| GET | /agent/online-balance/withdrawals/fee | fetchAgentOnlineBalanceWithdrawalFee | Preview phí |
| GET | /agent/portal-withdrawal-limits | fetchAgentPortalWithdrawalLimits | Giới hạn rút |
Shops
| Method | Endpoint | Function | Mục đích |
|---|---|---|---|
| GET | /agent/shops | fetchShops | Danh sách shop |
| GET | /agent/shops/stats | fetchAgentShopHierarchyStats | Thống kê hierarchy theo ngày |
| GET | /agent/shops/:shopId | fetchShop | Chi tiết shop |
| POST | /agent/shops | createShop | Tạo shop mới |
| PATCH | /agent/shops/:shopId/suspend | suspendShop | Suspend shop |
| PATCH | /agent/shops/:shopId/unsuspend | unsuspendShop | Unsuspend shop |
| PATCH | /agent/shops/:shopId/cost | updateShopCost | Cập nhật cost rate |
| PATCH | /agent/shops/:shopId/name | updateShopName | Đổi tên shop |
| PATCH | /agent/shops/:shopId/password | updateShopPassword | Đổi password shop |
| PATCH | /agent/shops/:shopId/popup-permissions | updateShopPopupPermission | Quyền popup shop |
| GET | /agent/shops/:shopId/wallets | fetchAgentShopWallets | Wallets của shop |
| GET | /agent/shops/:shopId/transactions | fetchAgentShopWalletTransactions | Credit ledger shop |
| GET | /agent/shops/:shopId/transactions/:id | fetchAgentShopCreditTransactionById | Chi tiết credit tx shop |
| GET | /agent/shops/:shopId/online-balance/ledger | fetchAgentShopOnlineBalanceLedger | USD ledger shop |
| GET | /agent/shops/:shopId/online-balance/ledger/:id | fetchAgentShopUsdLedgerEntryById | Chi tiết USD entry shop |
| GET | /agent/shops/:shopId/game-mappings | fetchShopGameMappings | Game mappings |
| PUT | /agent/shops/:shopId/game-mappings | putShopGameMappings | Cập nhật game mappings |
Players
| Method | Endpoint | Function | Mục đích |
|---|---|---|---|
| GET | /agent/players | fetchAgentPlayers | Danh sách players |
| GET | /agent/players/:playerId | fetchAgentPlayer | Chi tiết player |
| GET | /agent/players/:playerId/transactions | fetchAgentPlayerTransactions | Lịch sử giao dịch player |
Provider Fees & Payment
| Method | Endpoint | Function | Mục đích |
|---|---|---|---|
| GET | /agent/provider-fees | fetchProviderFeeConfigs | Bảng phí (read-only) |
| GET | /payment/provider-fee-rate | getProviderFeeRate | Tỷ lệ phí |
| GET | /payment/supported-methods | useSupportedZeroxMethods (hook) | Phương thức hỗ trợ (public) |
Broadcasts & Popups
| Method | Endpoint | Function | Mục đích |
|---|---|---|---|
| GET | /agent/broadcasts | fetchAgentBroadcasts | Danh sách broadcast |
| POST | /agent/broadcasts/:id/ack | ackAgentBroadcast | Acknowledge broadcast |
| POST | /agent/broadcasts | createAgentBroadcast | Gửi broadcast |
| GET | /agent/in-app-popups/unseen | fetchAgentInAppPopupsUnseen | Popup chưa xem |
| POST | /agent/in-app-popups/:id/seen | markAgentInAppPopupSeen | Đánh dấu đã xem |
| POST | /agent/in-app-popups/:id/never-again | markAgentInAppPopupNeverAgain | Không hiện lại |
| POST | /agent/in-app-popups | createAgentInAppPopup | Gửi popup |
Fraud & Games
| Method | Endpoint | Function | Mục đích |
|---|---|---|---|
| GET | /agent/player-fraud-indicators | fetchAgentPlayerFraudIndicators | Fraud player (list) |
| GET | /agent/player-fraud-indicators/:id | fetchAgentPlayerFraudIndicatorDetail | Chi tiết |
| GET | /agent/player-fraud-indicators/transaction/:id/profit-analysis | fetchAgentPlayerFraudWithdrawalAnalysis | Phân tích profit |
| POST | /agent/player-fraud-indicators/:id/resolve | resolveAgentPlayerFraudIndicator | Resolve indicator |
| GET | /game-providers | fetchPublicGameProviders | Danh sách game providers |