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
This commit is contained in:
parent
966d8e2aba
commit
b14360f4b6
92
CLAUDE.md
92
CLAUDE.md
@ -1,5 +1,97 @@
|
|||||||
# WellNuo - Project Architecture
|
# 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
|
## API-First Architecture
|
||||||
|
|
||||||
**IMPORTANT: This project uses an API-first approach. NO local storage for business data!**
|
**IMPORTANT: This project uses an API-first approach. NO local storage for business data!**
|
||||||
|
|||||||
11
babel.config.js
Normal file
11
babel.config.js
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
module.exports = function (api) {
|
||||||
|
api.cache(true);
|
||||||
|
return {
|
||||||
|
presets: [
|
||||||
|
['babel-preset-expo', { jsxRuntime: 'automatic' }]
|
||||||
|
],
|
||||||
|
plugins: [
|
||||||
|
'react-native-reanimated/plugin',
|
||||||
|
]
|
||||||
|
};
|
||||||
|
};
|
||||||
@ -40,29 +40,6 @@ export function AuthProvider({ children }: { children: ReactNode }) {
|
|||||||
error: null,
|
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 () => {
|
const checkAuth = useCallback(async () => {
|
||||||
try {
|
try {
|
||||||
console.log(`[AuthContext] checkAuth: Checking token...`);
|
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<CheckEmailResult> => {
|
const checkEmail = useCallback(async (email: string): Promise<CheckEmailResult> => {
|
||||||
setState((prev) => ({ ...prev, isLoading: true, error: null }));
|
setState((prev) => ({ ...prev, isLoading: true, error: null }));
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user