diff --git a/typescript/frontend-marios2/src/content/dashboards/Tickets/CreateTicketModal.tsx b/typescript/frontend-marios2/src/content/dashboards/Tickets/CreateTicketModal.tsx index 7d6f64087..4dc2ddb03 100644 --- a/typescript/frontend-marios2/src/content/dashboards/Tickets/CreateTicketModal.tsx +++ b/typescript/frontend-marios2/src/content/dashboards/Tickets/CreateTicketModal.tsx @@ -19,7 +19,7 @@ import { Typography } from '@mui/material'; import AttachFileIcon from '@mui/icons-material/AttachFile'; -import { FormattedMessage } from 'react-intl'; +import { FormattedMessage, useIntl } from 'react-intl'; import axiosConfig from 'src/Resources/axiosConfig'; import { TicketPriority, @@ -28,7 +28,8 @@ import { subCategoryLabels, subCategoriesByCategory, categoryLabels, - otherSubCategoryValues + otherSubCategoryValues, + AdminUser } from 'src/interfaces/TicketTypes'; type Installation = { @@ -65,6 +66,7 @@ interface Props { } function CreateTicketModal({ open, onClose, onCreated, defaultInstallationId }: Props) { + const intl = useIntl(); const [subject, setSubject] = useState(''); const [selectedProduct, setSelectedProduct] = useState(''); const [selectedDevice, setSelectedDevice] = useState(''); @@ -73,6 +75,8 @@ function CreateTicketModal({ open, onClose, onCreated, defaultInstallationId }: useState(null); const [loadingInstallations, setLoadingInstallations] = useState(false); const [priority, setPriority] = useState(TicketPriority.Medium); + const [assigneeId, setAssigneeId] = useState(''); + const [adminUsers, setAdminUsers] = useState([]); const [category, setCategory] = useState(TicketCategory.Hardware); const [subCategory, setSubCategory] = useState( TicketSubCategory.Battery @@ -189,6 +193,16 @@ function CreateTicketModal({ open, onClose, onCreated, defaultInstallationId }: .finally(() => setLoadingInstallations(false)); }, [selectedProduct]); + useEffect(() => { + if (!open) return; + axiosConfig + .get('/GetAdminUsers') + .then((res) => { + if (Array.isArray(res.data)) setAdminUsers(res.data); + }) + .catch(() => setAdminUsers([])); + }, [open]); + useEffect(() => { if (defaultInstallationId == null || !open) return; axiosConfig @@ -233,6 +247,7 @@ function CreateTicketModal({ open, onClose, onCreated, defaultInstallationId }: setAllInstallations([]); setSelectedInstallation(null); setPriority(TicketPriority.Medium); + setAssigneeId(''); setCategory(TicketCategory.Hardware); setSubCategory(TicketSubCategory.Battery); setDescription(''); @@ -244,6 +259,15 @@ function CreateTicketModal({ open, onClose, onCreated, defaultInstallationId }: const handleSubmit = async () => { if (!subject.trim()) return; + if (assigneeId === '') { + setError( + intl.formatMessage({ + id: 'assigneeRequired', + defaultMessage: 'Please assign this ticket to someone before creating it.' + }) + ); + return; + } setSubmitting(true); setError(''); @@ -253,6 +277,7 @@ function CreateTicketModal({ open, onClose, onCreated, defaultInstallationId }: description, installationId: selectedInstallation?.id ?? null, priority, + assigneeId, category, subCategory: isOtherCategory ? 0 : subCategory, customSubCategory: (isOtherSubCategory || isOtherCategory) ? customSubCategory || null : null, @@ -390,6 +415,33 @@ function CreateTicketModal({ open, onClose, onCreated, defaultInstallationId }: )} /> + + + + + + + diff --git a/typescript/frontend-marios2/src/content/dashboards/Tickets/TicketDetail.tsx b/typescript/frontend-marios2/src/content/dashboards/Tickets/TicketDetail.tsx index 7cecf3482..bb00c7e02 100644 --- a/typescript/frontend-marios2/src/content/dashboards/Tickets/TicketDetail.tsx +++ b/typescript/frontend-marios2/src/content/dashboards/Tickets/TicketDetail.tsx @@ -591,11 +591,19 @@ function TicketDetailPage() { /> - {adminUsers.map((u) => ( - - {u.name} - - ))} + {adminUsers + .filter((u) => { + const name = (u.name ?? '').toLowerCase(); + return ( + !name.includes('inesco energy master admin') && + !name.includes('paal myhre') + ); + }) + .map((u) => ( + + {u.name} + + ))} diff --git a/typescript/frontend-marios2/src/lang/de.json b/typescript/frontend-marios2/src/lang/de.json index 90b785b1b..d05706670 100644 --- a/typescript/frontend-marios2/src/lang/de.json +++ b/typescript/frontend-marios2/src/lang/de.json @@ -574,6 +574,7 @@ "resolvedAt": "Gelöst", "noDescription": "Keine Beschreibung vorhanden.", "assignee": "Zuständig", + "assigneeRequired": "Bitte weisen Sie dieses Ticket jemandem zu, bevor Sie es erstellen.", "unassigned": "Nicht zugewiesen", "deleteTicket": "Löschen", "confirmDeleteTicket": "Ticket löschen?", diff --git a/typescript/frontend-marios2/src/lang/en.json b/typescript/frontend-marios2/src/lang/en.json index 09f680f5a..ddf33dcde 100644 --- a/typescript/frontend-marios2/src/lang/en.json +++ b/typescript/frontend-marios2/src/lang/en.json @@ -322,6 +322,7 @@ "resolvedAt": "Resolved", "noDescription": "No description provided.", "assignee": "Assignee", + "assigneeRequired": "Please assign this ticket to someone before creating it.", "unassigned": "Unassigned", "deleteTicket": "Delete", "confirmDeleteTicket": "Delete Ticket?", diff --git a/typescript/frontend-marios2/src/lang/fr.json b/typescript/frontend-marios2/src/lang/fr.json index 702f73b7d..79aa856bd 100644 --- a/typescript/frontend-marios2/src/lang/fr.json +++ b/typescript/frontend-marios2/src/lang/fr.json @@ -574,6 +574,7 @@ "resolvedAt": "Résolu", "noDescription": "Aucune description fournie.", "assignee": "Responsable", + "assigneeRequired": "Veuillez assigner ce ticket à quelqu'un avant de le créer.", "unassigned": "Non assigné", "deleteTicket": "Supprimer", "confirmDeleteTicket": "Supprimer le ticket ?", diff --git a/typescript/frontend-marios2/src/lang/it.json b/typescript/frontend-marios2/src/lang/it.json index fef93ad05..4cbfbdaea 100644 --- a/typescript/frontend-marios2/src/lang/it.json +++ b/typescript/frontend-marios2/src/lang/it.json @@ -574,6 +574,7 @@ "resolvedAt": "Risolto", "noDescription": "Nessuna descrizione fornita.", "assignee": "Assegnatario", + "assigneeRequired": "Assegna questo ticket a qualcuno prima di crearlo.", "unassigned": "Non assegnato", "deleteTicket": "Elimina", "confirmDeleteTicket": "Eliminare il ticket?",