diff --git a/src/components/CreateTicketModal.jsx b/src/components/CreateTicketModal.jsx index eac2466..4839200 100644 --- a/src/components/CreateTicketModal.jsx +++ b/src/components/CreateTicketModal.jsx @@ -1,6 +1,5 @@ import { useState, useEffect, useMemo } from 'react' import { FaTimes } from 'react-icons/fa' -import { useAdminConfig } from '../hooks/useAdminConfig' import { useEmployees } from '../hooks/useEmployees' import { databases, DATABASE_ID, COLLECTIONS, Query } from '../lib/appwrite' import { @@ -11,6 +10,7 @@ import { buildRequesterSuggestions, rankSuggestions, } from '../lib/ticketForm' +import { priorityFor } from '../lib/ticketStatus' import { AutocompleteInput, DateTimeInput } from './ui' // Neue Tickets gibt es aktuell nur fuer diese Arten; alte Tickets behalten ihre Art. @@ -20,36 +20,25 @@ const TICKET_TYPES = [ { value: 'Migration', label: 'Migration (Übernahme von anderem Anbieter)' }, ] -const DEFAULT_PRIORITIES = [ - { value: 0, label: 'None' }, - { value: 1, label: 'Low' }, - { value: 2, label: 'Medium' }, - { value: 3, label: 'High' }, - { value: 4, label: 'Critical' } -] - -// Datum als "yyyy-mm-dd", Uhrzeit als "hh:mm" (Werte der Kalender-Felder) +// Datum als "yyyy-mm-dd", Uhrzeit als "hh:mm" (Werte der Kalender-Felder). +// Die Service-Art fragt das Formular nicht mehr ab: gespeichert wird Fernwartung. const emptyForm = () => ({ customerId: '', type: TICKET_TYPES[0].value, serviceType: SERVICE_TYPES[0].value, - priority: 1, + urgent: false, topic: '', requestedBy: '', - requestedFor: '', startDate: todayIso(), startTime: '', deadline: todayIso(), endTime: '', - estimate: '30', details: '' }) export default function CreateTicketModal({ isOpen, onClose, onCreate, customers = [] }) { - const { config } = useAdminConfig() const { employees } = useEmployees() - const PRIORITIES = config?.priorities || DEFAULT_PRIORITIES const [formData, setFormData] = useState(emptyForm) const [recentTickets, setRecentTickets] = useState([]) @@ -104,9 +93,11 @@ export default function CreateTicketModal({ isOpen, onClose, onCreate, customers setError('') const customer = customers.find(c => c.$id === formData.customerId) + const { urgent, ...fields } = formData try { const result = await onCreate({ - ...formData, + ...fields, + priority: priorityFor(urgent), customerName: customer?.name || '', customerLocation: customer?.location || '', startDate: isoToGermanDate(formData.startDate), @@ -136,7 +127,7 @@ export default function CreateTicketModal({ isOpen, onClose, onCreate, customers
-

Create New Ticket

+

Neues Ticket

{error && (
@@ -148,14 +139,14 @@ export default function CreateTicketModal({ isOpen, onClose, onCreate, customers
- +
- - -
- -
- - +
@@ -215,11 +189,11 @@ export default function CreateTicketModal({ isOpen, onClose, onCreate, customers
- + handleChange('topic', e.target.value)} required @@ -227,7 +201,7 @@ export default function CreateTicketModal({ isOpen, onClose, onCreate, customers
- +
- - handleChange('requestedFor', value)} - getSuggestions={getSuggestions} - /> -
- -
- +
- + handleChange('endTime', value)} />
- -
- - handleChange('estimate', e.target.value)} - /> -
- +