TT-003: complete request-module integration into modular platform
- integrated request-module into module registry - moved backend into modules/request-module - added manifest.json and module.py - implemented dynamic router mounting - implemented dynamic static mounting - removed direct dependencies from platform core - verified startup with request-module - verified startup without request-module - added implementation_report_003.md
This commit is contained in:
@@ -0,0 +1,181 @@
|
||||
import { useState, useEffect } from 'react'
|
||||
import { useNavigate } from 'react-router-dom'
|
||||
import { ticketsApi, referenceApi } from '../api/client'
|
||||
import { Priority, Category, Status } from '../types'
|
||||
import { ArrowLeft, Save } from 'lucide-react'
|
||||
import ReactQuill from 'react-quill'
|
||||
import 'react-quill/dist/quill.snow.css'
|
||||
|
||||
const quillModules = {
|
||||
toolbar: [
|
||||
[{ 'header': [1, 2, 3, false] }],
|
||||
['bold', 'italic', 'underline', 'strike'],
|
||||
[{ 'list': 'ordered'}, { 'list': 'bullet' }],
|
||||
['link', 'image'],
|
||||
['clean']
|
||||
]
|
||||
}
|
||||
|
||||
const quillFormats = [
|
||||
'header', 'bold', 'italic', 'underline', 'strike',
|
||||
'list', 'bullet', 'link', 'image'
|
||||
]
|
||||
|
||||
export default function TicketCreate() {
|
||||
const navigate = useNavigate()
|
||||
const [formData, setFormData] = useState({
|
||||
subject: '',
|
||||
description: '',
|
||||
category_id: 0,
|
||||
priority_id: 0,
|
||||
status_id: 0,
|
||||
source: 'web'
|
||||
})
|
||||
const [priorities, setPriorities] = useState<Priority[]>([])
|
||||
const [categories, setCategories] = useState<Category[]>([])
|
||||
const [statuses, setStatuses] = useState<Status[]>([])
|
||||
const [loading, setLoading] = useState(false)
|
||||
const [error, setError] = useState('')
|
||||
|
||||
useEffect(() => {
|
||||
Promise.all([
|
||||
referenceApi.getStatuses(),
|
||||
referenceApi.getPriorities(),
|
||||
referenceApi.getCategories()
|
||||
]).then(([s, p, c]) => {
|
||||
setStatuses(s.data)
|
||||
setPriorities(p.data)
|
||||
setCategories(c.data)
|
||||
if (s.data.length) setFormData(f => ({ ...f, status_id: s.data[0].id }))
|
||||
if (p.data.length) setFormData(f => ({ ...f, priority_id: p.data[0].id }))
|
||||
if (c.data.length) setFormData(f => ({ ...f, category_id: c.data[0].id }))
|
||||
})
|
||||
}, [])
|
||||
|
||||
const handleSubmit = async (e: React.FormEvent) => {
|
||||
e.preventDefault()
|
||||
setError('')
|
||||
setLoading(true)
|
||||
|
||||
try {
|
||||
await ticketsApi.create(formData)
|
||||
navigate('/tickets')
|
||||
} catch (err: any) {
|
||||
setError(err.response?.data?.detail || 'Ошибка создания заявки')
|
||||
} finally {
|
||||
setLoading(false)
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div className="flex items-center justify-between mb-6">
|
||||
<button onClick={() => navigate('/tickets')} className="flex items-center text-gray-600 hover:text-gray-900">
|
||||
<ArrowLeft className="w-4 h-4 mr-2" />
|
||||
Назад к заявкам
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div className="bg-white rounded-lg shadow p-6">
|
||||
<h2 className="text-xl font-semibold mb-6">Новая заявка</h2>
|
||||
|
||||
{error && (
|
||||
<div className="bg-red-50 text-red-600 p-3 rounded-lg mb-4 text-sm">{error}</div>
|
||||
)}
|
||||
|
||||
<form onSubmit={handleSubmit} className="space-y-4">
|
||||
<div>
|
||||
<label className="block text-sm font-medium text-gray-700 mb-1">Тема *</label>
|
||||
<input
|
||||
type="text"
|
||||
value={formData.subject}
|
||||
onChange={(e) => setFormData({ ...formData, subject: e.target.value })}
|
||||
className="w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500"
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label className="block text-sm font-medium text-gray-700 mb-1">Описание</label>
|
||||
<ReactQuill
|
||||
theme="snow"
|
||||
value={formData.description}
|
||||
onChange={(value) => setFormData({ ...formData, description: value })}
|
||||
modules={quillModules}
|
||||
formats={quillFormats}
|
||||
className="bg-white rounded-lg"
|
||||
style={{ minHeight: '200px' }}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-3 gap-4">
|
||||
<div>
|
||||
<label className="block text-sm font-medium text-gray-700 mb-1">Статус *</label>
|
||||
<select
|
||||
value={formData.status_id}
|
||||
onChange={(e) => setFormData({ ...formData, status_id: Number(e.target.value) })}
|
||||
className="w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500"
|
||||
required
|
||||
>
|
||||
{statuses.map(s => (
|
||||
<option key={s.id} value={s.id}>{s.name}</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<label className="block text-sm font-medium text-gray-700 mb-1">Приоритет *</label>
|
||||
<select
|
||||
value={formData.priority_id}
|
||||
onChange={(e) => setFormData({ ...formData, priority_id: Number(e.target.value) })}
|
||||
className="w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500"
|
||||
required
|
||||
>
|
||||
{priorities.map(p => (
|
||||
<option key={p.id} value={p.id}>{p.name}</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<label className="block text-sm font-medium text-gray-700 mb-1">Категория *</label>
|
||||
<select
|
||||
value={formData.category_id}
|
||||
onChange={(e) => setFormData({ ...formData, category_id: Number(e.target.value) })}
|
||||
className="w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500"
|
||||
required
|
||||
>
|
||||
{categories.map(c => (
|
||||
<option key={c.id} value={c.id}>{c.name}</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label className="block text-sm font-medium text-gray-700 mb-1">Источник</label>
|
||||
<select
|
||||
value={formData.source}
|
||||
onChange={(e) => setFormData({ ...formData, source: e.target.value })}
|
||||
className="w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500"
|
||||
>
|
||||
<option value="web">Веб</option>
|
||||
<option value="email">Email</option>
|
||||
<option value="phone">Телефон</option>
|
||||
<option value="sms">SMS</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div className="flex justify-end pt-4">
|
||||
<button
|
||||
type="submit"
|
||||
disabled={loading}
|
||||
className="flex items-center px-6 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 disabled:opacity-50"
|
||||
>
|
||||
<Save className="w-4 h-4 mr-2" />
|
||||
{loading ? 'Создание...' : 'Создать заявку'}
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user