From b14360f4b61badcfb6f832c12cddf6cf4fe727ac Mon Sep 17 00:00:00 2001 From: Sergei Date: Mon, 12 Jan 2026 11:56:24 -0800 Subject: [PATCH] Fix web build: React 19 JSX runtime + AuthContext hooks order - babel.config.js: changed jsxRuntime from 'classic' to 'automatic' (React 19 requirement) - AuthContext.tsx: reordered useEffect/useCallback to fix "Cannot access 'checkAuth' before initialization" error on web - CLAUDE.md: added Quick Start, Git Workflow, Credentials sections Web version now builds and runs correctly with npm run web --- CLAUDE.md | 92 ++++++++++++++++++++++++++++++++++++++++ babel.config.js | 11 +++++ contexts/AuthContext.tsx | 46 ++++++++++---------- 3 files changed, 126 insertions(+), 23 deletions(-) create mode 100644 babel.config.js diff --git a/CLAUDE.md b/CLAUDE.md index 045b9e1..b0a88a5 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -1,5 +1,97 @@ # WellNuo - Project Architecture +## Quick Start + +```bash +cd /Users/sergei/Desktop/WellNuo +git pull origin development # всегда сначала pull! +npm run web # Web-First подход +# Откроется http://localhost:8081 +``` + +--- + +## Git Workflow (ОБЯЗАТЕЛЬНО!) + +**Branch:** `development` + +### Перед началом работы: +```bash +git pull origin development +``` + +### После изменений: +```bash +git add <файлы> +git commit -m "описание" +git push origin development +``` + +### Правило одной сессии: +**Только ОДИН Claude Code работает с этим проектом одновременно!** + +--- + +## Credentials + +### PostgreSQL +``` +Host: eluxnetworks.net +Port: 5432 +Database: wellnuo_app +User: sergei +Password: W31153Rg31 +``` + +### JWT +``` +JWT_SECRET: wellnuo_jwt_secret_key_2024 +``` + +### Stripe (Test) +``` +Publishable: pk_test_51P3kdqP0gvUw6M9C7ixPQHqbPcvga4G5kAYx1h6QXQAt1psbrC2rrmOojW0fTeQzaxD1Q9RKS3zZ23MCvjjZpWLi00eCFWRHMk +Secret: sk_test_51P3kdqP0gvUw6M9CFhALbFxOzOUvw3LcWH7UvfGF4NtjZLOgUlzBqKAQJrHjs1loQTPRDUxfOQ5315mjUXICFU8z00PgKEVWGo +``` + +### Brevo Email (OTP) +``` +API Key: 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 +``` + +--- + +## Текущий статус (12.01.2026) + +### Работает: +- [x] Web версия (`npm run web`) +- [x] Login экран +- [x] Backend API + +### TODO (Web-First): +- [ ] SecureStore → localStorage (HIGH!) +- [ ] ImagePicker → File Input +- [ ] WebView → iframe +- [ ] Stripe.js для web + +### Исправленные баги: +1. `babel.config.js` — jsxRuntime: 'automatic' +2. `AuthContext.tsx` — порядок hooks + +--- + +## Ссылки + +| Что | URL | +|-----|-----| +| Production | https://wellnuo.smartlaunchhub.com/app | +| API | https://wellnuo.smartlaunchhub.com/api | +| Сервер | 91.98.205.156 | +| Системный анализ | https://scheme.smartlaunchhub.com/canvas?id=cmkatv8dp0001llnsbk6eviwr | +| Задачи в схеме | https://scheme.smartlaunchhub.com/canvas?schema=cmk8xf11g0005llbvsbt0rd5z | + +--- + ## API-First Architecture **IMPORTANT: This project uses an API-first approach. NO local storage for business data!** diff --git a/babel.config.js b/babel.config.js new file mode 100644 index 0000000..c2ec8df --- /dev/null +++ b/babel.config.js @@ -0,0 +1,11 @@ +module.exports = function (api) { + api.cache(true); + return { + presets: [ + ['babel-preset-expo', { jsxRuntime: 'automatic' }] + ], + plugins: [ + 'react-native-reanimated/plugin', + ] + }; +}; diff --git a/contexts/AuthContext.tsx b/contexts/AuthContext.tsx index 4b4364f..a13e457 100644 --- a/contexts/AuthContext.tsx +++ b/contexts/AuthContext.tsx @@ -40,29 +40,6 @@ export function AuthProvider({ children }: { children: ReactNode }) { error: null, }); - // Check authentication on mount - useEffect(() => { - console.log('[AuthContext] checkAuth starting...'); - checkAuth(); - }, [checkAuth]); - - // Auto-logout when WellNuo API returns 401 (token expired) - // Token now expires after 365 days, so this should rarely happen - useEffect(() => { - setOnUnauthorizedCallback(() => { - console.log('[AuthContext] Received 401 - session expired, logging out...'); - api.logout().then(() => { - setState({ - user: null, - isLoading: false, - isInitializing: false, - isAuthenticated: false, - error: { message: 'Session expired. Please login again.' }, - }); - }); - }); - }, []); - const checkAuth = useCallback(async () => { try { console.log(`[AuthContext] checkAuth: Checking token...`); @@ -107,6 +84,29 @@ export function AuthProvider({ children }: { children: ReactNode }) { } }, []); + // Auto-logout when WellNuo API returns 401 (token expired) + // Token now expires after 365 days, so this should rarely happen + useEffect(() => { + setOnUnauthorizedCallback(() => { + console.log('[AuthContext] Received 401 - session expired, logging out...'); + api.logout().then(() => { + setState({ + user: null, + isLoading: false, + isInitializing: false, + isAuthenticated: false, + error: { message: 'Session expired. Please login again.' }, + }); + }); + }); + }, []); + + // Check authentication on mount + useEffect(() => { + console.log('[AuthContext] checkAuth starting...'); + checkAuth(); + }, [checkAuth]); + const checkEmail = useCallback(async (email: string): Promise => { setState((prev) => ({ ...prev, isLoading: true, error: null }));