diff --git a/frontend/src/components/CreateTicketModal.jsx b/frontend/src/components/CreateTicketModal.jsx new file mode 100644 index 0000000..e38521b --- /dev/null +++ b/frontend/src/components/CreateTicketModal.jsx @@ -0,0 +1,93 @@ +import { useState } from 'react'; +import { X } from 'lucide-react'; +import axios from 'axios'; +import { API_URL } from '../config'; + +export default function CreateTicketModal({ token, theme, onClose, onCreated }) { + const [formData, setFormData] = useState({ + title: '', + description: '' + }); + const [loading, setLoading] = useState(false); + + const handleSubmit = async (e) => { + e.preventDefault(); + setLoading(true); + + try { + await axios.post( + `${API_URL}/api/tickets/create`, + formData, + { headers: { Authorization: `Bearer ${token}` } } + ); + onCreated(); + } catch (error) { + alert(error.response?.data?.detail || 'Ошибка создания тикета'); + } finally { + setLoading(false); + } + }; + + return ( +
+
+
+

Создать тикет

+ +
+ +
+
+ + setFormData({ ...formData, title: e.target.value })} + className={`w-full ${theme.input} ${theme.border} border rounded-xl px-4 py-2 ${theme.text} focus:outline-none focus:ring-2 focus:ring-blue-500 transition`} + placeholder="Краткое описание проблемы" + /> +
+ +
+ +