import { useState } from 'react' import { Box, Button, Dialog, DialogActions, DialogContent, DialogTitle, FormControl, FormControlLabel, InputLabel, MenuItem, Select as MuiSelect, Switch, TextField, ToggleButton, ToggleButtonGroup, Typography, } from '@mui/material' import { Building2, Globe, Lock, Search } from 'lucide-react' import type { MarktHinweis, HinweisVisibility, HinweisDirection, HinweisQuelle, CreateMarktHinweisInput, } from '../../domain/marktHinweis' import { useCreateMarktHinweis } from '../../hooks/useMarktHinweise' import { QUELLE_LABELS } from './hinweisHelpers' import { DS_BRAND, DS_SLATE } from '../../lib/ds' /** * Erfassung eines Netzwerk-Hinweises. * * Eigene Datei, weil der Dialog mit über 230 Zeilen für sich steht: er teilt * mit den Panels nur die Beschriftungstabelle, nicht den Zustand. */ // ── Netzwerk: HinweisErfassenDialog ───────────────────────────────────────── function HinweisErfassenDialog({ open, onClose, onCreated, }: { open: boolean onClose: () => void onCreated: (id: string) => void }) { const mutation = useCreateMarktHinweis() const [direction, setDirection] = useState('SUCHE') const [assetType, setAssetType] = useState('') const [locationHint, setLocationHint] = useState('') const [areaSqmMin, setAreaSqmMin] = useState('') const [areaSqmMax, setAreaSqmMax] = useState('') const [companyName, setCompanyName] = useState('') const [isAnonymized, setIsAnonymized] = useState(false) const [quelle, setQuelle] = useState('NETZWERKEVENT') const [note, setNote] = useState('') const [visibility, setVisibility] = useState('INTERN') const isValid = assetType.trim() !== '' && locationHint.trim() !== '' function resetForm() { setDirection('SUCHE') setAssetType('') setLocationHint('') setAreaSqmMin('') setAreaSqmMax('') setCompanyName('') setIsAnonymized(false) setQuelle('NETZWERKEVENT') setNote('') setVisibility('INTERN') } function handleSave() { if (!isValid) return const input: CreateMarktHinweisInput = { direction, assetType: assetType as MarktHinweis['assetType'], locationHint, areaSqmMin: areaSqmMin ? Number(areaSqmMin) : undefined, areaSqmMax: areaSqmMax ? Number(areaSqmMax) : undefined, companyName: companyName.trim() || undefined, isAnonymized, quelle, note: note.trim() || undefined, visibility, status: 'OFFEN', } mutation.mutate(input, { onSuccess: (result) => { onCreated(result.id) resetForm() }, }) } function handleClose() { resetForm() onClose() } return ( Hinweis erfassen {/* Richtung */} Richtung { if (v) setDirection(v as HinweisDirection) }} size="small" sx={{ '& .MuiToggleButton-root': { textTransform: 'none', fontSize: '0.8rem' } }} > Jemand sucht Wird verfügbar {/* Asset-Typ */} Asset-Typ * setAssetType(e.target.value)} > Büro Einzelhandel Gewerbe Logistik Produktion {/* Stadt / Region */} setLocationHint(e.target.value)} /> {/* Fläche */} setAreaSqmMin(e.target.value)} sx={{ flex: 1 }} /> setAreaSqmMax(e.target.value)} sx={{ flex: 1 }} /> {/* Firma / Name */} setCompanyName(e.target.value)} /> {/* Quelle */} Quelle setQuelle(e.target.value as HinweisQuelle)} > {Object.entries(QUELLE_LABELS).map(([k, v]) => ( {v} ))} {/* Notiz */} setNote(e.target.value)} /> {/* Sichtbarkeit */} Sichtbarkeit setVisibility('INTERN')} sx={{ flex: 1, borderRadius: 1.5, p: 1.5, cursor: 'pointer', display: 'flex', flexDirection: 'column', gap: 0.5, border: visibility === 'INTERN' ? '2px solid #4338ca' : '1px solid #e2e8f0', bgcolor: visibility === 'INTERN' ? '#eef2ff' : 'white', }} > Intern Nur für Ihr Team sichtbar setVisibility('PLATTFORM')} sx={{ flex: 1, borderRadius: 1.5, p: 1.5, cursor: 'pointer', display: 'flex', flexDirection: 'column', gap: 0.5, border: visibility === 'PLATTFORM' ? '2px solid #7c3aed' : '1px solid #e2e8f0', bgcolor: visibility === 'PLATTFORM' ? '#faf5ff' : 'white', }} > Plattform Für alle Verwaltungen auf Property Match sichtbar {/* Anonymisieren (only for PLATTFORM) */} {visibility === 'PLATTFORM' && ( setIsAnonymized(e.target.checked)} size="small" /> } label={Firmenname anonymisieren} /> )} ) } export { HinweisErfassenDialog }