379995ba51a015c82e932bdf503e08c7f6f5004a
Problem:
- When user selects a draft with all steps filled (description, plan, answers, documents)
- But claim status is still 'draft' (not submitted)
- User has to manually navigate through all steps again
Solution:
1. Added check in loadDraft() to detect fully filled drafts:
- hasDescription: problem_description exists
- hasWizardPlan: wizard_plan exists
- hasAnswers: answers exist and not empty
- hasDocuments: documents_meta array has items
- isDraft: status_code === 'draft'
- allStepsFilled: all checks pass
2. When draft is ready for confirmation:
- Automatically subscribe to claim:plan SSE channel
- Wait for claim data from n8n
- Show loading message while waiting
- On success: show confirmation form automatically
3. Added subscribeToClaimPlanForDraft() function:
- Subscribes to /api/v1/claim-plan/{session_token}
- Handles claim_plan_ready event
- Updates formData with claimPlanData
- Auto-navigates to confirmation step via useEffect
4. Added useEffect for auto-navigation:
- Watches formData.showClaimConfirmation and formData.claimPlanData
- When both true, navigates to step 3 (confirmation)
- Handles cleanup of EventSource on unmount
Flow:
1. User selects draft → loadDraft() checks completeness
2. If all filled + draft → subscribeToClaimPlanForDraft()
3. SSE receives data → updates formData
4. useEffect detects → navigates to confirmation step
5. User sees confirmation form immediately
Files:
- frontend/src/pages/ClaimForm.tsx: Added auto-navigation logic
🚀 Ticket Form Intake Platform
Платформа цифровой приёмки обращений для other.clientright.ru
- Backend: Python FastAPI (async)
- Frontend: React 18 + TypeScript
- Database: PostgreSQL + MySQL + Redis
- Queue: RabbitMQ
- Storage: S3 Timeweb Cloud
🎯 Быстрый старт
📍 Визуальный доступ:
После запуска доступны по адресам:
Frontend (форма):
http://147.45.146.17:5175/
Backend API:
http://147.45.146.17:8200/
API Документация (Swagger UI):
http://147.45.146.17:8200/docs ← Интерактивная!
Gitea (Git репозиторий):
http://147.45.146.17:3002/
🔧 Установка и запуск
Backend (FastAPI):
cd backend
# Создаём виртуальное окружение
python3 -m venv venv
source venv/bin/activate
# Устанавливаем зависимости
pip install -r requirements.txt
# Запускаем сервер
uvicorn app.main:app --reload --host 0.0.0.0 --port 8200
Frontend (React):
cd frontend
# Устанавливаем зависимости
npm install
# Запускаем dev сервер
npm run dev -- --host 0.0.0.0 --port 5175
📊 Архитектура
Поток данных:
React (5175) → FastAPI (8200) → [Redis, RabbitMQ, PostgreSQL]
↓
OCR Service (8001)
OpenRouter AI
FlightAware API
↓
PHP Bridge → Vtiger CRM
Что НЕ трогаем:
✅ CRM Vtiger (работает как работала)
✅ MySQL полисы (только READ)
✅ Существующий PHP код
🗄️ Базы данных
| База | Назначение | Хост |
|---|---|---|
| PostgreSQL | Логи, метрики, новые данные | 147.45.189.234:5432 |
| MySQL | Проверка полисов (READ) | localhost:3306 |
| Redis | Кеш, Rate Limiting | localhost:6379 |
📁 Структура проекта
ticket_form/
├─ backend/ ← Python FastAPI
│ ├─ app/
│ │ ├─ main.py
│ │ ├─ api/
│ │ ├─ services/
│ │ └─ models/
│ └─ requirements.txt
│
├─ frontend/ ← React TypeScript
│ ├─ src/
│ │ ├─ components/
│ │ ├─ pages/
│ │ └─ api/
│ └─ package.json
│
└─ .env ← Конфигурация
🔌 API Endpoints
Документы:
POST /api/v1/documents/upload- Загрузка в S3POST /api/v1/documents/scan- OCR + Vision
Рейсы:
GET /api/v1/flights/check- Проверка статуса
Обращения:
POST /api/v1/claims/submit- Создание обращения
Полисы:
GET /api/v1/policies/verify- Проверка полиса
🐛 Отладка
Логи:
# FastAPI
tail -f backend/logs/app.log
# PostgreSQL логи
SELECT * FROM logs ORDER BY created_at DESC LIMIT 50;
📝 Git
# Репозиторий
http://147.45.146.17:3002/negodiy/erv-platform
# Клонирование
git clone http://147.45.146.17:3002/negodiy/erv-platform.git
# Push изменений
git add .
git commit -m "Your message"
git push origin main
Автор: AI Assistant + Фёдор
Дата: 24.10.2025
Description
Languages
TypeScript
61.3%
Python
33.9%
Shell
1.8%
PLpgSQL
1.3%
HTML
1.3%
Other
0.4%