Commit Graph

11 Commits

Author SHA1 Message Date
Amiram_se ed6ddc05b1 feat(apps): call the API through a same-origin /api rewrite
- next.config rewrites /api/:path* to API_INTERNAL_ORIGIN, with a 120 s proxy timeout for uploads; NEXT_PUBLIC_API_ORIGIN is gone.
- The browser HTTP base is /api/v1; media, avatars and uploads load through /api (market env `apiBaseUrl`), so private media gets the session cookie.
- toApiUrl keeps a narrow rule for uploads stored with a host before the back end stored paths.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-06 21:47:18 +04:00
Amiram_se cfa8cce1b0 refactor: code review 2026-10-06 17:12:50 +04:00
Amiram_se 436695ae0b feat(market): registration step 5, profile completion
Creator (required, resumable) and investor (optional) profile steps, on the
session after registration step 4.

- Profile repository: `saveDraft` (PATCH /traders/me/profile, markets may be
  empty) and `complete` (POST /traders/me/profile/complete).
- Account repository: avatar upload and removal, `interests`; the account
  payload carries `avatarUrl` and `interests`.
- Actions: completeCreatorProfile (saves the form, then completes; emits
  `profile.complete`) and saveInvestorProfile (photo with progress, then
  markets; emits `auth.profile-saved`).
- Creator models: the page (form from the saved draft, links field array,
  submit), autosave (1 s after typing and on blur, one save at a time, never
  after completion), the photo part (uploads on pick, failed state with retry)
  and the live preview.
- Investor model: photo and markets saved on «ذخیره و ورود», «بعداً» skips;
  both land on ?redirect= or home with the welcome toast.
- The auth-flow store remembers the role registered in this tab, so step 5
  shows the resume banner only after a login or a reload.
- Validations: photo, bio, link rows per platform, markets, consent.
  Utils: social link handle and URL mapping, market toggle. PROFILE_LIMITS
  moves to shared/validations.
- Screens: CreatorProfileStep (mobile column with a preview sheet, desktop
  card beside a sticky preview, end-of-registration view) with its skeleton,
  and InvestorProfileStep.
- Copy for step 5 in the auth namespace; market and status labels in common.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-05 22:33:00 +04:00
Amiram_se 02e543d95d refactor(market,apps): share the registration frame with onboarding
Registration step 5 lives under (onboarding), so the pieces both route groups
use move to the nearest level they share. No behavior change.

- SupportEntry and RegisterProgress move from screens/(auth) to
  screens/organisms.
- bull's AuthTopBar and both apps' AuthTemplate move from the (auth) group to
  the app root's organisms/ and templates/.
- MARKETS and Market move from the profile feature to shared/constants, so
  features other than profile (the investor's interests) can use them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-05 22:32:05 +04:00
Amiram_se d43e74237f feat(market): login and registration flow
- auth-flow store: the number, code timing, misses, block, registration
  token and step-4 draft, in memory only (never URL, cookie or storage).
- Auth repository maps the gateway's English error text to codes and
  Persian copy (AUTH_ERROR_CODES, AUTH_ERROR_COPY, blockEndOf).
- Actions: sendCode, verifyRegistrationCode; login turns a suspended
  account away and closes its session; register actions reset the flow and
  creator registration reports upload progress and can be cancelled.
- Models: shared code step (wrong/expired codes, 3-miss block, resend),
  login, login verify (landing per role and unfinished creator profile),
  registration type, phone, verify and details (token warning and halt,
  investor and creator parts).
- Screens under (auth): support entry, code step, login, login verify with
  the suspended notice, registration progress and steps 1-4.
- Navigation: auth routes, withReturnPath and useAuthRoutes; GuestGuard keeps
  the page through its own sign-in.
- Shared: valibot auth schemas (phone, code, names, username, national ID,
  ID card image), showActionError, applyServerErrors, translateMessage,
  mobile helpers, and the `auth` locale namespace.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-05 20:06:42 +04:00
Amiram_se dc229a3949 refactor(market,apps): share PageError from market screens
Both apps had their own copy of the page error boundary. It now lives
once in platforms/market/src/app/screens/organisms/page-error, and every
route group's error.tsx re-exports it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-05 19:00:28 +04:00
Amiram_se aafac927bf refactor(market,apps): drop the session proxy and restore auth in the browser
The server render no longer depends on auth: it reads no session and
forwards only FORWARDED_COOKIES (none today), so every visitor of a URL
gets the same HTML and the Next.js proxy is no longer needed.

- Remove proxy.ts from bull and bear, the app/session module, the
  server auth and role guards, and the server caches that read the
  viewer's own data. Public caches stay: channel, post, prediction stats.
- Add an auth store (status unknown | guest | member) filled by the
  restoreSession action, which reads GET /auth/session once per load
  from the AppShell's useSession hook.
- Login and register actions set the store, logout clears it; the
  AppShell clears the query cache on auth.logout. No router.refresh.
- Add client AuthGuard (fallback, optional role) and GuestGuard, with
  safeReturnPath limiting post-login redirects to same-site paths.
- readOnServer no longer redirects on 401.
- The browser HTTP client refreshes against AUTH_ENDPOINTS.refresh.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-04 22:28:05 +04:00
Amiram_se a483fc0767 feat(market): app foundation, session handling and feature data layer
Foundation
- AppShell: query client, i18n, connection bar (NetworkBoundary), toast region,
  and reactions to sign-in and sign-out
- error boundaries: ErrorFallback, PartBoundary (catchError), StatusEmptyState,
  readOnServer
- typed ROUTES, platform env (API origin, support config), Persian locales
  (common, errors) with typed i18next keys
- mapApiErrorBody adapts the gateway's error envelope; shared utils for E.164
  phones, API URLs and field-error renames
- session: refreshSessionInProxy renews an expired cookie session before render
- guards: requireAccount, redirectIfSignedIn, requireRole

Data layer (entities, repositories with mappers, query keys, server caches)
- auth (with login, logout and registration actions), profile, channel, follow,
  notification, post, prediction, feed, pricing, checkout, subscription,
  transaction, overview, finance
- shared domain enums live in shared/constants

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-04 21:33:07 +04:00
Amiram_se 5e35fbd6f2 feat: libs, tools 2026-10-02 19:42:11 +04:00
Amiram_se 486f86fcea fix: gitignore 2026-10-02 19:30:30 +04:00
Amiram_se 7dde8dd6f8 feat: scaffold 2026-10-02 18:19:11 +04:00