B2B Portal React 18 · CRA + Craco TypeScript 4.9 Tailwind CSS 3 @kioskgaming/ui

Agent Portal (Dealer Gate)

Interface dedicated toAgency— network management regional distributor gaming shop, credits purchase/distribution, online USD wallet, cash transaction monitoring, and communication with the kiosk ecosystem.

17+
Route protection
2
Wallet (Credit + USD)
Shops management
B2B
Credit Economy

Location in the system

Agent is the second layer in KioskGaming's four-layer hierarchy. Each Agent is in charge many Shops and receive credits from SuperAgent or the platform.

👑  SuperAgent
🏢  Agent YOU ARE HERE
🏪  Shop
💵  Cashier
🎮  Player
🏢

Agent:Regional distributor. Buy credits from SuperAgent/platform, sell credits to shops via cash transactions (cash-credits), establishcostRatefor each shop and monitor credit wallet + online USD wallet.

🔗

B2B Chain: SuperAgent → Agent→ Shop → Cashier → Player. Credits flow down; Cash/USD flows back upcostRate.

💡

Repo notes:Nested folderkioskgaming_backend/just a reference backend clone — the frontend calls the API viaREACT_APP_API_BASE_URL, do not import backend code.

Dali Journey

The standard operating process of an Agent from purchasing credits to monitoring shop performance.

1. Buy Credits from Platform

Agent opensCreditPurchaseModal, select quantity and payment method (ZeroX crypto, eCash, bank transfer...). After payment is completed, credits are added to the Agent's wallet.

2. Sell Credits to Shop (Cash Sale)

From the shop details page, use AgentSellCreditsCashToShopTrigger (SellCreditsCashModalfrom@kioskgaming/ui) call POST /agent/shops/:id/cash-credits— record cash paid by the shop and distribute credits simultaneously.

3. Create and Configure Shop

Agent creates a new shop with information: name, email, phone number, password and costRate— decimal rate (0.05 = 5%) Agent collects on each credit delivered to that shop.

4. Performance Monitoring

Dashboard displays credits balance, shop list, number of players, recent transactions andAgentHierarchyMiniTree— visual hierarchy tree Agent → Shops.

5. Shop Administration (Governance)

If the shop violates, the Agent uses itShopGovernanceModalto pause (Suspend), reopen (Unsuspend) or terminate the contract (Terminate) of a shop.

Shop Manager

Agent has full CRUD rights for Shops within its scope, including setting prices and control operating status.

🏪

Create a new Shop

Usage formreact-hook-formv7. Fields: name, username, email, phone, password andcostRate (% → cost_ratedecimal). File:ShopsPage.tsx

📋

List of Shops

List all shops with status, credits balance, number of players and quick action button. Support distributing credits directly from the list.

🔍

Shop details

Route /shops/:shopIduseShopDetailPageRedesign.tsx (import alias ShopDetailPage). Display credit/USD shop wallet, game mapping, sell/withdraw credits.

⚖️

Shop Governance Modal

ShopGovernanceModal.tsxprovides three administrative actions with validation:Suspend, Unsuspend, Terminate.

costRate — Credit price ratio

💰

costRateis a decimal number 0–1 (eg 0.05 = 5%). Shop must have costRatebiggeragent's costRate. Amount owed by shop = credits × shopCostRate; agent profit = credits × (shopCostRate − agentCostRate). UseformatCostRate()andpercentInputToRate() in costFormat.ts.

Shop status Show Agent can do it Transaction
Active Green badge Distribute credits, view details, Suspend / Terminate Normal
Suspended Golden badge Unsuspend, Terminate, see details Blocked
Terminated Red badge View only — cannot be restored Closed

Credits system

Credits are the intermediate currency in the system. Agent buys credits from the platform and distributes them Go to the shops to let the shops serve the players. This is the core currency flow of the entire ecosystem.

Credits Stream

Platform / SuperAgent
Agent Wallet
Shop Wallet
Player Sessions

Two wallets: Credit + USD Online

💳

Credit Wallet (CDN)

Balancecredit_balanceon dashboard. Buy itCreditPurchaseModal, convert from USD toconvertBalanceToCredits. Ledger at/transactions.

