Commit Graph

11 Commits

Author SHA1 Message Date
AI Assistant
6f31ad0dda debug: Add detailed logging for SMS code in backend
Added comprehensive logging to track SMS code:
- Log all keys in request body
- Log SMS code presence and value
- Log extracted SMS code before adding to event_data
- This will help identify why SMS code might not appear in Redis

Files:
- backend/app/api/claims.py
2025-11-25 15:38:07 +03:00
AI Assistant
116ea17b4a feat: Add SMS code to Redis channel data
Added SMS code to form approval data:
- Frontend: Pass SMS code to saveFormData function
- Frontend: Include sms_code in payload sent to backend
- Backend: Include sms_code in Redis event data

This allows n8n workflow to access the verified SMS code for logging/audit purposes.

Files:
- frontend/src/components/form/StepClaimConfirmation.tsx
- backend/app/api/claims.py
2025-11-25 13:43:13 +03:00
AI Assistant
cd02c21c34 fix: Move /approve route before /{claim_id} to fix 405 error
Fixed route conflict:
- Moved POST /approve route BEFORE GET /{claim_id}
- FastAPI processes routes in order, so specific routes must come before parameterized ones
- This fixes 405 Method Not Allowed error

Files:
- backend/app/api/claims.py
2025-11-25 13:09:42 +03:00
AI Assistant
13070a2100 fix: Change Redis channel to fixed name clientright:webform:approve
Changed from dynamic channel form_approve:{claim_id} to fixed channel:
- Channel: clientright:webform:approve
- Simpler n8n subscription (no need for dynamic channel name)
- All form approvals go to the same channel

Files:
- backend/app/api/claims.py
- frontend/src/components/form/StepClaimConfirmation.tsx
- docs/REDIS_FORM_APPROVE.md
2025-11-25 12:32:51 +03:00
AI Assistant
de092755af feat: Switch form approval to Redis channel instead of webhook
Changed from webhook to Redis Pub/Sub channel:
- Created endpoint POST /api/v1/claims/approve
- Publishes to Redis channel: form_approve:{claim_id}
- Added idempotency_key for future RabbitMQ integration
- Fire-and-forget approach (no waiting for response)

Benefits:
- Higher performance (Redis Pub/Sub is faster)
- Better scalability
- Ready for RabbitMQ queue integration
- Idempotency key included for duplicate protection

Files:
- backend/app/api/claims.py (new /approve endpoint)
- frontend/src/components/form/StepClaimConfirmation.tsx (updated saveFormData)
- docs/REDIS_FORM_APPROVE.md (documentation)
2025-11-25 12:29:36 +03:00
AI Assistant
82f4bf818b feat: Send form approval data to webhook without waiting for response
Simplified approach:
- Removed backend endpoint /approve (will use direct webhook)
- Updated saveFormData to send data directly to n8n webhook
- Fire-and-forget approach: no waiting for response
- Show success message 'Ваше заявление отправлено!' after SMS verification
- Uses webhook URL: https://n8n.clientright.pro/webhook/eebe58d4-0bcd-4d09-9d62-39868b110960

Flow:
1. User confirms form → SMS modal appears
2. SMS code sent automatically
3. User enters code → verified
4. Data sent to webhook (fire-and-forget)
5. Success message shown
6. Navigate to next step

Files:
- frontend/src/components/form/StepClaimConfirmation.tsx
- backend/app/api/claims.py (removed /approve endpoint)
2025-11-25 11:58:29 +03:00
AI Assistant
894463742f fix: Order by updated_at DESC to get latest claim record with send_to_form_approve
Problem:
- Multiple records exist with same claim_id in DB
- One record (ID: 0eb051ec...) has send_to_form_approve.draft (updated: 2025-11-24)
- Another record (ID: b532b1b3...) doesn't have send_to_form_approve (updated: 2025-11-21)
- API query used LIMIT 1 without ORDER BY, could return wrong record
- Form was empty because wrong record (without send_to_form_approve) was returned

Solution:
- Added ORDER BY updated_at DESC to get latest record first
- This ensures we always get the record with send_to_form_approve.draft
- Latest record has correct data structure for confirmation form

Files:
- backend/app/api/claims.py: Added ORDER BY updated_at DESC
2025-11-24 16:46:56 +03:00
AI Assistant
3621ae6021 feat: Session persistence with Redis + Draft management fixes
- Implement session management API (/api/v1/session/create, verify, logout)
- Add session restoration from localStorage on page reload
- Fix session_id priority when loading drafts (use current, not old from DB)
- Add unified_id and claim_id to wizard payload sent to n8n
- Add Docker volume for frontend HMR (Hot Module Replacement)
- Add comprehensive session logging for debugging

Components updated:
- backend/app/api/session.py (NEW) - Session management endpoints
- backend/app/main.py - Include session router
- frontend/src/components/form/Step1Phone.tsx v2.0 - Create session after SMS
- frontend/src/pages/ClaimForm.tsx v3.8 - Session restoration & priority fix
- frontend/src/components/form/StepWizardPlan.tsx v1.4 - Add unified_id/claim_id
- docker-compose.yml - Add frontend volume for live reload

Session flow:
1. User verifies phone -> session created in Redis (24h TTL)
2. session_token saved to localStorage
3. Page reload -> session restored automatically
4. Draft selected -> current session_id used (not old from DB)
5. Wizard submit -> unified_id, claim_id, session_id sent to n8n
6. Logout -> session removed from Redis & localStorage

Fixes:
- Session token not persisting after page reload
- unified_id missing in n8n webhook payload
- Old session_id from draft overwriting current session
- Frontend changes requiring container rebuild
2025-11-20 18:31:42 +03:00
AI Assistant
4c8fda5f55 Добавлено логирование для отладки черновиков
- Добавлены логи в frontend (ClaimForm.tsx) для отслеживания unified_id и запросов к API
- Добавлены логи в backend (claims.py) для отладки SQL запросов
- Создан лог сессии с описанием проблемы и текущего состояния
- Проблема: API возвращает 0 черновиков, хотя в БД есть данные
2025-11-19 18:46:48 +03:00
AI Assistant
3306d01e0d Ticket form: new stack + description step 2025-11-14 19:06:36 +03:00
AI Assistant
0f82eef08d 🚀 MVP: FastAPI + React форма с SMS верификацией
 Инфраструктура: PostgreSQL, Redis, RabbitMQ, S3
 Backend: SMS сервис + API endpoints
 Frontend: React форма (3 шага) + SMS верификация
2025-10-24 16:19:58 +03:00