- Port halo_tokens + halo_theme + HaloButton to mitra_app (rose palette, Bricolage display, Poppins body, JetBrainsMono). - Build S3a Input WhatsApp (figma-bestie BestieS3 first half) with +62 chip, leading-zero/62 normalization, allow '+' in input. - Build S3b OTP verification (6-digit, 60s resend timer, attempts hint, Focus(canRequestFocus:false) for maestro inputText compat) with full error branching (CODE_MISMATCH, OTP_EXPIRED, OTP_USED, ATTEMPTS_EXCEEDED, WRONG_FLOW, ACCOUNT_INACTIVE). - Add AccountInactive terminal screen for is_active=false mitras. - Typed MitraAuthError with Indonesian-first localized messages + retryAfterSeconds passthrough. - Rebuild home_screen.dart to match figma BestieHome (greeting + status card + Ganti Status CTA + Pengingat + 2-tile dark grid). - Backend: POST /internal/_test/seed-mitra (idempotent) and PATCH /internal/mitras/:id (display_name update). - Control center: inline Edit Nama on mitras row + expandable inline log table under clicked mitra (vs old below-table panel). - 5 maestro flows ts-mitra-A-01/03/04/05/06 covering invalid input, happy path, account inactive, phone-format normalization, and the back-to-S3a regression. All green. Plan + memory documented in: - requirement/phase4-mitra-prehome-plan.md - requirement/flow_mitra.md / flow_mitra.mermaid.md §A Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
3.4 KiB
3.4 KiB
Application Flow for Mitra App
We are defining mitra flow along with the app referenced on the claude design
A. Pre-Home (auth)
The mitra app has no Google/Apple login — phone OTP only. All limits live on the
backend (see backend/src/services/otp.service.js + config.service.js); the
app must surface them clearly so a stuck mitra knows what to do.
A1. Boot — token gate
- App boot → check stored refresh token
- Valid session → go straight to Home (skip auth)
- No / expired refresh → go to Login screen
A2. S3a · Input WhatsApp
- Show phone number field (E.164, hint
+628xxxxxxxxxx) - "Kirim OTP" submit →
POST /api/mitra/auth/otp/request - Error responses:
PHONE_INVALID(422) → inline field error "Format nomor salah"OTP_COOLDOWN(429) → snackbar "Tunggu N detik sebelum minta kode baru" usingretry_after_secondsOTP_RATE_LIMIT_PHONE(429) → popup "Terlalu banyak permintaan untuk nomor ini. Coba lagi dalam N menit" (useretry_after_seconds)OTP_RATE_LIMIT_IP(429) → popup "Terlalu banyak permintaan dari jaringan ini. Coba lagi nanti / hubungi admin"
- Success → push OTP screen with
otp_request_id+ masked phone
A3. S3b · OTP verification (6-digit)
- Show 6 digit fields + masked phone reminder
- Auto-submit when 6 digits entered →
POST /api/mitra/auth/otp/verify - Show "Tersisa N percobaan" hint when attempts have been used (compute from local counter; backend doesn't expose it)
- Show "Kirim ulang kode" button — disabled until 60s cooldown elapses, with countdown timer
- Error responses:
CODE_INVALID(422) → inline "Kode harus 6 digit angka"CODE_MISMATCH(401) → clear fields, inline "Kode salah · tersisa N percobaan", focus first digitOTP_ATTEMPTS_EXCEEDED(429) → blocked popup "Terlalu banyak percobaan" with CTAs: "Minta kode baru" (back to Login) / "Hubungi admin"OTP_EXPIRED(410) → popup "Kode kadaluarsa" → CTA "Minta kode baru" (back to Login pre-filled)OTP_USED(409) → same asOTP_EXPIRED(treat as terminal — user must request a new code)WRONG_FLOW(400) → popup "Kode ini bukan untuk akun mitra. Pastikan kamu pakai app yang benar"ACCOUNT_INACTIVE(403) — comes from verify endpoint after a valid code, before token issuance → full-screen "Akun belum aktif" state with admin contact CTAs (WhatsApp / Telegram). No retry.
- Success → store tokens → push Home
A4. Resend OTP (from S3b)
- From S3b → tap "Kirim ulang kode" (only enabled after 60s)
- Hits same
POST /api/mitra/auth/otp/request→ newotp_request_idreplaces old - Resets the local attempts counter to 0
- Same error scenarios as A2 (cooldown / rate-limit) apply
B. Home onwards
mitra app flow:
-
Home screen
-
Undangan CTA -> Show Undangan · pending invitations
-
Perpanjang CTA -> Show Undangan · Perpanjang Curhat
-
Profil CTA -> show Bestie Profile · profil
-
Status Offline?
- Status offline -> Show Bestie Home · OFFLINE
- Status online -> Show Bestie Home · standby & status. Goto next step
-
incoming chat request:
- New chat -> Show Popup · incoming Curhat Baru
- Extend chat -> Show Popup · incoming Perpanjang
-
Accept chat request?
- Reject -> Close dialog and Go to hoome screen
- Accept -> Show Bestie Chat Room · sesi aktif
-
Session end -> Bestie Chat · durasi habis