💵

USD Online Wallet

online_balance_net— accumulated commission/cash. Page/online-transactions, withdraw crypto via OTP +createAgentOnlineBalanceWithdrawal.

CreditPurchaseModal — Buy credit online

1

Choose the amount

Agent enters or selects the amount he wants to buy. With eCash, only select from a fixed list (ECASH_APP_ALLOWED_AMOUNTS).

2

Choose payment method

Show options: ZeroX crypto, eCash app, bank transfer, etc. Each method has its own separate UI.

3

Confirmation & Pay

Modal embed iframe checkout provider + open new tab button. ZeroX static wallets via/agent/payments/zeroxprocessing/static-wallets.

4

Confirm completion

AgentPaymentReturnPage.tsxReceive redirect after payment. Credits are added to the Agent wallet.

Payment method

🔮

ZeroX Crypto— Cryptocurrency payments. Display wallet address, QR code. Options defined atZEROX_PAYMENT_OPTIONS.

📱

eCash App— Internal payment application. Only accept denominations listed inECASH_APP_ALLOWED_AMOUNTS.

🏦

Bank Transfer— Traditional bank transfer with account information provided.

SellCreditsCashToShopTrigger — Sell credits to shops

📤

Sell ​​credits (cash-credits)

SellCreditsCashToShopTriggeron Shop Detail callcreateShopCashCredits. Record cash transactions + distribute credits once.

📥

Withdraw credits from the shop

WithdrawCreditsFromShopTriggerPOST /agent/shops/:id/credits/withdraw. Refund credits to agent wallet when needed.

Broadcast & Notification

Agents have many communication channels with shops and players: system-wide broadcast, targeted popups and real-time notification bell.

📢

SendBroadcastPage

Send a broadcast message to all shops/players belonging to the Agent. Link markup support is handled bybroadcastLinkMarkup.ts.

💬

SendShopPopupPage

Send notification popups to a specific shop. Suitable for privacy alerts, store-specific promotion announcements.

🔔

AgentNotificationBell

Bell icon with badge counting the number of unread notifications. Displayed in the header of every page. Demo:🔔 3Notification

AgentInAppPopupGate

🚪

AgentInAppPopupGate.tsxis a wrapper component placed at a high level in the component tree. It listens for broadcasts/popups coming from the server andautomatically block the screento display a message before the Agent continues using the app.

🔗

broadcastLinkMarkup.ts:The parser converts special link syntax in broadcast content into clickable HTML anchor tags.BroadcastMessageBody.tsxrender the parsed result.

Broadcast stream

1

Agent composes message

Enter content; link markup supported [text](url).

2

Distribution server

Backend sends message to all shops/players under Agent.

3

InAppPopupGate blocks

Shops/players receive popup overlay on login or in real time.

Dashboard & Analytics

Dashboard Home (DashboardPage.tsx) is the Agent's operating center — providing Instant overview of the entire network.

🌳

AgentHierarchyMiniTree

AgentHierarchyMiniTree.tsx— Compact hierarchical tree displayed right on the Dashboard. Visualize the Agent → Shops relationship with summary metrics for each branch.

💳

AvailableCreditsCallout

AvailableCreditsCallout.tsx— featured block displays the Agent's current credit balance, with "Buy Credits" and "Distribute" buttons for quick access.

🧾

AgentHomeRecentTransactions

AgentHomeRecentTransactions.tsx— most recent transactions displayed on Dashboard. List type, amount, shop involved and time.

📈

AgentTransactionsPage

Full transaction history page (AgentTransactionsPage.tsx) with filter by time, transaction type and shop.

Widgets on Dashboard

Widget Component Data displayed Action
Credit Balance AvailableCreditsCallout Agent wallet balance Purchase/Distribution
Shops Overview DashboardPage Total shops, active / suspended See details
Players Count DashboardPage Total players under all shops Xem PlayersPage
Recent Transactions AgentHomeRecentTransactions 5–10 most recent transactions See all
Hierarchy Tree AgentHierarchyMiniTree Agent tree → Shops Drill-down shop

Technique

Technical stack, directory structure, important utilities and ZeroX payment integration.

Directory structure

src/
pages/
DashboardPage.tsx // Agent home page
ShopsPage.tsx // Manage shops
ShopDetailPage.tsx
ShopDetailPageRedesign.tsx
PlayersPage.tsx
AgentPlayerDetailPage.tsx
AgentTransactionsPage.tsx
SendBroadcastPage.tsx
SendShopPopupPage.tsx
OnlineBalanceTransactionsPage.tsx
CashTransactionsLedgerPage.tsx
ProviderFeesPage.tsx · FraudIndicatorsPage.tsx
SendBroadcastPage.tsx · SendShopPopupPage.tsx
SettingsPage.tsx · AgentPaymentReturnPage.tsx
components/credits/
CreditPurchaseModal.tsx · SellCreditsCashToShopTrigger.tsx
WithdrawCreditsFromShopTrigger.tsx · AvailableCreditsCallout.tsx
services/ api.ts // prefix /agent/*
craco.config.js // webpack + @kioskgaming/ui

Technical stack

CRA + Craco 7 TypeScript 4.9 React Router v6 Tailwind CSS 3 @kioskgaming/ui @kioskgaming/page-loading Axios · react-hot-toast

costFormat.ts — Main Utilities

// Switch display % → internal rate
percentInputToRate(5)  // "5%" → 0.05

// Internal format rate → display
formatCostRate(0.05)   // 0.05 → "5%"

Important constants

// eCash: only allows fixed denominations
ECASH_APP_ALLOWED_AMOUNTS = [
  50, 100, 200, 500, 1000
]

// ZeroX: crypto option
ZEROX_PAYMENT_OPTIONS = [
  { id: 'eth', label: 'Ethereum' },
  { id: 'usdt', label: 'USDT' },
  ...
]

ZeroX Crypto Integration

🔮

ZeroXis the platform's crypto payments integration. Agent chooses token (ETH, USDT...), The system displays the wallet address and QR code. After the on-chain transaction is confirmed, Backend webhook updates Agent balance automatically.

🔒

sanitizeUser.tssanitize user data before displaying — remove sensitive information, standardize field names. Used before rendering any user object to the UI.

React Router v6 — Main route

Route Component Function
/ DashboardPage Home — credits + USD balance
/transactions AgentTransactionsPage Ledger credit wallet
/online-transactions OnlineBalanceTransactionsPage Ledger USD wallet + withdrawal
/cash-transactions CashTransactionsLedgerPage Cash transactions with shops
/provider-fees ProviderFeesPage Provider fee (read-only)
/fraud-indicators FraudIndicatorsPage Warning about cheating players
/shops ShopsPage List + create shop
/shops/:shopId ShopDetailPageRedesign Shop details + sell/withdraw credits
/players PlayersPage Players (read-only)
/broadcasts/send SendBroadcastPage Send broadcast
/popups/send SendShopPopupPage Send in-app popups
/settings SettingsPage 2FA, balance alerts, verification
/payment/{success,cancelled,error} AgentPayment*Page Callback after online payment

Managing Players

Agents have visibility over all players belonging to all shops in the network, but do not directly interfere with player accounts.

👥

PlayersPage

Lists all players across all Agent shops. Can filter by shop and status. Displays username, source store, balance, registration date.

👤

AgentPlayerDetailPage

View details of a player: personal information, transaction history, recent sessions, which shop manages it. Read-only from the Agent side.

ℹ️

Note on authorization: Agent Are nothas the right to create, edit or delete players. Players are created by the Shop or registered themselves. Agent only has rights to view players within your network.

Quick synthesis

📄

17+ Routes

Dashboard, Shops, ShopDetail, Players, Transactions, Online/Cash transactions, Provider fees, Fraud, Broadcast, Popup, Settings, Payment return

🧩

API prefix

/agent/*, /agent-auth/* via Axios singleton services/api.ts → backend B2B routes

🛠️

Build

craco start/build · packages file:../packages/ui + page-loading · PORT 3003

💳

Two wallets

Credit CDN + USD online balance; Buy online, sell cash to the shop, withdraw crypto

📐

Hierarchy

SuperAgent → Agent → Shop → Cashier → Player

🎯

Technical details

Xem 04+ Technical details— full endpoint, auth, cookbook