Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 362514681a | |||
| 07cea21143 | |||
| be5523bcee | |||
| a8b54af0b8 | |||
| 6206447dae |
Generated
+48
@@ -41,6 +41,7 @@
|
|||||||
"eslint-plugin-react-refresh": "^0.5.2",
|
"eslint-plugin-react-refresh": "^0.5.2",
|
||||||
"globals": "^17.6.0",
|
"globals": "^17.6.0",
|
||||||
"jsdom": "^29.1.1",
|
"jsdom": "^29.1.1",
|
||||||
|
"playwright": "^1.61.0",
|
||||||
"tailwindcss": "^4.3.0",
|
"tailwindcss": "^4.3.0",
|
||||||
"typescript": "~6.0.2",
|
"typescript": "~6.0.2",
|
||||||
"typescript-eslint": "^8.59.2",
|
"typescript-eslint": "^8.59.2",
|
||||||
@@ -4330,6 +4331,53 @@
|
|||||||
"url": "https://github.com/sponsors/jonschlinkert"
|
"url": "https://github.com/sponsors/jonschlinkert"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/playwright": {
|
||||||
|
"version": "1.61.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/playwright/-/playwright-1.61.0.tgz",
|
||||||
|
"integrity": "sha512-Z+7BeeqQPRRzklHsVFP4KTGIyMxKUmfeRA4WisM6G3/XW6nwGeX6fX9qYaDa+CiUqpOkb2f6X3nar05R3kSuJQ==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"dependencies": {
|
||||||
|
"playwright-core": "1.61.0"
|
||||||
|
},
|
||||||
|
"bin": {
|
||||||
|
"playwright": "cli.js"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18"
|
||||||
|
},
|
||||||
|
"optionalDependencies": {
|
||||||
|
"fsevents": "2.3.2"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/playwright-core": {
|
||||||
|
"version": "1.61.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.61.0.tgz",
|
||||||
|
"integrity": "sha512-caX7TrY3Ml6egyDX0WUcTHDxodl/b51y5wJOdCEA36QviK/s2g081hvmGs8eaE3DWb6NYZQ6BjO/QkNRPenoPA==",
|
||||||
|
"dev": true,
|
||||||
|
"license": "Apache-2.0",
|
||||||
|
"bin": {
|
||||||
|
"playwright-core": "cli.js"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=18"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/playwright/node_modules/fsevents": {
|
||||||
|
"version": "2.3.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz",
|
||||||
|
"integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==",
|
||||||
|
"dev": true,
|
||||||
|
"hasInstallScript": true,
|
||||||
|
"license": "MIT",
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"darwin"
|
||||||
|
],
|
||||||
|
"engines": {
|
||||||
|
"node": "^8.16.0 || ^10.6.0 || >=11.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/postcss": {
|
"node_modules/postcss": {
|
||||||
"version": "8.5.14",
|
"version": "8.5.14",
|
||||||
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.14.tgz",
|
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.14.tgz",
|
||||||
|
|||||||
@@ -47,6 +47,7 @@
|
|||||||
"eslint-plugin-react-refresh": "^0.5.2",
|
"eslint-plugin-react-refresh": "^0.5.2",
|
||||||
"globals": "^17.6.0",
|
"globals": "^17.6.0",
|
||||||
"jsdom": "^29.1.1",
|
"jsdom": "^29.1.1",
|
||||||
|
"playwright": "^1.61.0",
|
||||||
"tailwindcss": "^4.3.0",
|
"tailwindcss": "^4.3.0",
|
||||||
"typescript": "~6.0.2",
|
"typescript": "~6.0.2",
|
||||||
"typescript-eslint": "^8.59.2",
|
"typescript-eslint": "^8.59.2",
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { useEffect, useState } from 'react'
|
|||||||
import { Box, IconButton, Tooltip, Typography, useMediaQuery, useTheme } from '@mui/material'
|
import { Box, IconButton, Tooltip, Typography, useMediaQuery, useTheme } from '@mui/material'
|
||||||
import { ArrowLeft, LayoutGrid, List as ListIcon, Inbox } from 'lucide-react'
|
import { ArrowLeft, LayoutGrid, List as ListIcon, Inbox } from 'lucide-react'
|
||||||
import { useActiveInquiries } from '../../hooks/useInquiries'
|
import { useActiveInquiries } from '../../hooks/useInquiries'
|
||||||
|
import type { InquiryFilters } from '../../provider/IInquiryProvider'
|
||||||
import { EmptyState } from '../ui'
|
import { EmptyState } from '../ui'
|
||||||
import { InquiryList } from './InquiryList'
|
import { InquiryList } from './InquiryList'
|
||||||
import { InquiryCardGrid } from './InquiryCardGrid'
|
import { InquiryCardGrid } from './InquiryCardGrid'
|
||||||
@@ -17,8 +18,14 @@ function loadViewMode(): ViewMode {
|
|||||||
return stored === 'grid' ? 'grid' : 'list'
|
return stored === 'grid' ? 'grid' : 'list'
|
||||||
}
|
}
|
||||||
|
|
||||||
export function ActiveInquiriesTab() {
|
interface Props {
|
||||||
const { data: inquiries = [], isLoading } = useActiveInquiries()
|
filters?: InquiryFilters
|
||||||
|
emptyTitle?: string
|
||||||
|
emptyDescription?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export function ActiveInquiriesTab({ filters, emptyTitle, emptyDescription }: Props = {}) {
|
||||||
|
const { data: inquiries = [], isLoading } = useActiveInquiries(filters)
|
||||||
const [selectedId, setSelectedId] = useState<string | null>(null)
|
const [selectedId, setSelectedId] = useState<string | null>(null)
|
||||||
const [view, setView] = useState<ViewMode>(loadViewMode())
|
const [view, setView] = useState<ViewMode>(loadViewMode())
|
||||||
const theme = useTheme()
|
const theme = useTheme()
|
||||||
@@ -41,8 +48,8 @@ export function ActiveInquiriesTab() {
|
|||||||
return (
|
return (
|
||||||
<EmptyState
|
<EmptyState
|
||||||
icon={<Inbox size={40} />}
|
icon={<Inbox size={40} />}
|
||||||
title="Keine aktiven Anfragen"
|
title={emptyTitle ?? 'Keine aktiven Anfragen'}
|
||||||
description="Sobald Interessenten Anfragen zu Ihren Objekten stellen, erscheinen diese hier."
|
description={emptyDescription ?? 'Sobald Interessenten Anfragen zu Ihren Objekten stellen, erscheinen diese hier.'}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,146 @@
|
|||||||
|
import { Box, Button, Checkbox, Paper, Typography } from '@mui/material'
|
||||||
|
import { Building2, MapPin } from 'lucide-react'
|
||||||
|
import type { Property } from '../../domain/property'
|
||||||
|
import { getScoreTier, SCORE_THEME } from '../shared/scoreTheme'
|
||||||
|
import { assetTypeLabel } from './latentNeedUtils'
|
||||||
|
|
||||||
|
interface EmbeddedPropertyCardProps {
|
||||||
|
property: Property
|
||||||
|
matchScore: number
|
||||||
|
selected: boolean
|
||||||
|
onToggle: () => void
|
||||||
|
reason: string
|
||||||
|
onQuickOffer: () => void
|
||||||
|
disabled?: boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
export function EmbeddedPropertyCard({
|
||||||
|
property,
|
||||||
|
matchScore,
|
||||||
|
selected,
|
||||||
|
onToggle,
|
||||||
|
reason,
|
||||||
|
onQuickOffer,
|
||||||
|
disabled,
|
||||||
|
}: EmbeddedPropertyCardProps) {
|
||||||
|
const tier = getScoreTier(matchScore)
|
||||||
|
const theme = SCORE_THEME[tier]
|
||||||
|
const image = property.images?.[0]
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Paper
|
||||||
|
elevation={0}
|
||||||
|
sx={{
|
||||||
|
borderRadius: 2,
|
||||||
|
border: '1px solid',
|
||||||
|
borderColor: selected ? '#152642' : '#e2e8f0',
|
||||||
|
bgcolor: selected ? '#f8fafc' : 'white',
|
||||||
|
overflow: 'hidden',
|
||||||
|
transition: 'all 0.15s',
|
||||||
|
'&:hover': { borderColor: selected ? '#152642' : '#94a3b8', boxShadow: '0 2px 8px rgba(15,23,42,0.07)' },
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{/* Info row */}
|
||||||
|
<Box sx={{ display: 'flex', gap: 2, p: 2 }}>
|
||||||
|
<Box
|
||||||
|
sx={{
|
||||||
|
width: 72,
|
||||||
|
height: 72,
|
||||||
|
flexShrink: 0,
|
||||||
|
borderRadius: 1.5,
|
||||||
|
bgcolor: '#e8e7e4',
|
||||||
|
display: 'flex',
|
||||||
|
alignItems: 'center',
|
||||||
|
justifyContent: 'center',
|
||||||
|
backgroundImage: image ? `url(${image})` : 'none',
|
||||||
|
backgroundSize: 'cover',
|
||||||
|
backgroundPosition: 'center',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{!image && <Building2 size={24} color="#94a3b8" />}
|
||||||
|
</Box>
|
||||||
|
|
||||||
|
<Box sx={{ flex: 1, minWidth: 0 }}>
|
||||||
|
<Box sx={{ display: 'flex', justifyContent: 'space-between', alignItems: 'flex-start', gap: 1 }}>
|
||||||
|
<Typography variant="body2" sx={{ fontWeight: 700, color: '#0f172a', fontSize: '0.9rem', lineHeight: 1.3 }}>
|
||||||
|
{property.title}
|
||||||
|
</Typography>
|
||||||
|
<Box
|
||||||
|
sx={{
|
||||||
|
background: theme.gradient,
|
||||||
|
color: theme.text,
|
||||||
|
px: 1.25,
|
||||||
|
py: 0.375,
|
||||||
|
borderRadius: 1,
|
||||||
|
fontSize: '0.9rem',
|
||||||
|
fontWeight: 700,
|
||||||
|
flexShrink: 0,
|
||||||
|
border: `1px solid ${theme.border}`,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{matchScore}%
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
<Box sx={{ display: 'flex', alignItems: 'center', gap: 0.75, mt: 0.5, color: '#64748b' }}>
|
||||||
|
<MapPin size={12} />
|
||||||
|
<Typography variant="caption" sx={{ fontSize: '0.75rem' }}>
|
||||||
|
{property.location.city} · {assetTypeLabel(property.assetType)} · {property.areaSqm.toLocaleString('de-CH')} m²
|
||||||
|
</Typography>
|
||||||
|
</Box>
|
||||||
|
<Typography variant="caption" sx={{ fontSize: '0.775rem', color: '#15803d', fontWeight: 600, display: 'block', mt: 0.5 }}>
|
||||||
|
{reason}
|
||||||
|
</Typography>
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
|
||||||
|
{/* Action row */}
|
||||||
|
<Box
|
||||||
|
sx={{
|
||||||
|
borderTop: '1px solid #f1f5f9',
|
||||||
|
px: 2,
|
||||||
|
py: 1,
|
||||||
|
display: 'flex',
|
||||||
|
alignItems: 'center',
|
||||||
|
justifyContent: 'space-between',
|
||||||
|
bgcolor: '#fafafa',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Box
|
||||||
|
onClick={!disabled ? onToggle : undefined}
|
||||||
|
sx={{ display: 'flex', alignItems: 'center', gap: 0.5, cursor: disabled ? 'default' : 'pointer' }}
|
||||||
|
>
|
||||||
|
<Checkbox
|
||||||
|
checked={selected}
|
||||||
|
onChange={onToggle}
|
||||||
|
onClick={e => e.stopPropagation()}
|
||||||
|
size="small"
|
||||||
|
disabled={disabled}
|
||||||
|
sx={{ p: 0.5 }}
|
||||||
|
/>
|
||||||
|
<Typography variant="caption" sx={{ fontSize: '0.775rem', color: '#475569', fontWeight: 500 }}>
|
||||||
|
Für Angebot auswählen
|
||||||
|
</Typography>
|
||||||
|
</Box>
|
||||||
|
<Button
|
||||||
|
size="small"
|
||||||
|
variant="outlined"
|
||||||
|
onClick={onQuickOffer}
|
||||||
|
disabled={disabled}
|
||||||
|
sx={{
|
||||||
|
textTransform: 'none',
|
||||||
|
fontSize: '0.775rem',
|
||||||
|
fontWeight: 600,
|
||||||
|
borderColor: '#152642',
|
||||||
|
color: '#152642',
|
||||||
|
py: 0.5,
|
||||||
|
px: 1.5,
|
||||||
|
minWidth: 0,
|
||||||
|
'&:hover': { bgcolor: '#152642', color: 'white', borderColor: '#152642' },
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Angebot →
|
||||||
|
</Button>
|
||||||
|
</Box>
|
||||||
|
</Paper>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -5,7 +5,6 @@ import { usePublicNeeds, useLatentNeedById } from '../../hooks/useLatentNeeds'
|
|||||||
import { EmptyState } from '../ui'
|
import { EmptyState } from '../ui'
|
||||||
import { PublicNeedList } from './PublicNeedList'
|
import { PublicNeedList } from './PublicNeedList'
|
||||||
import { PublicNeedDetail } from './PublicNeedDetail'
|
import { PublicNeedDetail } from './PublicNeedDetail'
|
||||||
import { OwnPropertyMatchList } from './OwnPropertyMatchList'
|
|
||||||
|
|
||||||
type MobileView = 'list' | 'detail' | 'properties'
|
type MobileView = 'list' | 'detail' | 'properties'
|
||||||
|
|
||||||
@@ -112,7 +111,6 @@ export function LatentInquiriesTab() {
|
|||||||
</Box>
|
</Box>
|
||||||
)}
|
)}
|
||||||
</Box>
|
</Box>
|
||||||
{selectedNeed && <OwnPropertyMatchList need={selectedNeed} />}
|
|
||||||
</Box>
|
</Box>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,9 @@ import { Box, Button, CircularProgress, IconButton, TextField, Typography } from
|
|||||||
import { ArrowLeft, FileText, Paperclip, Send, X } from 'lucide-react'
|
import { ArrowLeft, FileText, Paperclip, Send, X } from 'lucide-react'
|
||||||
import { useOfferWizardStore } from '../../stores/offerWizardStore'
|
import { useOfferWizardStore } from '../../stores/offerWizardStore'
|
||||||
import { useSendOffer } from '../../hooks/useOffers'
|
import { useSendOffer } from '../../hooks/useOffers'
|
||||||
|
import { useCreateOffer } from '../../hooks/useInquiries'
|
||||||
|
import { useLatentNeedById } from '../../hooks/useLatentNeeds'
|
||||||
|
import { useSessionStore } from '../../stores/sessionStore'
|
||||||
import { useToastStore } from '../../stores/toastStore'
|
import { useToastStore } from '../../stores/toastStore'
|
||||||
import { AiOfferEmailButton } from './AiOfferEmailButton'
|
import { AiOfferEmailButton } from './AiOfferEmailButton'
|
||||||
import { mockProperties } from '../../mock-data/properties'
|
import { mockProperties } from '../../mock-data/properties'
|
||||||
@@ -24,6 +27,9 @@ export function OfferChatComposer() {
|
|||||||
const reset = useOfferWizardStore(s => s.reset)
|
const reset = useOfferWizardStore(s => s.reset)
|
||||||
|
|
||||||
const sendOffer = useSendOffer()
|
const sendOffer = useSendOffer()
|
||||||
|
const createOffer = useCreateOffer()
|
||||||
|
const { data: latentNeed } = useLatentNeedById(needId)
|
||||||
|
const currentUser = useSessionStore(s => s.currentUser)
|
||||||
const showToast = useToastStore(s => s.showToast)
|
const showToast = useToastStore(s => s.showToast)
|
||||||
|
|
||||||
const propertyTitles = selectedPropertyIds.map(id => {
|
const propertyTitles = selectedPropertyIds.map(id => {
|
||||||
@@ -60,6 +66,19 @@ export function OfferChatComposer() {
|
|||||||
showToast(`Fehler: ${res.error}`, 'error')
|
showToast(`Fehler: ${res.error}`, 'error')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
// Angebot als Konversation im Nachfrager-Postfach materialisieren
|
||||||
|
await createOffer.mutateAsync({
|
||||||
|
organizationId: currentUser?.organizationId ?? 'org-wincasa',
|
||||||
|
tenantOrgId: latentNeed?.tenantOrgId ?? 'org-mobimo',
|
||||||
|
needId: needId ?? '',
|
||||||
|
propertyId: selectedPropertyIds[0] ?? '',
|
||||||
|
offeredPropertyIds: selectedPropertyIds,
|
||||||
|
subject,
|
||||||
|
message: body,
|
||||||
|
senderName: currentUser?.organizationName ?? 'Wincasa AG',
|
||||||
|
recipientName: latentNeed?.tenantCompany,
|
||||||
|
attachments,
|
||||||
|
})
|
||||||
showToast('Angebot erfolgreich gesendet', 'success')
|
showToast('Angebot erfolgreich gesendet', 'success')
|
||||||
reset()
|
reset()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Box, Chip, Paper, Typography } from '@mui/material'
|
import { Box, Chip, Paper, Typography } from '@mui/material'
|
||||||
import { MapPin, Ruler } from 'lucide-react'
|
import { MapPin } from 'lucide-react'
|
||||||
import type { LatentNeed } from '../../domain/latentNeed'
|
import type { LatentNeed } from '../../domain/latentNeed'
|
||||||
import { assetTypeLabel, latentStatusBadge } from './latentNeedUtils'
|
import { assetTypeLabel, latentStatusBadge } from './latentNeedUtils'
|
||||||
|
|
||||||
@@ -9,6 +9,12 @@ interface PublicNeedCardProps {
|
|||||||
onClick: () => void
|
onClick: () => void
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function opportunityColor(status: 'public' | 'paused' | 'expired'): string {
|
||||||
|
if (status === 'public') return '#16a34a'
|
||||||
|
if (status === 'paused') return '#d97706'
|
||||||
|
return '#94a3b8'
|
||||||
|
}
|
||||||
|
|
||||||
export function PublicNeedCard({ need, selected, onClick }: PublicNeedCardProps) {
|
export function PublicNeedCard({ need, selected, onClick }: PublicNeedCardProps) {
|
||||||
const statusCfg = latentStatusBadge(need.status)
|
const statusCfg = latentStatusBadge(need.status)
|
||||||
return (
|
return (
|
||||||
@@ -36,17 +42,14 @@ export function PublicNeedCard({ need, selected, onClick }: PublicNeedCardProps)
|
|||||||
<Typography variant="body2" sx={{ fontWeight: 600, color: '#0f172a', fontSize: '0.85rem', lineHeight: 1.3 }}>
|
<Typography variant="body2" sx={{ fontWeight: 600, color: '#0f172a', fontSize: '0.85rem', lineHeight: 1.3 }}>
|
||||||
{need.title}
|
{need.title}
|
||||||
</Typography>
|
</Typography>
|
||||||
<Chip
|
<Box sx={{ display: 'flex', alignItems: 'center', gap: 0.75, flexShrink: 0 }}>
|
||||||
label={statusCfg.label}
|
<Box sx={{ width: 8, height: 8, borderRadius: '50%', bgcolor: opportunityColor(need.status) }} />
|
||||||
size="small"
|
<Chip
|
||||||
sx={{
|
label={statusCfg.label}
|
||||||
bgcolor: statusCfg.bg,
|
size="small"
|
||||||
color: statusCfg.fg,
|
sx={{ bgcolor: statusCfg.bg, color: statusCfg.fg, fontWeight: 600, fontSize: '0.65rem', height: 20 }}
|
||||||
fontWeight: 600,
|
/>
|
||||||
fontSize: '0.65rem',
|
</Box>
|
||||||
height: 20,
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</Box>
|
</Box>
|
||||||
|
|
||||||
{need.tenantCompany && (
|
{need.tenantCompany && (
|
||||||
@@ -74,12 +77,6 @@ export function PublicNeedCard({ need, selected, onClick }: PublicNeedCardProps)
|
|||||||
{need.desiredLocation}
|
{need.desiredLocation}
|
||||||
</Typography>
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
<Box sx={{ display: 'flex', alignItems: 'center', gap: 0.75, color: '#475569', fontSize: '0.75rem' }}>
|
|
||||||
<Ruler size={12} />
|
|
||||||
<Typography variant="caption" sx={{ fontSize: '0.75rem' }}>
|
|
||||||
{need.sizeRange.min}–{need.sizeRange.max} m²
|
|
||||||
</Typography>
|
|
||||||
</Box>
|
|
||||||
</Paper>
|
</Paper>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,242 +1,248 @@
|
|||||||
import { Alert, Box, Button, Chip, Typography } from '@mui/material'
|
import { useMemo, useState } from 'react'
|
||||||
import { CheckCircle2, Calendar, MapPin, Wallet, Info, Ruler, Sparkles } from 'lucide-react'
|
import {
|
||||||
|
Accordion, AccordionDetails, AccordionSummary,
|
||||||
|
Alert, Box, Button, Chip, CircularProgress, Divider, Paper, Typography,
|
||||||
|
} from '@mui/material'
|
||||||
|
import { Calendar, CheckCircle2, ChevronDown, Info, MapPin, Ruler, Sparkles, Target, Wallet } from 'lucide-react'
|
||||||
import type { LatentNeed } from '../../domain/latentNeed'
|
import type { LatentNeed } from '../../domain/latentNeed'
|
||||||
|
import { ResultType, UserRole } from '../../domain/enums'
|
||||||
import { useOfferWizardStore } from '../../stores/offerWizardStore'
|
import { useOfferWizardStore } from '../../stores/offerWizardStore'
|
||||||
import { useSessionStore } from '../../stores/sessionStore'
|
import { useSessionStore } from '../../stores/sessionStore'
|
||||||
import { assetTypeLabel, latentStatusBadge } from './latentNeedUtils'
|
import { useProperties } from '../../hooks/useProperties'
|
||||||
import { UserRole } from '../../domain/enums'
|
import { assetTypeLabel, deterministicMatchScore, latentStatusBadge } from './latentNeedUtils'
|
||||||
|
import { EmbeddedPropertyCard } from './EmbeddedPropertyCard'
|
||||||
|
|
||||||
interface PublicNeedDetailProps {
|
interface PublicNeedDetailProps {
|
||||||
need: LatentNeed
|
need: LatentNeed
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function buildReason(propType: string, needType: string, city: string, location: string): string {
|
||||||
|
if (propType === needType) {
|
||||||
|
const match = location.toLowerCase().includes(city.toLowerCase()) || city.toLowerCase().includes(location.toLowerCase())
|
||||||
|
return match ? 'Nutzungstyp und Standort passen sehr gut' : 'Passender Nutzungstyp, alternative Lage'
|
||||||
|
}
|
||||||
|
return 'Alternatives Profil — Detailprüfung empfohlen'
|
||||||
|
}
|
||||||
|
|
||||||
export function PublicNeedDetail({ need }: PublicNeedDetailProps) {
|
export function PublicNeedDetail({ need }: PublicNeedDetailProps) {
|
||||||
const openWizard = useOfferWizardStore(s => s.open)
|
const openWizard = useOfferWizardStore(s => s.open)
|
||||||
|
const setSelectedProperties = useOfferWizardStore(s => s.setSelectedProperties)
|
||||||
|
const selectedIds = useOfferWizardStore(s => s.selectedPropertyIds)
|
||||||
|
const toggleProperty = useOfferWizardStore(s => s.toggleProperty)
|
||||||
const currentUser = useSessionStore(s => s.currentUser)
|
const currentUser = useSessionStore(s => s.currentUser)
|
||||||
const statusCfg = latentStatusBadge(need.status)
|
const statusCfg = latentStatusBadge(need.status)
|
||||||
|
const [showAll, setShowAll] = useState(false)
|
||||||
|
|
||||||
|
const { data: properties = [], isLoading: propertiesLoading } = useProperties({ resultType: ResultType.VERIFIED_PORTFOLIO })
|
||||||
const disabled = currentUser?.role === UserRole.OWNER_VIEWER || need.status !== 'public'
|
const disabled = currentUser?.role === UserRole.OWNER_VIEWER || need.status !== 'public'
|
||||||
|
|
||||||
|
const scored = useMemo(
|
||||||
|
() =>
|
||||||
|
properties
|
||||||
|
.map(p => ({
|
||||||
|
property: p,
|
||||||
|
score: deterministicMatchScore(p.id, need.id),
|
||||||
|
reason: buildReason(p.assetType, need.assetType, p.location.city, need.desiredLocation),
|
||||||
|
}))
|
||||||
|
.sort((a, b) => b.score - a.score),
|
||||||
|
[properties, need],
|
||||||
|
)
|
||||||
|
|
||||||
|
const visible = showAll ? scored : scored.slice(0, 3)
|
||||||
|
const remaining = scored.length - 3
|
||||||
|
|
||||||
|
function handleQuickOffer(propertyId: string) {
|
||||||
|
setSelectedProperties([propertyId])
|
||||||
|
openWizard(need.id, need.title)
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box
|
<Box sx={{ flex: 1, display: 'flex', flexDirection: 'column', overflow: 'hidden', bgcolor: '#f8fafc' }}>
|
||||||
sx={{
|
{/* Scrollable content */}
|
||||||
flex: 1,
|
<Box sx={{ flex: 1, overflowY: 'auto', p: 3, display: 'flex', flexDirection: 'column', gap: 2.5 }}>
|
||||||
overflowY: 'auto',
|
|
||||||
bgcolor: '#f8fafc',
|
|
||||||
display: 'flex',
|
|
||||||
flexDirection: 'column',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Box sx={{ p: 3, display: 'flex', flexDirection: 'column', gap: 2.5 }}>
|
|
||||||
{/* Header */}
|
{/* Header */}
|
||||||
<Box>
|
<Box>
|
||||||
<Box sx={{ display: 'flex', alignItems: 'center', gap: 1, mb: 0.5 }}>
|
<Box sx={{ display: 'flex', alignItems: 'center', gap: 1, mb: 0.5 }}>
|
||||||
<Chip
|
<Chip label={assetTypeLabel(need.assetType)} size="small"
|
||||||
label={assetTypeLabel(need.assetType)}
|
sx={{ bgcolor: '#e0e7ff', color: '#3730a3', fontWeight: 600, fontSize: '0.7rem', height: 22 }} />
|
||||||
size="small"
|
<Chip label={statusCfg.label} size="small"
|
||||||
sx={{
|
sx={{ bgcolor: statusCfg.bg, color: statusCfg.fg, fontWeight: 600, fontSize: '0.7rem', height: 22 }} />
|
||||||
bgcolor: '#e0e7ff',
|
|
||||||
color: '#3730a3',
|
|
||||||
fontWeight: 600,
|
|
||||||
fontSize: '0.7rem',
|
|
||||||
height: 22,
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<Chip
|
|
||||||
label={statusCfg.label}
|
|
||||||
size="small"
|
|
||||||
sx={{
|
|
||||||
bgcolor: statusCfg.bg,
|
|
||||||
color: statusCfg.fg,
|
|
||||||
fontWeight: 600,
|
|
||||||
fontSize: '0.7rem',
|
|
||||||
height: 22,
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</Box>
|
</Box>
|
||||||
<Typography variant="h5" sx={{ fontWeight: 700, color: '#0f172a', fontSize: '1.35rem', mb: 0.5 }}>
|
<Typography variant="h5" sx={{ fontWeight: 700, color: '#0f172a', fontSize: '1.35rem', mb: 0.5 }}>
|
||||||
{need.title}
|
{need.title}
|
||||||
</Typography>
|
</Typography>
|
||||||
{need.tenantCompany && (
|
{need.tenantCompany && (
|
||||||
<Typography variant="body2" sx={{ color: '#64748b' }}>
|
<Typography variant="body2" sx={{ color: '#64748b' }}>{need.tenantCompany}</Typography>
|
||||||
{need.tenantCompany}
|
|
||||||
</Typography>
|
|
||||||
)}
|
)}
|
||||||
</Box>
|
</Box>
|
||||||
|
|
||||||
{/* AI Summary */}
|
{/* KI-Entscheidungsbrief */}
|
||||||
{need.aiSummary && (
|
{need.aiSummary && (
|
||||||
<Alert
|
<Paper variant="outlined" sx={{ p: 2.5, borderRadius: 2, borderColor: '#bfdbfe', bgcolor: '#eff6ff' }}>
|
||||||
icon={<Sparkles size={16} />}
|
<Box sx={{ display: 'flex', alignItems: 'center', gap: 1, mb: 1.25 }}>
|
||||||
severity="info"
|
<Sparkles size={16} color="#1d4ed8" />
|
||||||
sx={{
|
<Typography variant="caption"
|
||||||
bgcolor: '#eff6ff',
|
sx={{ fontWeight: 700, color: '#1d4ed8', textTransform: 'uppercase', letterSpacing: 0.8, fontSize: '0.7rem' }}>
|
||||||
borderRadius: 1.5,
|
KI-Entscheidungsbrief
|
||||||
border: '1px solid #bfdbfe',
|
</Typography>
|
||||||
'& .MuiAlert-icon': { color: '#1d4ed8' },
|
</Box>
|
||||||
'& .MuiAlert-message': { color: '#1e3a8a', fontSize: '0.875rem' },
|
<Typography variant="body1" sx={{ color: '#1e3a8a', lineHeight: 1.7, fontSize: '0.9375rem' }}>
|
||||||
}}
|
{need.aiSummary}
|
||||||
>
|
|
||||||
<Typography variant="caption" sx={{ fontWeight: 700, color: '#1d4ed8', display: 'block', mb: 0.5 }}>
|
|
||||||
KI-Analyse
|
|
||||||
</Typography>
|
</Typography>
|
||||||
{need.aiSummary}
|
</Paper>
|
||||||
</Alert>
|
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{/* Suchprofil grid */}
|
{/* Suchprofil */}
|
||||||
<Box>
|
<Box>
|
||||||
<Typography
|
<Typography variant="caption" sx={{ color: '#64748b', fontWeight: 700, textTransform: 'uppercase', letterSpacing: 0.5 }}>
|
||||||
variant="caption"
|
|
||||||
sx={{ color: '#64748b', fontWeight: 700, textTransform: 'uppercase', letterSpacing: 0.5 }}
|
|
||||||
>
|
|
||||||
Suchprofil
|
Suchprofil
|
||||||
</Typography>
|
</Typography>
|
||||||
<Box
|
<Box sx={{ mt: 1, display: 'grid', gridTemplateColumns: 'repeat(auto-fit, minmax(220px, 1fr))', gap: 1.5 }}>
|
||||||
sx={{
|
|
||||||
mt: 1,
|
|
||||||
display: 'grid',
|
|
||||||
gridTemplateColumns: 'repeat(auto-fit, minmax(220px, 1fr))',
|
|
||||||
gap: 1.5,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<ProfileBox icon={<MapPin size={14} />} label="Standort" value={need.desiredLocation} />
|
<ProfileBox icon={<MapPin size={14} />} label="Standort" value={need.desiredLocation} />
|
||||||
<ProfileBox
|
<ProfileBox icon={<Ruler size={14} />} label="Fläche" value={`${need.sizeRange.min}–${need.sizeRange.max} m²`} />
|
||||||
icon={<Ruler size={14} />}
|
|
||||||
label="Fläche"
|
|
||||||
value={`${need.sizeRange.min}–${need.sizeRange.max} m²`}
|
|
||||||
/>
|
|
||||||
<ProfileBox
|
<ProfileBox
|
||||||
icon={<Wallet size={14} />}
|
icon={<Wallet size={14} />}
|
||||||
label="Budget"
|
label="Budget"
|
||||||
value={
|
value={need.budgetRange
|
||||||
need.budgetRange
|
? `${need.budgetRange.min ? `CHF ${need.budgetRange.min}` : 'flex'}–${need.budgetRange.max ? `CHF ${need.budgetRange.max}` : 'flex'} /m²`
|
||||||
? `${need.budgetRange.min ? `CHF ${need.budgetRange.min}` : 'flex'}–${
|
: 'Flexibel'}
|
||||||
need.budgetRange.max ? `CHF ${need.budgetRange.max}` : 'flex'
|
|
||||||
} /m²`
|
|
||||||
: 'Flexibel'
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
<ProfileBox icon={<Calendar size={14} />} label="Timing" value={need.timing} />
|
<ProfileBox icon={<Calendar size={14} />} label="Timing" value={need.timing} />
|
||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
|
|
||||||
{/* Must-have Kriterien */}
|
{/* Must-haves */}
|
||||||
{need.mustHaveCriteria.length > 0 && (
|
{need.mustHaveCriteria.length > 0 && (
|
||||||
<Box>
|
<Box>
|
||||||
<Typography
|
<Typography variant="caption" sx={{ color: '#64748b', fontWeight: 700, textTransform: 'uppercase', letterSpacing: 0.5 }}>
|
||||||
variant="caption"
|
|
||||||
sx={{ color: '#64748b', fontWeight: 700, textTransform: 'uppercase', letterSpacing: 0.5 }}
|
|
||||||
>
|
|
||||||
Must-have Kriterien
|
Must-have Kriterien
|
||||||
</Typography>
|
</Typography>
|
||||||
<Box sx={{ mt: 1, display: 'flex', flexDirection: 'column', gap: 0.5 }}>
|
<Box sx={{ mt: 1, display: 'flex', flexDirection: 'column', gap: 0.5 }}>
|
||||||
{need.mustHaveCriteria.map((c, idx) => (
|
{need.mustHaveCriteria.map((c, idx) => (
|
||||||
<Box key={idx} sx={{ display: 'flex', alignItems: 'center', gap: 1 }}>
|
<Box key={idx} sx={{ display: 'flex', alignItems: 'center', gap: 1 }}>
|
||||||
<CheckCircle2 size={14} color="#16a34a" />
|
<CheckCircle2 size={14} color="#16a34a" />
|
||||||
<Typography variant="body2" sx={{ fontSize: '0.875rem', color: '#1e293b' }}>
|
<Typography variant="body2" sx={{ fontSize: '0.875rem', color: '#1e293b' }}>{c}</Typography>
|
||||||
{c}
|
|
||||||
</Typography>
|
|
||||||
</Box>
|
</Box>
|
||||||
))}
|
))}
|
||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{/* Gewichtete Präferenzen */}
|
{/* Gewichtete Präferenzen — Accordion */}
|
||||||
{need.weightedPreferences.length > 0 && (
|
{need.weightedPreferences.length > 0 && (
|
||||||
<Box>
|
<Accordion elevation={0} disableGutters
|
||||||
<Typography
|
sx={{ border: '1px solid #e2e8f0', borderRadius: '8px !important', overflow: 'hidden', '&:before': { display: 'none' }, bgcolor: 'white' }}>
|
||||||
variant="caption"
|
<AccordionSummary expandIcon={<ChevronDown size={16} color="#64748b" />}
|
||||||
sx={{ color: '#64748b', fontWeight: 700, textTransform: 'uppercase', letterSpacing: 0.5 }}
|
sx={{ px: 2, minHeight: 44, '& .MuiAccordionSummary-content': { my: 0 } }}>
|
||||||
>
|
<Typography variant="caption" sx={{ color: '#64748b', fontWeight: 700, textTransform: 'uppercase', letterSpacing: 0.5 }}>
|
||||||
Gewichtete Präferenzen
|
Gewichtete Präferenzen
|
||||||
</Typography>
|
</Typography>
|
||||||
<Box sx={{ mt: 1, display: 'flex', flexDirection: 'column', gap: 1 }}>
|
</AccordionSummary>
|
||||||
{need.weightedPreferences.map((p, idx) => {
|
<AccordionDetails sx={{ px: 2, pt: 0, pb: 2 }}>
|
||||||
const pct = Math.round(p.weight * 100)
|
<Box sx={{ display: 'flex', flexDirection: 'column', gap: 1 }}>
|
||||||
return (
|
{need.weightedPreferences.map((p, idx) => {
|
||||||
<Box
|
const pct = Math.round(p.weight * 100)
|
||||||
key={idx}
|
return (
|
||||||
sx={{
|
<Box key={idx} sx={{ bgcolor: '#f8fafc', border: '1px solid #e2e8f0', borderRadius: 1.5, px: 1.5, py: 1 }}>
|
||||||
bgcolor: 'white',
|
<Box sx={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', mb: 0.5 }}>
|
||||||
border: '1px solid #e2e8f0',
|
<Typography variant="body2" sx={{ fontWeight: 600, fontSize: '0.85rem' }}>{p.criterion}</Typography>
|
||||||
borderRadius: 1.5,
|
<Typography variant="caption"
|
||||||
px: 1.5,
|
sx={{ fontWeight: 700, color: '#152642', fontSize: '0.75rem', bgcolor: '#e0e7ff', px: 1, py: 0.125, borderRadius: 1 }}>
|
||||||
py: 1,
|
{pct}%
|
||||||
}}
|
</Typography>
|
||||||
>
|
</Box>
|
||||||
<Box sx={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', mb: 0.5 }}>
|
<Box sx={{ height: 6, borderRadius: 3, bgcolor: '#e8e7e4', overflow: 'hidden' }}>
|
||||||
<Typography variant="body2" sx={{ fontWeight: 600, fontSize: '0.85rem' }}>
|
<Box sx={{ width: `${pct}%`, height: '100%', bgcolor: '#152642', transition: 'width 0.3s' }} />
|
||||||
{p.criterion}
|
</Box>
|
||||||
</Typography>
|
{p.description && (
|
||||||
<Typography
|
<Typography variant="caption" sx={{ color: '#64748b', fontSize: '0.75rem', mt: 0.5, display: 'block' }}>
|
||||||
variant="caption"
|
{p.description}
|
||||||
sx={{
|
</Typography>
|
||||||
fontWeight: 700,
|
)}
|
||||||
color: '#152642',
|
|
||||||
fontSize: '0.75rem',
|
|
||||||
bgcolor: '#e0e7ff',
|
|
||||||
px: 1,
|
|
||||||
py: 0.125,
|
|
||||||
borderRadius: 1,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{pct}%
|
|
||||||
</Typography>
|
|
||||||
</Box>
|
</Box>
|
||||||
<Box
|
)
|
||||||
sx={{
|
})}
|
||||||
height: 6,
|
</Box>
|
||||||
borderRadius: 3,
|
</AccordionDetails>
|
||||||
bgcolor: '#e8e7e4',
|
</Accordion>
|
||||||
overflow: 'hidden',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Box
|
|
||||||
sx={{
|
|
||||||
width: `${pct}%`,
|
|
||||||
height: '100%',
|
|
||||||
bgcolor: '#152642',
|
|
||||||
transition: 'width 0.3s',
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</Box>
|
|
||||||
{p.description && (
|
|
||||||
<Typography variant="caption" sx={{ color: '#64748b', fontSize: '0.75rem', mt: 0.5, display: 'block' }}>
|
|
||||||
{p.description}
|
|
||||||
</Typography>
|
|
||||||
)}
|
|
||||||
</Box>
|
|
||||||
)
|
|
||||||
})}
|
|
||||||
</Box>
|
|
||||||
</Box>
|
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{/* Top Empfehlungen */}
|
||||||
|
<Box>
|
||||||
|
<Divider sx={{ mb: 2.5 }} />
|
||||||
|
<Box sx={{ display: 'flex', alignItems: 'center', gap: 1, mb: 1.5 }}>
|
||||||
|
<Target size={14} color="#152642" />
|
||||||
|
<Typography variant="caption" sx={{ color: '#64748b', fontWeight: 700, textTransform: 'uppercase', letterSpacing: 0.5 }}>
|
||||||
|
Ihre Top Empfehlungen
|
||||||
|
</Typography>
|
||||||
|
</Box>
|
||||||
|
{propertiesLoading ? (
|
||||||
|
<Box sx={{ display: 'flex', justifyContent: 'center', p: 3 }}><CircularProgress size={20} /></Box>
|
||||||
|
) : scored.length === 0 ? (
|
||||||
|
<Typography variant="caption" sx={{ color: '#64748b', fontSize: '0.8rem' }}>
|
||||||
|
Keine Portfolio-Objekte vorhanden
|
||||||
|
</Typography>
|
||||||
|
) : (
|
||||||
|
<Box sx={{ display: 'flex', flexDirection: 'column', gap: 1.25 }}>
|
||||||
|
{visible.map(({ property, score, reason }) => (
|
||||||
|
<EmbeddedPropertyCard
|
||||||
|
key={property.id}
|
||||||
|
property={property}
|
||||||
|
matchScore={score}
|
||||||
|
selected={selectedIds.includes(property.id)}
|
||||||
|
onToggle={() => toggleProperty(property.id)}
|
||||||
|
reason={reason}
|
||||||
|
onQuickOffer={() => handleQuickOffer(property.id)}
|
||||||
|
disabled={disabled}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
{remaining > 0 && (
|
||||||
|
<Box
|
||||||
|
onClick={() => setShowAll(s => !s)}
|
||||||
|
sx={{
|
||||||
|
py: 1.25,
|
||||||
|
textAlign: 'center',
|
||||||
|
cursor: 'pointer',
|
||||||
|
color: '#64748b',
|
||||||
|
fontSize: '0.8rem',
|
||||||
|
fontWeight: 500,
|
||||||
|
border: '1px dashed #e2e8f0',
|
||||||
|
borderRadius: 1.5,
|
||||||
|
'&:hover': { color: '#152642', borderColor: '#152642', bgcolor: '#f8fafc' },
|
||||||
|
transition: 'all 0.15s',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{showAll ? '▲ Weniger anzeigen' : `▼ Alle ${scored.length} Objekte anzeigen (+${remaining} weitere)`}
|
||||||
|
</Box>
|
||||||
|
)}
|
||||||
|
</Box>
|
||||||
|
)}
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
|
||||||
|
{/* Sticky footer CTA */}
|
||||||
|
<Box sx={{ flexShrink: 0, borderTop: '1px solid #e2e8f0', px: 3, py: 2, bgcolor: 'white' }}>
|
||||||
{disabled && need.status !== 'public' && (
|
{disabled && need.status !== 'public' && (
|
||||||
<Alert severity="warning" icon={<Info size={16} />} sx={{ fontSize: '0.8125rem' }}>
|
<Alert severity="warning" icon={<Info size={16} />} sx={{ fontSize: '0.8125rem', mb: 1.5 }}>
|
||||||
Dieser Bedarf ist aktuell {statusCfg.label.toLowerCase()} — kein Angebot möglich.
|
Dieser Bedarf ist aktuell {statusCfg.label.toLowerCase()} — kein Angebot möglich.
|
||||||
</Alert>
|
</Alert>
|
||||||
)}
|
)}
|
||||||
|
{selectedIds.length > 0 && !disabled && (
|
||||||
<Box sx={{ mt: 'auto', pt: 1 }}>
|
<Typography variant="caption" sx={{ color: '#475569', display: 'block', mb: 1, textAlign: 'center' }}>
|
||||||
<Button
|
{selectedIds.length} Objekt{selectedIds.length !== 1 ? 'e' : ''} ausgewählt
|
||||||
variant="contained"
|
</Typography>
|
||||||
size="large"
|
)}
|
||||||
fullWidth
|
<Button
|
||||||
onClick={() => openWizard(need.id, need.title)}
|
variant="contained"
|
||||||
disabled={disabled}
|
size="large"
|
||||||
sx={{
|
fullWidth
|
||||||
textTransform: 'none',
|
onClick={() => openWizard(need.id, need.title)}
|
||||||
bgcolor: '#152642',
|
disabled={disabled}
|
||||||
fontWeight: 600,
|
sx={{ textTransform: 'none', bgcolor: '#152642', fontWeight: 600, '&:hover': { bgcolor: '#16304d' } }}
|
||||||
'&:hover': { bgcolor: '#16304d' },
|
>
|
||||||
}}
|
Angebot erstellen
|
||||||
>
|
</Button>
|
||||||
Angebot erstellen
|
|
||||||
</Button>
|
|
||||||
</Box>
|
|
||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
)
|
)
|
||||||
@@ -244,24 +250,14 @@ export function PublicNeedDetail({ need }: PublicNeedDetailProps) {
|
|||||||
|
|
||||||
function ProfileBox({ icon, label, value }: { icon: React.ReactNode; label: string; value: string }) {
|
function ProfileBox({ icon, label, value }: { icon: React.ReactNode; label: string; value: string }) {
|
||||||
return (
|
return (
|
||||||
<Box
|
<Box sx={{ bgcolor: 'white', border: '1px solid #e2e8f0', borderRadius: 1.5, px: 1.5, py: 1 }}>
|
||||||
sx={{
|
|
||||||
bgcolor: 'white',
|
|
||||||
border: '1px solid #e2e8f0',
|
|
||||||
borderRadius: 1.5,
|
|
||||||
px: 1.5,
|
|
||||||
py: 1,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Box sx={{ display: 'flex', alignItems: 'center', gap: 0.75, color: '#64748b', mb: 0.25 }}>
|
<Box sx={{ display: 'flex', alignItems: 'center', gap: 0.75, color: '#64748b', mb: 0.25 }}>
|
||||||
{icon}
|
{icon}
|
||||||
<Typography variant="caption" sx={{ fontSize: '0.7rem', fontWeight: 600, textTransform: 'uppercase', letterSpacing: 0.5 }}>
|
<Typography variant="caption" sx={{ fontSize: '0.7rem', fontWeight: 600, textTransform: 'uppercase', letterSpacing: 0.5 }}>
|
||||||
{label}
|
{label}
|
||||||
</Typography>
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
<Typography variant="body2" sx={{ fontSize: '0.85rem', color: '#0f172a', fontWeight: 500 }}>
|
<Typography variant="body2" sx={{ fontSize: '0.85rem', color: '#0f172a', fontWeight: 500 }}>{value}</Typography>
|
||||||
{value}
|
|
||||||
</Typography>
|
|
||||||
</Box>
|
</Box>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,8 +16,8 @@ export function PublicNeedList({ selectedNeedId, onSelect, fullWidth }: PublicNe
|
|||||||
return (
|
return (
|
||||||
<Box
|
<Box
|
||||||
sx={{
|
sx={{
|
||||||
width: fullWidth ? '100%' : 280,
|
width: fullWidth ? '100%' : 260,
|
||||||
minWidth: fullWidth ? 'unset' : 280,
|
minWidth: fullWidth ? 'unset' : 260,
|
||||||
flexShrink: 0,
|
flexShrink: 0,
|
||||||
borderRight: fullWidth ? 'none' : '1px solid #e2e8f0',
|
borderRight: fullWidth ? 'none' : '1px solid #e2e8f0',
|
||||||
bgcolor: 'white',
|
bgcolor: 'white',
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ export { PublicNeedCard } from './PublicNeedCard'
|
|||||||
export { PublicNeedDetail } from './PublicNeedDetail'
|
export { PublicNeedDetail } from './PublicNeedDetail'
|
||||||
export { OwnPropertyMatchList } from './OwnPropertyMatchList'
|
export { OwnPropertyMatchList } from './OwnPropertyMatchList'
|
||||||
export { SelectablePropertyMatchCard } from './SelectablePropertyMatchCard'
|
export { SelectablePropertyMatchCard } from './SelectablePropertyMatchCard'
|
||||||
|
export { EmbeddedPropertyCard } from './EmbeddedPropertyCard'
|
||||||
export { OfferCreationPanel } from './OfferCreationPanel'
|
export { OfferCreationPanel } from './OfferCreationPanel'
|
||||||
export { OfferPropertySelectionStep } from './OfferPropertySelectionStep'
|
export { OfferPropertySelectionStep } from './OfferPropertySelectionStep'
|
||||||
export { OfferPdfReviewStep } from './OfferPdfReviewStep'
|
export { OfferPdfReviewStep } from './OfferPdfReviewStep'
|
||||||
|
|||||||
@@ -27,13 +27,13 @@ export function AppShell() {
|
|||||||
const location = useLocation()
|
const location = useLocation()
|
||||||
const theme = useTheme()
|
const theme = useTheme()
|
||||||
const isMobile = useMediaQuery(theme.breakpoints.down('sm'))
|
const isMobile = useMediaQuery(theme.breakpoints.down('sm'))
|
||||||
const isCompact = useMediaQuery(theme.breakpoints.down('xl'))
|
const isCompact = useMediaQuery(theme.breakpoints.down('lg'))
|
||||||
const [mobileOpen, setMobileOpen] = useState(false)
|
const [mobileOpen, setMobileOpen] = useState(false)
|
||||||
|
|
||||||
// Close mobile menu on route change
|
// Close mobile menu on route change
|
||||||
useEffect(() => { setMobileOpen(false) }, [location.pathname])
|
useEffect(() => { setMobileOpen(false) }, [location.pathname])
|
||||||
|
|
||||||
// Auto-collapse sidebar on compact screens (laptops < 1536px)
|
// Auto-collapse sidebar only on smaller screens (< 1200px); laptops keep the full nav + account
|
||||||
useEffect(() => { setSidebarCollapsed(isCompact) }, [isCompact, setSidebarCollapsed])
|
useEffect(() => { setSidebarCollapsed(isCompact) }, [isCompact, setSidebarCollapsed])
|
||||||
|
|
||||||
// Sync active workspace with URL
|
// Sync active workspace with URL
|
||||||
|
|||||||
@@ -16,11 +16,9 @@ interface Props {
|
|||||||
lat?: number
|
lat?: number
|
||||||
lng?: number
|
lng?: number
|
||||||
cityLabel?: string
|
cityLabel?: string
|
||||||
overlayTypeLabel?: string
|
|
||||||
overlayLocationLabel?: string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function IntelligenceMatchCard({ vm, imageUrl, lat, lng, cityLabel, overlayTypeLabel, overlayLocationLabel }: Props) {
|
export function IntelligenceMatchCard({ vm, imageUrl, lat, lng, cityLabel }: Props) {
|
||||||
const tier = getScoreTier(vm.matchScore)
|
const tier = getScoreTier(vm.matchScore)
|
||||||
const theme = SCORE_THEME[tier]
|
const theme = SCORE_THEME[tier]
|
||||||
const { currentUser } = useSessionStore()
|
const { currentUser } = useSessionStore()
|
||||||
@@ -59,7 +57,7 @@ export function IntelligenceMatchCard({ vm, imageUrl, lat, lng, cityLabel, overl
|
|||||||
|
|
||||||
{/* ── Hero zone ── */}
|
{/* ── Hero zone ── */}
|
||||||
<Box sx={{ position: 'relative' }}>
|
<Box sx={{ position: 'relative' }}>
|
||||||
<LocationPreview imageUrl={imageUrl} lat={lat} lng={lng} cityLabel={cityLabel} height={200} overlayTypeLabel={overlayTypeLabel} overlayLocationLabel={overlayLocationLabel} />
|
<LocationPreview imageUrl={imageUrl} lat={lat} lng={lng} cityLabel={cityLabel} aspectRatio="15/8" />
|
||||||
|
|
||||||
{/* Score badge — bottom-left editorial */}
|
{/* Score badge — bottom-left editorial */}
|
||||||
<Box sx={{
|
<Box sx={{
|
||||||
|
|||||||
@@ -6,7 +6,9 @@ import {
|
|||||||
import { Send } from 'lucide-react'
|
import { Send } from 'lucide-react'
|
||||||
import { useToastStore } from '../../stores/toastStore'
|
import { useToastStore } from '../../stores/toastStore'
|
||||||
import { useInquiryStore } from '../../stores/inquiryStore'
|
import { useInquiryStore } from '../../stores/inquiryStore'
|
||||||
|
import { useSessionStore } from '../../stores/sessionStore'
|
||||||
import { useMoveStage } from '../../hooks/usePipeline'
|
import { useMoveStage } from '../../hooks/usePipeline'
|
||||||
|
import { useCreateInquiry } from '../../hooks/useInquiries'
|
||||||
import { DS_BG, DS_BORDER, DS_TEXT } from '../../lib/ds'
|
import { DS_BG, DS_BORDER, DS_TEXT } from '../../lib/ds'
|
||||||
|
|
||||||
function buildTemplate(propertyTitle: string, location: string, areaLabel?: string): string {
|
function buildTemplate(propertyTitle: string, location: string, areaLabel?: string): string {
|
||||||
@@ -19,7 +21,8 @@ export function InquiryQuickDialog() {
|
|||||||
const dialogOpen = useInquiryStore(s => s.dialogOpen)
|
const dialogOpen = useInquiryStore(s => s.dialogOpen)
|
||||||
const pendingInquiry = useInquiryStore(s => s.pendingInquiry)
|
const pendingInquiry = useInquiryStore(s => s.pendingInquiry)
|
||||||
const closeInquiryDialog = useInquiryStore(s => s.closeInquiryDialog)
|
const closeInquiryDialog = useInquiryStore(s => s.closeInquiryDialog)
|
||||||
const addInquiry = useInquiryStore(s => s.addInquiry)
|
const currentUser = useSessionStore(s => s.currentUser)
|
||||||
|
const createInquiry = useCreateInquiry()
|
||||||
const { mutate: moveStage } = useMoveStage()
|
const { mutate: moveStage } = useMoveStage()
|
||||||
|
|
||||||
const [message, setMessage] = useState('')
|
const [message, setMessage] = useState('')
|
||||||
@@ -32,7 +35,18 @@ export function InquiryQuickDialog() {
|
|||||||
|
|
||||||
function handleSend() {
|
function handleSend() {
|
||||||
if (!pendingInquiry) return
|
if (!pendingInquiry) return
|
||||||
addInquiry(pendingInquiry, message)
|
createInquiry.mutate({
|
||||||
|
organizationId: 'org-wincasa', // Supply-Org des Objekts (Mock: Wincasa)
|
||||||
|
tenantOrgId: currentUser?.organizationId ?? 'org-mobimo',
|
||||||
|
propertyId: pendingInquiry.propertyId ?? 'unknown',
|
||||||
|
tenantName: currentUser?.name ?? 'Demand User',
|
||||||
|
tenantCompany: currentUser?.organizationName,
|
||||||
|
tenantEmail: currentUser?.email,
|
||||||
|
propertyAddress: pendingInquiry.propertyTitle,
|
||||||
|
subject: `Anfrage: ${pendingInquiry.propertyTitle}`,
|
||||||
|
message,
|
||||||
|
matchScore: pendingInquiry.matchScore,
|
||||||
|
})
|
||||||
if (pendingInquiry.pipelineItemId) {
|
if (pendingInquiry.pipelineItemId) {
|
||||||
moveStage({ id: pendingInquiry.pipelineItemId, stage: 'CONTACTED' })
|
moveStage({ id: pendingInquiry.pipelineItemId, stage: 'CONTACTED' })
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,9 +8,11 @@ interface Props {
|
|||||||
futureCount: number
|
futureCount: number
|
||||||
view?: 'list' | 'grid'
|
view?: 'list' | 'grid'
|
||||||
onViewChange?: (v: 'list' | 'grid') => void
|
onViewChange?: (v: 'list' | 'grid') => void
|
||||||
|
columns?: 3 | 5 | 10
|
||||||
|
onColumnsChange?: (n: 3 | 5 | 10) => void
|
||||||
}
|
}
|
||||||
|
|
||||||
export function ResultFeedHeader({ total, platformCount, maisonWorkCount, futureCount, view = 'list', onViewChange }: Props) {
|
export function ResultFeedHeader({ total, platformCount, maisonWorkCount, futureCount, view = 'list', onViewChange, columns = 3, onColumnsChange }: Props) {
|
||||||
return (
|
return (
|
||||||
<Box sx={{ bgcolor: 'white', borderBottom: '1px solid #e2e8f0', px: 3, py: 2, display: 'flex', alignItems: 'center', justifyContent: 'space-between' }}>
|
<Box sx={{ bgcolor: 'white', borderBottom: '1px solid #e2e8f0', px: 3, py: 2, display: 'flex', alignItems: 'center', justifyContent: 'space-between' }}>
|
||||||
<Box>
|
<Box>
|
||||||
@@ -21,9 +23,30 @@ export function ResultFeedHeader({ total, platformCount, maisonWorkCount, future
|
|||||||
{platformCount} Plattform · {maisonWorkCount} Maison Work · {futureCount} Future Availability
|
{platformCount} Plattform · {maisonWorkCount} Maison Work · {futureCount} Future Availability
|
||||||
</Typography>
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
{onViewChange && (
|
<Box sx={{ display: 'flex', gap: 1, alignItems: 'center' }}>
|
||||||
<ViewToggle view={view} onChange={onViewChange} />
|
{view === 'grid' && onColumnsChange && (
|
||||||
)}
|
<Box sx={{ display: 'flex', border: '1px solid #e2e8f0', borderRadius: 1, overflow: 'hidden' }}>
|
||||||
|
{([3, 5, 10] as const).map(n => (
|
||||||
|
<Box
|
||||||
|
key={n}
|
||||||
|
onClick={() => onColumnsChange(n)}
|
||||||
|
sx={{
|
||||||
|
width: 32, height: 32, display: 'flex', alignItems: 'center', justifyContent: 'center',
|
||||||
|
cursor: 'pointer', fontSize: '0.72rem', fontWeight: 600,
|
||||||
|
bgcolor: columns === n ? '#152642' : 'transparent',
|
||||||
|
color: columns === n ? 'white' : '#64748b',
|
||||||
|
'&:hover': { bgcolor: columns === n ? '#162d4a' : '#f1f5f9' },
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{n}
|
||||||
|
</Box>
|
||||||
|
))}
|
||||||
|
</Box>
|
||||||
|
)}
|
||||||
|
{onViewChange && (
|
||||||
|
<ViewToggle view={view} onChange={onViewChange} />
|
||||||
|
)}
|
||||||
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import { useNavigate } from 'react-router'
|
|||||||
import { MatchCardCompact } from '../match-card/MatchCardCompact'
|
import { MatchCardCompact } from '../match-card/MatchCardCompact'
|
||||||
import { IntelligenceMatchCard } from '../match-card/IntelligenceMatchCard'
|
import { IntelligenceMatchCard } from '../match-card/IntelligenceMatchCard'
|
||||||
import { buildMatchCardViewModel } from '../../features/matching/matchCardAdapter'
|
import { buildMatchCardViewModel } from '../../features/matching/matchCardAdapter'
|
||||||
import { resolveImageLabel } from '../../lib/propertyImageResolver'
|
|
||||||
import { useCompareStore } from '../../stores/compareStore'
|
import { useCompareStore } from '../../stores/compareStore'
|
||||||
import { usePipelineStore } from '../../stores/pipelineStore'
|
import { usePipelineStore } from '../../stores/pipelineStore'
|
||||||
import type { UnifiedMatchResult } from '../../domain/unifiedResult'
|
import type { UnifiedMatchResult } from '../../domain/unifiedResult'
|
||||||
@@ -98,17 +97,6 @@ export function UnifiedResultCard({ result, view = 'list' }: Props) {
|
|||||||
? result.property.location.city
|
? result.property.location.city
|
||||||
: result.signal.locationHint ?? undefined
|
: result.signal.locationHint ?? undefined
|
||||||
|
|
||||||
const overlayLabels = result.resultType !== 'FUTURE_AVAILABILITY'
|
|
||||||
? resolveImageLabel({
|
|
||||||
assetType: result.property.assetType,
|
|
||||||
city: result.property.location.city,
|
|
||||||
district: result.property.location.district,
|
|
||||||
prestige: result.property.softFactors?.prestige,
|
|
||||||
floorLevel: result.property.floorLevel,
|
|
||||||
propertyId: result.property.id,
|
|
||||||
})
|
|
||||||
: null
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<IntelligenceMatchCard
|
<IntelligenceMatchCard
|
||||||
vm={vm}
|
vm={vm}
|
||||||
@@ -116,8 +104,6 @@ export function UnifiedResultCard({ result, view = 'list' }: Props) {
|
|||||||
lat={lat}
|
lat={lat}
|
||||||
lng={lng}
|
lng={lng}
|
||||||
cityLabel={cityLabel}
|
cityLabel={cityLabel}
|
||||||
overlayTypeLabel={overlayLabels?.type}
|
|
||||||
overlayLocationLabel={overlayLabels?.location}
|
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import { SCORE_THEME } from '../shared/scoreTheme'
|
|||||||
interface Props {
|
interface Props {
|
||||||
results: UnifiedMatchResult[]
|
results: UnifiedMatchResult[]
|
||||||
view?: 'list' | 'grid'
|
view?: 'list' | 'grid'
|
||||||
|
columns?: 3 | 5 | 10
|
||||||
}
|
}
|
||||||
|
|
||||||
const TIER_CONFIG = [
|
const TIER_CONFIG = [
|
||||||
@@ -40,7 +41,7 @@ interface TierHeaderProps {
|
|||||||
function TierHeader({ label, sublabel, tierKey, count, isFirst }: TierHeaderProps) {
|
function TierHeader({ label, sublabel, tierKey, count, isFirst }: TierHeaderProps) {
|
||||||
const theme = SCORE_THEME[tierKey]
|
const theme = SCORE_THEME[tierKey]
|
||||||
return (
|
return (
|
||||||
<Box sx={{ display: 'flex', alignItems: 'center', gap: 1.5, mt: isFirst ? 0 : 3, mb: 1.5 }}>
|
<Box sx={{ display: 'flex', alignItems: 'center', gap: 1.5, mt: isFirst ? 0 : 4.5, mb: 2.5 }}>
|
||||||
<Box
|
<Box
|
||||||
sx={{
|
sx={{
|
||||||
width: 4,
|
width: 4,
|
||||||
@@ -72,7 +73,7 @@ function TierHeader({ label, sublabel, tierKey, count, isFirst }: TierHeaderProp
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function UnifiedResultFeed({ results, view = 'list' }: Props) {
|
export function UnifiedResultFeed({ results, view = 'list', columns = 3 }: Props) {
|
||||||
// All results — real properties and Schattenmarkt signals — are sorted into
|
// All results — real properties and Schattenmarkt signals — are sorted into
|
||||||
// the same score tiers so they appear in a single unified ranked list.
|
// the same score tiers so they appear in a single unified ranked list.
|
||||||
const tiers = TIER_CONFIG.map(t => ({ ...t, items: results.filter(t.filter) }))
|
const tiers = TIER_CONFIG.map(t => ({ ...t, items: results.filter(t.filter) }))
|
||||||
@@ -80,7 +81,7 @@ export function UnifiedResultFeed({ results, view = 'list' }: Props) {
|
|||||||
|
|
||||||
function renderCards(items: UnifiedMatchResult[]) {
|
function renderCards(items: UnifiedMatchResult[]) {
|
||||||
return view === 'grid' ? (
|
return view === 'grid' ? (
|
||||||
<Box sx={{ display: 'grid', gridTemplateColumns: 'repeat(auto-fill, minmax(320px, 1fr))', gap: 2 }}>
|
<Box sx={{ display: 'grid', gridTemplateColumns: `repeat(${columns}, 1fr)`, gap: 3 }}>
|
||||||
{items.map(result => (
|
{items.map(result => (
|
||||||
<UnifiedResultCard key={result.matchId} result={result} view="grid" />
|
<UnifiedResultCard key={result.matchId} result={result} view="grid" />
|
||||||
))}
|
))}
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ interface Props {
|
|||||||
address?: string
|
address?: string
|
||||||
cityLabel?: string
|
cityLabel?: string
|
||||||
height?: number
|
height?: number
|
||||||
|
/** When set, the hero scales proportionally with width (e.g. '15/8') instead of using a fixed pixel height. */
|
||||||
|
aspectRatio?: string
|
||||||
overlayTypeLabel?: string
|
overlayTypeLabel?: string
|
||||||
overlayLocationLabel?: string
|
overlayLocationLabel?: string
|
||||||
}
|
}
|
||||||
@@ -23,13 +25,13 @@ function buildMapsUrl(lat?: number, lng?: number, address?: string): string {
|
|||||||
return 'https://www.google.com/maps'
|
return 'https://www.google.com/maps'
|
||||||
}
|
}
|
||||||
|
|
||||||
export function LocationPreview({ imageUrl, lat, lng, address, cityLabel, height = 180, overlayTypeLabel, overlayLocationLabel }: Props) {
|
export function LocationPreview({ imageUrl, lat, lng, address, cityLabel, height = 180, aspectRatio, overlayTypeLabel, overlayLocationLabel }: Props) {
|
||||||
const [imgError, setImgError] = useState(false)
|
const [imgError, setImgError] = useState(false)
|
||||||
const mapsUrl = buildMapsUrl(lat, lng, address)
|
const mapsUrl = buildMapsUrl(lat, lng, address)
|
||||||
const showImage = !!imageUrl && !imgError
|
const showImage = !!imageUrl && !imgError
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box sx={{ position: 'relative', width: '100%', height, overflow: 'hidden', flexShrink: 0 }}>
|
<Box sx={{ position: 'relative', width: '100%', ...(aspectRatio ? { aspectRatio } : { height }), overflow: 'hidden', flexShrink: 0 }}>
|
||||||
{showImage ? (
|
{showImage ? (
|
||||||
<img
|
<img
|
||||||
src={imageUrl}
|
src={imageUrl}
|
||||||
|
|||||||
@@ -20,10 +20,20 @@ export interface InquiryMessage {
|
|||||||
|
|
||||||
export type InquiryStatus = 'new' | 'in_progress' | 'answered' | 'archived'
|
export type InquiryStatus = 'new' | 'in_progress' | 'answered' | 'archived'
|
||||||
|
|
||||||
|
/** Konversationstyp: Nachfrager-initiierte Anfrage vs. Verwaltung-initiiertes Angebot. */
|
||||||
|
export type InquiryKind = 'INQUIRY' | 'OFFER'
|
||||||
|
|
||||||
export interface Inquiry {
|
export interface Inquiry {
|
||||||
id: string
|
id: string
|
||||||
|
/** Supply-Organisation (Eigentümer/Verwaltung des Objekts). */
|
||||||
organizationId: string
|
organizationId: string
|
||||||
|
/** Nachfrager-Organisation — für das Demand-Postfach. */
|
||||||
|
tenantOrgId?: string
|
||||||
|
/** INQUIRY (Demand→Supply) oder OFFER (Supply→Demand). Default INQUIRY. */
|
||||||
|
kind?: InquiryKind
|
||||||
propertyId: string
|
propertyId: string
|
||||||
|
/** Bei OFFER: alle im Angebot enthaltenen Objekte. */
|
||||||
|
offeredPropertyIds?: string[]
|
||||||
needId?: string
|
needId?: string
|
||||||
tenantName: string
|
tenantName: string
|
||||||
tenantCompany?: string
|
tenantCompany?: string
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ export interface LatentNeed {
|
|||||||
id: string
|
id: string
|
||||||
title: string
|
title: string
|
||||||
tenantCompany?: string
|
tenantCompany?: string
|
||||||
|
/** Nachfrager-Organisation — Empfänger eines Angebots (Demo-Default-Routing: org-mobimo). */
|
||||||
|
tenantOrgId?: string
|
||||||
assetType: AssetType
|
assetType: AssetType
|
||||||
desiredLocation: string
|
desiredLocation: string
|
||||||
sizeRange: { min: number; max: number }
|
sizeRange: { min: number; max: number }
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'
|
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'
|
||||||
import { inquiryService } from '../services/inquiryService'
|
import { inquiryService } from '../services/inquiryService'
|
||||||
import type { InquiryFilters } from '../provider/IInquiryProvider'
|
import type { InquiryFilters, CreateInquiryInput, CreateOfferInput } from '../provider/IInquiryProvider'
|
||||||
import type { Attachment } from '../domain/inquiry'
|
import type { Attachment, InquiryMessage } from '../domain/inquiry'
|
||||||
import { useToastStore } from '../stores/toastStore'
|
import { useToastStore } from '../stores/toastStore'
|
||||||
|
|
||||||
export function useActiveInquiries(filters?: InquiryFilters) {
|
export function useActiveInquiries(filters?: InquiryFilters) {
|
||||||
@@ -29,7 +29,7 @@ export function useSendInquiryReply() {
|
|||||||
payload,
|
payload,
|
||||||
}: {
|
}: {
|
||||||
inquiryId: string
|
inquiryId: string
|
||||||
payload: { subject?: string; body: string; attachments?: Attachment[] }
|
payload: { subject?: string; body: string; attachments?: Attachment[]; senderType?: InquiryMessage['senderType']; senderName?: string }
|
||||||
}) => inquiryService.sendInquiryReply(inquiryId, payload),
|
}) => inquiryService.sendInquiryReply(inquiryId, payload),
|
||||||
onSuccess: (_data, { inquiryId }) => {
|
onSuccess: (_data, { inquiryId }) => {
|
||||||
qc.invalidateQueries({ queryKey: ['inquiry', inquiryId] })
|
qc.invalidateQueries({ queryKey: ['inquiry', inquiryId] })
|
||||||
@@ -41,6 +41,31 @@ export function useSendInquiryReply() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Demand→Supply: neue Anfrage erstellen (ersetzt die alte Zustand-Insel). */
|
||||||
|
export function useCreateInquiry() {
|
||||||
|
const qc = useQueryClient()
|
||||||
|
return useMutation({
|
||||||
|
mutationFn: (input: CreateInquiryInput) => inquiryService.createInquiry(input),
|
||||||
|
onSuccess: () => {
|
||||||
|
qc.invalidateQueries({ queryKey: ['inquiries'] })
|
||||||
|
},
|
||||||
|
onError: () => {
|
||||||
|
useToastStore.getState().showToast('Anfrage konnte nicht gesendet werden.', 'error')
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Supply→Demand: Angebot als Konversation im Nachfrager-Postfach materialisieren. */
|
||||||
|
export function useCreateOffer() {
|
||||||
|
const qc = useQueryClient()
|
||||||
|
return useMutation({
|
||||||
|
mutationFn: (input: CreateOfferInput) => inquiryService.createOffer(input),
|
||||||
|
onSuccess: () => {
|
||||||
|
qc.invalidateQueries({ queryKey: ['inquiries'] })
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
export function useMarkThreadAsRead() {
|
export function useMarkThreadAsRead() {
|
||||||
const qc = useQueryClient()
|
const qc = useQueryClient()
|
||||||
return useMutation({
|
return useMutation({
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ export const mockDemandInquiries: Inquiry[] = [
|
|||||||
{
|
{
|
||||||
id: 'dinq-001',
|
id: 'dinq-001',
|
||||||
organizationId: 'org-wincasa',
|
organizationId: 'org-wincasa',
|
||||||
|
tenantOrgId: 'org-mobimo',
|
||||||
|
kind: 'INQUIRY',
|
||||||
propertyId: 'prop-technopark',
|
propertyId: 'prop-technopark',
|
||||||
tenantName: 'Admin User',
|
tenantName: 'Admin User',
|
||||||
tenantCompany: 'Mobimo Management AG',
|
tenantCompany: 'Mobimo Management AG',
|
||||||
@@ -39,6 +41,8 @@ export const mockDemandInquiries: Inquiry[] = [
|
|||||||
{
|
{
|
||||||
id: 'dinq-002',
|
id: 'dinq-002',
|
||||||
organizationId: 'org-wincasa',
|
organizationId: 'org-wincasa',
|
||||||
|
tenantOrgId: 'org-mobimo',
|
||||||
|
kind: 'INQUIRY',
|
||||||
propertyId: 'prop-hardturmpark',
|
propertyId: 'prop-hardturmpark',
|
||||||
tenantName: 'Admin User',
|
tenantName: 'Admin User',
|
||||||
tenantCompany: 'Mobimo Management AG',
|
tenantCompany: 'Mobimo Management AG',
|
||||||
@@ -73,6 +77,8 @@ export const mockDemandInquiries: Inquiry[] = [
|
|||||||
{
|
{
|
||||||
id: 'dinq-003',
|
id: 'dinq-003',
|
||||||
organizationId: 'org-wincasa',
|
organizationId: 'org-wincasa',
|
||||||
|
tenantOrgId: 'org-mobimo',
|
||||||
|
kind: 'INQUIRY',
|
||||||
propertyId: 'prop-sihlcity',
|
propertyId: 'prop-sihlcity',
|
||||||
tenantName: 'Admin User',
|
tenantName: 'Admin User',
|
||||||
tenantCompany: 'Mobimo Management AG',
|
tenantCompany: 'Mobimo Management AG',
|
||||||
@@ -130,6 +136,8 @@ export const mockDemandInquiries: Inquiry[] = [
|
|||||||
{
|
{
|
||||||
id: 'dinq-004',
|
id: 'dinq-004',
|
||||||
organizationId: 'org-wincasa',
|
organizationId: 'org-wincasa',
|
||||||
|
tenantOrgId: 'org-mobimo',
|
||||||
|
kind: 'INQUIRY',
|
||||||
propertyId: 'prop-bahnhofzug',
|
propertyId: 'prop-bahnhofzug',
|
||||||
tenantName: 'Admin User',
|
tenantName: 'Admin User',
|
||||||
tenantCompany: 'Mobimo Management AG',
|
tenantCompany: 'Mobimo Management AG',
|
||||||
@@ -186,6 +194,8 @@ export const mockDemandInquiries: Inquiry[] = [
|
|||||||
{
|
{
|
||||||
id: 'dinq-005',
|
id: 'dinq-005',
|
||||||
organizationId: 'org-wincasa',
|
organizationId: 'org-wincasa',
|
||||||
|
tenantOrgId: 'org-mobimo',
|
||||||
|
kind: 'INQUIRY',
|
||||||
propertyId: 'prop-dreispitz',
|
propertyId: 'prop-dreispitz',
|
||||||
tenantName: 'Admin User',
|
tenantName: 'Admin User',
|
||||||
tenantCompany: 'Mobimo Management AG',
|
tenantCompany: 'Mobimo Management AG',
|
||||||
@@ -238,4 +248,40 @@ export const mockDemandInquiries: Inquiry[] = [
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// 6 — OFFER (Verwaltung → Nachfrager, proaktiv aus Latente Anfragen)
|
||||||
|
{
|
||||||
|
id: 'off-seed-001',
|
||||||
|
organizationId: 'org-wincasa',
|
||||||
|
tenantOrgId: 'org-mobimo',
|
||||||
|
kind: 'OFFER',
|
||||||
|
propertyId: 'prop-001',
|
||||||
|
offeredPropertyIds: ['prop-001', 'prop-093'],
|
||||||
|
tenantName: 'Mobimo Management AG',
|
||||||
|
propertyManagerCompany: 'Wincasa AG',
|
||||||
|
propertyAddress: '2 Objekte im Angebot',
|
||||||
|
subject: 'Passende Büroflächen zu Ihrem Bedarf',
|
||||||
|
message:
|
||||||
|
'Sehr geehrte Damen und Herren,\n\nbasierend auf Ihrem Suchprofil haben wir zwei passende Büroflächen für Sie zusammengestellt. Details finden Sie im beigefügten Angebot.\n\nFreundliche Grüsse\nWincasa AG',
|
||||||
|
status: 'new',
|
||||||
|
unreadCount: 1,
|
||||||
|
isRead: false,
|
||||||
|
createdAt: '2026-05-24T10:00:00Z',
|
||||||
|
updatedAt: '2026-05-24T10:00:00Z',
|
||||||
|
thread: [
|
||||||
|
{
|
||||||
|
id: 'off-seed-001-1',
|
||||||
|
inquiryId: 'off-seed-001',
|
||||||
|
senderType: 'supply_user',
|
||||||
|
senderName: 'Wincasa AG',
|
||||||
|
subject: 'Passende Büroflächen zu Ihrem Bedarf',
|
||||||
|
body:
|
||||||
|
'Sehr geehrte Damen und Herren,\n\nbasierend auf Ihrem Suchprofil haben wir zwei passende Büroflächen für Sie zusammengestellt. Details finden Sie im beigefügten Angebot.\n\nFreundliche Grüsse\nWincasa AG',
|
||||||
|
attachments: [
|
||||||
|
{ id: 'off-att-001', fileName: 'Angebot_Bueroflaechen_Zuerich.pdf', fileType: 'application/pdf', fileSize: 312500, generated: true },
|
||||||
|
],
|
||||||
|
createdAt: '2026-05-24T10:00:00Z',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -5,10 +5,9 @@ import {
|
|||||||
InputAdornment, Alert,
|
InputAdornment, Alert,
|
||||||
} from '@mui/material'
|
} from '@mui/material'
|
||||||
import { Search, Send, Paperclip, ArrowLeft, Bot, Building2, Kanban } from 'lucide-react'
|
import { Search, Send, Paperclip, ArrowLeft, Bot, Building2, Kanban } from 'lucide-react'
|
||||||
import { mockDemandInquiries } from '../../mock-data/demandInquiries'
|
import { useActiveInquiries, useSendInquiryReply, useMarkThreadAsRead } from '../../hooks/useInquiries'
|
||||||
import { useInquiryStore } from '../../stores/inquiryStore'
|
|
||||||
import { usePipelineItems, useMoveStage } from '../../hooks/usePipeline'
|
import { usePipelineItems, useMoveStage } from '../../hooks/usePipeline'
|
||||||
import type { InquiryMessage } from '../../domain/inquiry'
|
import { mockProperties } from '../../mock-data/properties'
|
||||||
import { STAGE_ORDER, STAGE_LABELS, detectKiStage } from './anfragenKiDetection'
|
import { STAGE_ORDER, STAGE_LABELS, detectKiStage } from './anfragenKiDetection'
|
||||||
import { AnfragenMessageBubble } from '../../components/demand/AnfragenMessageBubble'
|
import { AnfragenMessageBubble } from '../../components/demand/AnfragenMessageBubble'
|
||||||
import { AnfragenInquiryItem } from '../../components/demand/AnfragenInquiryItem'
|
import { AnfragenInquiryItem } from '../../components/demand/AnfragenInquiryItem'
|
||||||
@@ -18,10 +17,9 @@ import { useSessionStore } from '../../stores/sessionStore'
|
|||||||
// ── Config ────────────────────────────────────────────────────────────────────
|
// ── Config ────────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
const FILTER_TABS = [
|
const FILTER_TABS = [
|
||||||
{ key: 'all', label: 'Alle' },
|
{ key: 'all', label: 'Alle' },
|
||||||
{ key: 'new', label: 'Neu' },
|
{ key: 'INQUIRY', label: 'Gesendet' },
|
||||||
{ key: 'in_progress', label: 'Aktiv' },
|
{ key: 'OFFER', label: 'Erhalten' },
|
||||||
{ key: 'answered', label: 'Beantwortet' },
|
|
||||||
]
|
]
|
||||||
|
|
||||||
// ── Anfragen page ─────────────────────────────────────────────────────────────
|
// ── Anfragen page ─────────────────────────────────────────────────────────────
|
||||||
@@ -36,20 +34,23 @@ export default function Anfragen() {
|
|||||||
const preselectedId = searchParams.get('inquiry')
|
const preselectedId = searchParams.get('inquiry')
|
||||||
|
|
||||||
const { currentUser } = useSessionStore()
|
const { currentUser } = useSessionStore()
|
||||||
const storeInquiries = useInquiryStore(s => s.sentInquiries)
|
const { data: allInquiries = [] } = useActiveInquiries({ tenantOrgId: currentUser?.organizationId })
|
||||||
const [inquiries, setInquiries] = useState(mockDemandInquiries)
|
const sendReply = useSendInquiryReply()
|
||||||
const allInquiries = [...storeInquiries, ...inquiries]
|
const markRead = useMarkThreadAsRead()
|
||||||
|
|
||||||
const [selectedId, setSelectedId] = useState<string | null>(
|
const [selectedId, setSelectedId] = useState<string | null>(preselectedId ?? null)
|
||||||
preselectedId ?? mockDemandInquiries[0]?.id ?? null
|
|
||||||
)
|
|
||||||
const [search, setSearch] = useState('')
|
const [search, setSearch] = useState('')
|
||||||
const [statusFilter, setStatusFilter] = useState('all')
|
const [kindFilter, setKindFilter] = useState('all')
|
||||||
const [replyText, setReplyText] = useState('')
|
const [replyText, setReplyText] = useState('')
|
||||||
const [mobileShowChat, setMobileShowChat] = useState(!!preselectedId)
|
const [mobileShowChat, setMobileShowChat] = useState(!!preselectedId)
|
||||||
const [kiAlert, setKiAlert] = useState<{ title: string; stage: string } | null>(null)
|
const [kiAlert, setKiAlert] = useState<{ title: string; stage: string } | null>(null)
|
||||||
const threadRef = useRef<HTMLDivElement>(null)
|
const threadRef = useRef<HTMLDivElement>(null)
|
||||||
|
|
||||||
|
// Default-Auswahl: erste Konversation, sobald geladen
|
||||||
|
useEffect(() => {
|
||||||
|
if (!selectedId && allInquiries.length > 0) setSelectedId(allInquiries[0].id)
|
||||||
|
}, [allInquiries, selectedId])
|
||||||
|
|
||||||
const filtered = allInquiries.filter(inq => {
|
const filtered = allInquiries.filter(inq => {
|
||||||
const q = search.toLowerCase()
|
const q = search.toLowerCase()
|
||||||
const matchesSearch = !q ||
|
const matchesSearch = !q ||
|
||||||
@@ -59,12 +60,14 @@ export default function Anfragen() {
|
|||||||
(inq.propertyAddress?.toLowerCase().includes(q) ?? false) ||
|
(inq.propertyAddress?.toLowerCase().includes(q) ?? false) ||
|
||||||
(inq.propertyManagerName?.toLowerCase().includes(q) ?? false) ||
|
(inq.propertyManagerName?.toLowerCase().includes(q) ?? false) ||
|
||||||
(inq.propertyManagerCompany?.toLowerCase().includes(q) ?? false)
|
(inq.propertyManagerCompany?.toLowerCase().includes(q) ?? false)
|
||||||
const matchesStatus = statusFilter === 'all' || inq.status === statusFilter
|
const matchesKind = kindFilter === 'all' || (inq.kind ?? 'INQUIRY') === kindFilter
|
||||||
return matchesSearch && matchesStatus
|
return matchesSearch && matchesKind
|
||||||
})
|
})
|
||||||
|
|
||||||
const selected = allInquiries.find(i => i.id === selectedId) ?? null
|
const selected = allInquiries.find(i => i.id === selectedId) ?? null
|
||||||
const totalUnread = allInquiries.reduce((sum, i) => sum + i.unreadCount, 0)
|
const totalUnread = allInquiries.reduce((sum, i) => sum + i.unreadCount, 0)
|
||||||
|
const offeredProperties = (selected?.kind === 'OFFER' ? selected.offeredPropertyIds ?? [] : [])
|
||||||
|
.map(id => mockProperties.find(p => p.id === id)).filter(Boolean)
|
||||||
|
|
||||||
// Pipeline link for currently selected inquiry
|
// Pipeline link for currently selected inquiry
|
||||||
const linkedPipelineItem = selected?.propertyId
|
const linkedPipelineItem = selected?.propertyId
|
||||||
@@ -86,7 +89,7 @@ export default function Anfragen() {
|
|||||||
|
|
||||||
function handleSelect(id: string) {
|
function handleSelect(id: string) {
|
||||||
setSelectedId(id)
|
setSelectedId(id)
|
||||||
setInquiries(prev => prev.map(i => i.id === id ? { ...i, isRead: true, unreadCount: 0 } : i))
|
markRead.mutate(id)
|
||||||
setMobileShowChat(true)
|
setMobileShowChat(true)
|
||||||
setKiAlert(null)
|
setKiAlert(null)
|
||||||
}
|
}
|
||||||
@@ -95,20 +98,10 @@ export default function Anfragen() {
|
|||||||
if (!replyText.trim() || !selectedId) return
|
if (!replyText.trim() || !selectedId) return
|
||||||
const text = replyText.trim()
|
const text = replyText.trim()
|
||||||
|
|
||||||
const msg: InquiryMessage = {
|
sendReply.mutate({
|
||||||
id: `msg-${Date.now()}`,
|
|
||||||
inquiryId: selectedId,
|
inquiryId: selectedId,
|
||||||
senderType: 'tenant',
|
payload: { body: text, senderType: 'tenant', senderName: currentUser?.name ?? 'Sie' },
|
||||||
senderName: 'Sie',
|
})
|
||||||
body: text,
|
|
||||||
attachments: [],
|
|
||||||
createdAt: new Date().toISOString(),
|
|
||||||
}
|
|
||||||
setInquiries(prev => prev.map(i =>
|
|
||||||
i.id === selectedId
|
|
||||||
? { ...i, thread: [...i.thread, msg], status: 'in_progress', updatedAt: new Date().toISOString() }
|
|
||||||
: i
|
|
||||||
))
|
|
||||||
setReplyText('')
|
setReplyText('')
|
||||||
|
|
||||||
// KI: detect stage transition from message content
|
// KI: detect stage transition from message content
|
||||||
@@ -160,13 +153,13 @@ export default function Anfragen() {
|
|||||||
/>
|
/>
|
||||||
<Box sx={{ display: 'flex', gap: 0.5, flexWrap: 'wrap' }}>
|
<Box sx={{ display: 'flex', gap: 0.5, flexWrap: 'wrap' }}>
|
||||||
{FILTER_TABS.map(tab => (
|
{FILTER_TABS.map(tab => (
|
||||||
<Chip key={tab.key} label={tab.label} size="small" onClick={() => setStatusFilter(tab.key)}
|
<Chip key={tab.key} label={tab.label} size="small" onClick={() => setKindFilter(tab.key)}
|
||||||
sx={{
|
sx={{
|
||||||
height: 22, fontSize: '0.7rem', cursor: 'pointer',
|
height: 22, fontSize: '0.7rem', cursor: 'pointer',
|
||||||
bgcolor: statusFilter === tab.key ? 'primary.main' : DS_BG.subtle,
|
bgcolor: kindFilter === tab.key ? 'primary.main' : DS_BG.subtle,
|
||||||
color: statusFilter === tab.key ? 'white' : DS_TEXT.secondary,
|
color: kindFilter === tab.key ? 'white' : DS_TEXT.secondary,
|
||||||
fontWeight: statusFilter === tab.key ? 700 : 400,
|
fontWeight: kindFilter === tab.key ? 700 : 400,
|
||||||
'&:hover': { bgcolor: statusFilter === tab.key ? 'primary.dark' : DS_BG.muted },
|
'&:hover': { bgcolor: kindFilter === tab.key ? 'primary.dark' : DS_BG.muted },
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
@@ -291,6 +284,27 @@ export default function Anfragen() {
|
|||||||
</Box>
|
</Box>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{/* Angebot: enthaltene Objekte */}
|
||||||
|
{offeredProperties.length > 0 && (
|
||||||
|
<Box sx={{ px: { xs: 2, md: 3 }, pt: 1.5, flexShrink: 0 }}>
|
||||||
|
<Typography variant="caption" sx={{ color: DS_TEXT.muted, fontWeight: 700, textTransform: 'uppercase', letterSpacing: 0.4, display: 'block', mb: 0.75 }}>
|
||||||
|
Enthaltene Objekte ({offeredProperties.length})
|
||||||
|
</Typography>
|
||||||
|
<Box sx={{ display: 'flex', gap: 1, flexWrap: 'wrap' }}>
|
||||||
|
{offeredProperties.map(p => p && (
|
||||||
|
<Chip
|
||||||
|
key={p.id}
|
||||||
|
icon={<Building2 size={12} />}
|
||||||
|
label={`${p.title} · CHF ${p.rentPricePerSqm}/m²`}
|
||||||
|
size="small"
|
||||||
|
onClick={() => navigate(`/demand/property/${p.id}`)}
|
||||||
|
sx={{ cursor: 'pointer', bgcolor: DS_SURFACE.blue.bg, color: DS_TEXT.signalDark, border: `1px solid ${DS_SURFACE.blue.border}`, fontSize: '0.72rem', '& .MuiChip-icon': { color: DS_TEXT.signalDark } }}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
)}
|
||||||
|
|
||||||
{/* Thread */}
|
{/* Thread */}
|
||||||
<Box ref={threadRef} sx={{ flex: 1, overflowY: 'auto', px: { xs: 2, md: 3 }, py: 2.5, display: 'flex', flexDirection: 'column', gap: 0.5 }}>
|
<Box ref={threadRef} sx={{ flex: 1, overflowY: 'auto', px: { xs: 2, md: 3 }, py: 2.5, display: 'flex', flexDirection: 'column', gap: 0.5 }}>
|
||||||
{selected.thread.map(msg => (
|
{selected.thread.map(msg => (
|
||||||
|
|||||||
@@ -44,6 +44,9 @@ export default function Results() {
|
|||||||
const [view, setView] = useState<'list' | 'grid'>(() =>
|
const [view, setView] = useState<'list' | 'grid'>(() =>
|
||||||
(localStorage.getItem('view-results') as 'list' | 'grid') ?? 'list'
|
(localStorage.getItem('view-results') as 'list' | 'grid') ?? 'list'
|
||||||
)
|
)
|
||||||
|
const [columns, setColumns] = useState<3 | 5 | 10>(() =>
|
||||||
|
(Number(localStorage.getItem('view-results-cols')) as 3 | 5 | 10) || 3
|
||||||
|
)
|
||||||
|
|
||||||
// When coming from NeedBuilder, invalidate so the freshly created need is included
|
// When coming from NeedBuilder, invalidate so the freshly created need is included
|
||||||
const activeNeedIdFromNav = (location.state as { activeNeedId?: string } | null)?.activeNeedId
|
const activeNeedIdFromNav = (location.state as { activeNeedId?: string } | null)?.activeNeedId
|
||||||
@@ -107,9 +110,11 @@ export default function Results() {
|
|||||||
futureCount={futureCount}
|
futureCount={futureCount}
|
||||||
view={view}
|
view={view}
|
||||||
onViewChange={v => { setView(v); localStorage.setItem('view-results', v) }}
|
onViewChange={v => { setView(v); localStorage.setItem('view-results', v) }}
|
||||||
|
columns={columns}
|
||||||
|
onColumnsChange={n => { setColumns(n); localStorage.setItem('view-results-cols', String(n)) }}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Box sx={{ flex: 1, overflowY: 'auto', px: 3, py: 3, pb: 10 }}>
|
<Box sx={{ flex: 1, overflowY: 'auto', px: 3, py: 4, pb: 12 }}>
|
||||||
|
|
||||||
{/* Aktive Suche */}
|
{/* Aktive Suche */}
|
||||||
{activeNeed && (
|
{activeNeed && (
|
||||||
@@ -169,7 +174,7 @@ export default function Results() {
|
|||||||
</Box>
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
)}
|
)}
|
||||||
<UnifiedResultFeed results={sorted} view={view} />
|
<UnifiedResultFeed results={sorted} view={view} columns={columns} />
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</Box>
|
</Box>
|
||||||
|
|||||||
@@ -2,11 +2,13 @@ import { useState } from 'react'
|
|||||||
import { useLocation } from 'react-router'
|
import { useLocation } from 'react-router'
|
||||||
import { Box, Tab, Tabs, Typography } from '@mui/material'
|
import { Box, Tab, Tabs, Typography } from '@mui/material'
|
||||||
import { ActiveInquiriesTab, LatentInquiriesTab, OfferWizard } from '../../components/anfragencenter'
|
import { ActiveInquiriesTab, LatentInquiriesTab, OfferWizard } from '../../components/anfragencenter'
|
||||||
|
import { useSessionStore } from '../../stores/sessionStore'
|
||||||
|
|
||||||
export default function Anfragencenter() {
|
export default function Anfragencenter() {
|
||||||
const location = useLocation()
|
const location = useLocation()
|
||||||
const initialTab = (location.state as { tab?: number } | null)?.tab ?? 0
|
const initialTab = (location.state as { tab?: number } | null)?.tab ?? 0
|
||||||
const [tab, setTab] = useState(initialTab)
|
const [tab, setTab] = useState(initialTab)
|
||||||
|
const orgId = useSessionStore(s => s.currentUser?.organizationId)
|
||||||
return (
|
return (
|
||||||
<Box sx={{ display: 'flex', flexDirection: 'column', height: '100%', overflow: 'hidden' }}>
|
<Box sx={{ display: 'flex', flexDirection: 'column', height: '100%', overflow: 'hidden' }}>
|
||||||
<Box sx={{ borderBottom: '1px solid #e8e7e4', px: 3, bgcolor: 'white', flexShrink: 0 }}>
|
<Box sx={{ borderBottom: '1px solid #e8e7e4', px: 3, bgcolor: 'white', flexShrink: 0 }}>
|
||||||
@@ -21,12 +23,20 @@ export default function Anfragencenter() {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Tab label="Aktive Anfragen" />
|
<Tab label="Aktive Anfragen" />
|
||||||
|
<Tab label="Gesendet" />
|
||||||
<Tab label="Latente Anfragen" />
|
<Tab label="Latente Anfragen" />
|
||||||
</Tabs>
|
</Tabs>
|
||||||
</Box>
|
</Box>
|
||||||
<Box sx={{ flex: 1, overflow: 'hidden' }}>
|
<Box sx={{ flex: 1, overflow: 'hidden' }}>
|
||||||
{tab === 0 && <ActiveInquiriesTab />}
|
{tab === 0 && <ActiveInquiriesTab filters={{ organizationId: orgId, kind: 'INQUIRY' }} />}
|
||||||
{tab === 1 && <LatentInquiriesTab />}
|
{tab === 1 && (
|
||||||
|
<ActiveInquiriesTab
|
||||||
|
filters={{ organizationId: orgId, kind: 'OFFER' }}
|
||||||
|
emptyTitle="Keine gesendeten Angebote"
|
||||||
|
emptyDescription="Angebote aus den latenten Anfragen erscheinen hier, sobald Sie sie versenden."
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
{tab === 2 && <LatentInquiriesTab />}
|
||||||
</Box>
|
</Box>
|
||||||
<OfferWizard />
|
<OfferWizard />
|
||||||
</Box>
|
</Box>
|
||||||
|
|||||||
@@ -1,17 +1,50 @@
|
|||||||
import type { Inquiry, InquiryStatus, InquiryMessage } from '../domain/inquiry'
|
import type { Inquiry, InquiryStatus, InquiryKind, InquiryMessage, Attachment } from '../domain/inquiry'
|
||||||
|
|
||||||
export interface InquiryFilters {
|
export interface InquiryFilters {
|
||||||
status?: InquiryStatus
|
status?: InquiryStatus
|
||||||
propertyId?: string
|
propertyId?: string
|
||||||
organizationId?: string
|
organizationId?: string // Supply-Perspektive
|
||||||
|
tenantOrgId?: string // Demand-Perspektive
|
||||||
|
kind?: InquiryKind
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Demand→Supply: neue Anfrage zu einem Objekt. */
|
||||||
|
export interface CreateInquiryInput {
|
||||||
|
organizationId: string // Supply-Org (Objekt-Eigentümer)
|
||||||
|
tenantOrgId: string // Demand-Org (Absender)
|
||||||
|
propertyId: string
|
||||||
|
needId?: string
|
||||||
|
tenantName: string
|
||||||
|
tenantCompany?: string
|
||||||
|
tenantEmail?: string
|
||||||
|
propertyAddress?: string
|
||||||
|
subject: string
|
||||||
|
message: string
|
||||||
|
matchScore?: number
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Supply→Demand: Angebot zu einem latenten Bedarf. */
|
||||||
|
export interface CreateOfferInput {
|
||||||
|
organizationId: string // Supply-Org (Absender)
|
||||||
|
tenantOrgId: string // Demand-Org (Empfänger, aus need.organizationId)
|
||||||
|
needId: string
|
||||||
|
propertyId: string // primäres Objekt (Kompatibilität)
|
||||||
|
offeredPropertyIds: string[]
|
||||||
|
subject: string
|
||||||
|
message: string
|
||||||
|
senderName: string // Verwaltungs-/Org-Name
|
||||||
|
recipientName?: string
|
||||||
|
attachments?: Attachment[]
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IInquiryProvider {
|
export interface IInquiryProvider {
|
||||||
getAll(filters?: InquiryFilters): Promise<Inquiry[]>
|
getAll(filters?: InquiryFilters): Promise<Inquiry[]>
|
||||||
getById(id: string): Promise<Inquiry | null>
|
getById(id: string): Promise<Inquiry | null>
|
||||||
|
createInquiry(input: CreateInquiryInput): Promise<Inquiry>
|
||||||
|
createOffer(input: CreateOfferInput): Promise<Inquiry>
|
||||||
updateStatus(id: string, status: InquiryStatus): Promise<Inquiry>
|
updateStatus(id: string, status: InquiryStatus): Promise<Inquiry>
|
||||||
markThreadAsRead(id: string): Promise<Inquiry>
|
markThreadAsRead(id: string): Promise<Inquiry>
|
||||||
getUnreadCount(): Promise<number>
|
getUnreadCount(filters?: InquiryFilters): Promise<number>
|
||||||
addMessage(
|
addMessage(
|
||||||
inquiryId: string,
|
inquiryId: string,
|
||||||
msg: Omit<InquiryMessage, 'id' | 'inquiryId' | 'createdAt'>,
|
msg: Omit<InquiryMessage, 'id' | 'inquiryId' | 'createdAt'>,
|
||||||
|
|||||||
@@ -1,20 +1,99 @@
|
|||||||
import type { IInquiryProvider, InquiryFilters } from './IInquiryProvider'
|
import type { IInquiryProvider, InquiryFilters, CreateInquiryInput, CreateOfferInput } from './IInquiryProvider'
|
||||||
import type { Inquiry, InquiryStatus, InquiryMessage } from '../domain/inquiry'
|
import type { Inquiry, InquiryStatus, InquiryMessage } from '../domain/inquiry'
|
||||||
import { mockInquiries } from '../mock-data/inquiries'
|
import { mockInquiries } from '../mock-data/inquiries'
|
||||||
|
import { mockDemandInquiries } from '../mock-data/demandInquiries'
|
||||||
|
|
||||||
const store: Inquiry[] = mockInquiries.map(i => ({ ...i, thread: [...i.thread] }))
|
// Eine gemeinsame Konversationsmenge: Supply-Eingang (mockInquiries) + Demand-Perspektive
|
||||||
|
// (mockDemandInquiries, inkl. erhaltener Angebote). Beide Seiten lesen perspektivisch gefiltert.
|
||||||
|
const store: Inquiry[] = [...mockInquiries, ...mockDemandInquiries].map(i => ({ ...i, thread: [...i.thread] }))
|
||||||
|
|
||||||
|
function applyFilters(results: Inquiry[], filters?: InquiryFilters): Inquiry[] {
|
||||||
|
let out = results
|
||||||
|
if (filters?.status) out = out.filter(i => i.status === filters.status)
|
||||||
|
if (filters?.propertyId) out = out.filter(i => i.propertyId === filters.propertyId)
|
||||||
|
if (filters?.organizationId) out = out.filter(i => i.organizationId === filters.organizationId)
|
||||||
|
if (filters?.tenantOrgId) out = out.filter(i => i.tenantOrgId === filters.tenantOrgId)
|
||||||
|
if (filters?.kind) out = out.filter(i => (i.kind ?? 'INQUIRY') === filters.kind)
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
export const MockupInquiryProvider: IInquiryProvider = {
|
export const MockupInquiryProvider: IInquiryProvider = {
|
||||||
async getAll(filters?: InquiryFilters): Promise<Inquiry[]> {
|
async getAll(filters?: InquiryFilters): Promise<Inquiry[]> {
|
||||||
let results = [...store]
|
return applyFilters([...store], filters).sort((a, b) => (a.updatedAt < b.updatedAt ? 1 : -1))
|
||||||
if (filters?.status) results = results.filter(i => i.status === filters.status)
|
|
||||||
if (filters?.propertyId) results = results.filter(i => i.propertyId === filters.propertyId)
|
|
||||||
if (filters?.organizationId) results = results.filter(i => i.organizationId === filters.organizationId)
|
|
||||||
return results.sort((a, b) => (a.createdAt < b.createdAt ? 1 : -1))
|
|
||||||
},
|
},
|
||||||
async getById(id: string): Promise<Inquiry | null> {
|
async getById(id: string): Promise<Inquiry | null> {
|
||||||
return store.find(i => i.id === id) ?? null
|
return store.find(i => i.id === id) ?? null
|
||||||
},
|
},
|
||||||
|
async createInquiry(input: CreateInquiryInput): Promise<Inquiry> {
|
||||||
|
const now = new Date().toISOString()
|
||||||
|
const id = `inq-${crypto.randomUUID().slice(0, 8)}`
|
||||||
|
const inquiry: Inquiry = {
|
||||||
|
id,
|
||||||
|
kind: 'INQUIRY',
|
||||||
|
organizationId: input.organizationId,
|
||||||
|
tenantOrgId: input.tenantOrgId,
|
||||||
|
propertyId: input.propertyId,
|
||||||
|
needId: input.needId,
|
||||||
|
tenantName: input.tenantName,
|
||||||
|
tenantCompany: input.tenantCompany,
|
||||||
|
tenantEmail: input.tenantEmail,
|
||||||
|
propertyAddress: input.propertyAddress,
|
||||||
|
subject: input.subject,
|
||||||
|
message: input.message,
|
||||||
|
status: 'new',
|
||||||
|
unreadCount: 1, // neu für die Verwaltung (Empfänger)
|
||||||
|
isRead: false,
|
||||||
|
matchScore: input.matchScore,
|
||||||
|
createdAt: now,
|
||||||
|
updatedAt: now,
|
||||||
|
thread: [{
|
||||||
|
id: crypto.randomUUID(),
|
||||||
|
inquiryId: id,
|
||||||
|
senderType: 'tenant',
|
||||||
|
senderName: input.tenantCompany ?? input.tenantName,
|
||||||
|
subject: input.subject,
|
||||||
|
body: input.message,
|
||||||
|
attachments: [],
|
||||||
|
createdAt: now,
|
||||||
|
}],
|
||||||
|
}
|
||||||
|
store.unshift(inquiry)
|
||||||
|
return inquiry
|
||||||
|
},
|
||||||
|
async createOffer(input: CreateOfferInput): Promise<Inquiry> {
|
||||||
|
const now = new Date().toISOString()
|
||||||
|
const id = `off-${crypto.randomUUID().slice(0, 8)}`
|
||||||
|
const inquiry: Inquiry = {
|
||||||
|
id,
|
||||||
|
kind: 'OFFER',
|
||||||
|
organizationId: input.organizationId,
|
||||||
|
tenantOrgId: input.tenantOrgId,
|
||||||
|
propertyId: input.propertyId,
|
||||||
|
offeredPropertyIds: input.offeredPropertyIds,
|
||||||
|
needId: input.needId,
|
||||||
|
tenantName: input.recipientName ?? '',
|
||||||
|
propertyManagerCompany: input.senderName,
|
||||||
|
subject: input.subject,
|
||||||
|
message: input.message,
|
||||||
|
status: 'new',
|
||||||
|
unreadCount: 1, // neu für den Nachfrager (Empfänger)
|
||||||
|
isRead: false,
|
||||||
|
createdAt: now,
|
||||||
|
updatedAt: now,
|
||||||
|
thread: [{
|
||||||
|
id: crypto.randomUUID(),
|
||||||
|
inquiryId: id,
|
||||||
|
senderType: 'supply_user',
|
||||||
|
senderName: input.senderName,
|
||||||
|
subject: input.subject,
|
||||||
|
body: input.message,
|
||||||
|
attachments: input.attachments ?? [],
|
||||||
|
createdAt: now,
|
||||||
|
}],
|
||||||
|
}
|
||||||
|
store.unshift(inquiry)
|
||||||
|
return inquiry
|
||||||
|
},
|
||||||
async updateStatus(id: string, status: InquiryStatus): Promise<Inquiry> {
|
async updateStatus(id: string, status: InquiryStatus): Promise<Inquiry> {
|
||||||
const idx = store.findIndex(i => i.id === id)
|
const idx = store.findIndex(i => i.id === id)
|
||||||
if (idx === -1) throw new Error(`Inquiry ${id} not found`)
|
if (idx === -1) throw new Error(`Inquiry ${id} not found`)
|
||||||
@@ -33,8 +112,8 @@ export const MockupInquiryProvider: IInquiryProvider = {
|
|||||||
}
|
}
|
||||||
return store[idx]
|
return store[idx]
|
||||||
},
|
},
|
||||||
async getUnreadCount(): Promise<number> {
|
async getUnreadCount(filters?: InquiryFilters): Promise<number> {
|
||||||
return store.reduce((sum, i) => sum + (i.unreadCount ?? 0), 0)
|
return applyFilters([...store], filters).reduce((sum, i) => sum + (i.unreadCount ?? 0), 0)
|
||||||
},
|
},
|
||||||
async addMessage(
|
async addMessage(
|
||||||
inquiryId: string,
|
inquiryId: string,
|
||||||
@@ -51,6 +130,10 @@ export const MockupInquiryProvider: IInquiryProvider = {
|
|||||||
store[idx] = {
|
store[idx] = {
|
||||||
...store[idx],
|
...store[idx],
|
||||||
thread: [...store[idx].thread, message],
|
thread: [...store[idx].thread, message],
|
||||||
|
// Neue Nachricht der Gegenseite → für den Empfänger ungelesen
|
||||||
|
unreadCount: (store[idx].unreadCount ?? 0) + 1,
|
||||||
|
isRead: false,
|
||||||
|
status: store[idx].status === 'new' ? 'in_progress' : store[idx].status,
|
||||||
updatedAt: message.createdAt,
|
updatedAt: message.createdAt,
|
||||||
}
|
}
|
||||||
return store[idx]
|
return store[idx]
|
||||||
|
|||||||
@@ -1,12 +1,39 @@
|
|||||||
import { AssetType } from '../../domain/enums'
|
import { AssetType } from '../../domain/enums'
|
||||||
import type { ParsedNeedCriteria, WeightingKey } from '../../domain/needBuilder'
|
import type { ParsedNeedCriteria, WeightingKey } from '../../domain/needBuilder'
|
||||||
import type { CreateNeedInput } from '../../domain/need'
|
import type { CreateNeedInput, Need } from '../../domain/need'
|
||||||
|
|
||||||
const ASSET_LABELS_TEXT: Record<string, string> = {
|
const ASSET_LABELS_TEXT: Record<string, string> = {
|
||||||
OFFICE: 'Bürofläche', RETAIL: 'Retail-Fläche', LOGISTICS: 'Logistikfläche',
|
OFFICE: 'Bürofläche', RETAIL: 'Retail-Fläche', LOGISTICS: 'Logistikfläche',
|
||||||
PRODUCTION: 'Produktionsfläche', LIGHT_INDUSTRIAL: 'Gewerbefläche', MIXED: 'gemischte Fläche',
|
PRODUCTION: 'Produktionsfläche', LIGHT_INDUSTRIAL: 'Gewerbefläche', MIXED: 'gemischte Fläche',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function needToParsedCriteria(need: Need): ParsedNeedCriteria {
|
||||||
|
return {
|
||||||
|
assetType: need.assetType,
|
||||||
|
areaRange: need.requiredArea,
|
||||||
|
preferredLocations: need.preferredLocations,
|
||||||
|
budgetRange: need.budgetRange,
|
||||||
|
timing: need.timing,
|
||||||
|
mustHaveCriteria: need.mustCriteriaText,
|
||||||
|
softFactors: need.softFactors,
|
||||||
|
requireGroundFloor: need.requireGroundFloor,
|
||||||
|
requiredFitOut: need.requiredFitOut,
|
||||||
|
requiredParkingMin: need.requiredParkingMin,
|
||||||
|
requireAirConditioning: need.requireAirConditioning,
|
||||||
|
requireLoadingDock: need.requireLoadingDock,
|
||||||
|
requireBarrierFree: need.requireBarrierFree,
|
||||||
|
minCeilingHeightM: need.minCeilingHeightM,
|
||||||
|
minContractDurationMonths: need.minContractDurationMonths,
|
||||||
|
searchRadius: need.searchRadius,
|
||||||
|
isAnonymous: need.isAnonymous,
|
||||||
|
requiresDivisibility: need.requiresDivisibility,
|
||||||
|
minDivisibleUnit: need.minDivisibleUnit,
|
||||||
|
fitOutBudgetMaxPerSqm: need.fitOutBudgetMaxPerSqm,
|
||||||
|
notes: need.notes,
|
||||||
|
companyName: need.companyName,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export function generateSummary(c: ParsedNeedCriteria): string {
|
export function generateSummary(c: ParsedNeedCriteria): string {
|
||||||
const parts: string[] = []
|
const parts: string[] = []
|
||||||
if (c.assetType) parts.push(`Suche ${ASSET_LABELS_TEXT[c.assetType] ?? c.assetType}`)
|
if (c.assetType) parts.push(`Suche ${ASSET_LABELS_TEXT[c.assetType] ?? c.assetType}`)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { MockupInquiryProvider } from '../provider/MockupInquiryProvider'
|
import { MockupInquiryProvider } from '../provider/MockupInquiryProvider'
|
||||||
import type { InquiryFilters } from '../provider/IInquiryProvider'
|
import type { InquiryFilters, CreateInquiryInput, CreateOfferInput } from '../provider/IInquiryProvider'
|
||||||
import type { Inquiry, Attachment } from '../domain/inquiry'
|
import type { Inquiry, Attachment, InquiryMessage } from '../domain/inquiry'
|
||||||
import type { ListResponse, ItemResponse } from './types'
|
import type { ListResponse, ItemResponse } from './types'
|
||||||
import { throwServiceError } from './errors'
|
import { throwServiceError } from './errors'
|
||||||
|
|
||||||
@@ -10,6 +10,8 @@ export interface InquiryReplyPayload {
|
|||||||
subject?: string
|
subject?: string
|
||||||
body: string
|
body: string
|
||||||
attachments?: Attachment[]
|
attachments?: Attachment[]
|
||||||
|
senderType?: InquiryMessage['senderType'] // default 'supply_user'
|
||||||
|
senderName?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export const inquiryService = {
|
export const inquiryService = {
|
||||||
@@ -31,14 +33,32 @@ export const inquiryService = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
async createInquiry(input: CreateInquiryInput): Promise<ItemResponse<Inquiry>> {
|
||||||
|
try {
|
||||||
|
const data = await provider.createInquiry(input)
|
||||||
|
return { data }
|
||||||
|
} catch (err) {
|
||||||
|
throwServiceError(err)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
async createOffer(input: CreateOfferInput): Promise<ItemResponse<Inquiry>> {
|
||||||
|
try {
|
||||||
|
const data = await provider.createOffer(input)
|
||||||
|
return { data }
|
||||||
|
} catch (err) {
|
||||||
|
throwServiceError(err)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
async sendInquiryReply(
|
async sendInquiryReply(
|
||||||
inquiryId: string,
|
inquiryId: string,
|
||||||
payload: InquiryReplyPayload,
|
payload: InquiryReplyPayload,
|
||||||
): Promise<ItemResponse<Inquiry>> {
|
): Promise<ItemResponse<Inquiry>> {
|
||||||
try {
|
try {
|
||||||
const data = await provider.addMessage(inquiryId, {
|
const data = await provider.addMessage(inquiryId, {
|
||||||
senderType: 'supply_user',
|
senderType: payload.senderType ?? 'supply_user',
|
||||||
senderName: 'Wincasa AG',
|
senderName: payload.senderName ?? 'Wincasa AG',
|
||||||
subject: payload.subject,
|
subject: payload.subject,
|
||||||
body: payload.body,
|
body: payload.body,
|
||||||
attachments: payload.attachments ?? [],
|
attachments: payload.attachments ?? [],
|
||||||
@@ -58,9 +78,9 @@ export const inquiryService = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
async getUnreadCount(): Promise<ItemResponse<number>> {
|
async getUnreadCount(filters?: InquiryFilters): Promise<ItemResponse<number>> {
|
||||||
try {
|
try {
|
||||||
const data = await provider.getUnreadCount()
|
const data = await provider.getUnreadCount(filters)
|
||||||
return { data }
|
return { data }
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
throwServiceError(err)
|
throwServiceError(err)
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import type { NeedFilters } from '../provider/INeedProvider'
|
|||||||
import type { Need, CreateNeedInput, UpdateNeedInput } from '../domain/need'
|
import type { Need, CreateNeedInput, UpdateNeedInput } from '../domain/need'
|
||||||
import type { ListResponse, ItemResponse } from './types'
|
import type { ListResponse, ItemResponse } from './types'
|
||||||
import { throwServiceError } from './errors'
|
import { throwServiceError } from './errors'
|
||||||
|
import { useSessionStore } from '../stores/sessionStore'
|
||||||
|
|
||||||
const provider = MockupNeedProvider
|
const provider = MockupNeedProvider
|
||||||
|
|
||||||
@@ -25,7 +26,10 @@ export const needService = {
|
|||||||
},
|
},
|
||||||
async create(input: CreateNeedInput): Promise<ItemResponse<Need>> {
|
async create(input: CreateNeedInput): Promise<ItemResponse<Need>> {
|
||||||
try {
|
try {
|
||||||
const data = await provider.create(input)
|
// Neues Suchprofil der Organisation des Erstellers zuordnen (sonst fällt es aus der
|
||||||
|
// org-gefilterten Liste — Aktive-Suche-Leiste zeigt sonst ein fremdes Profil)
|
||||||
|
const orgId = useSessionStore.getState().currentUser?.organizationId
|
||||||
|
const data = await provider.create({ ...input, organizationId: input.organizationId ?? orgId })
|
||||||
return { data }
|
return { data }
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
throwServiceError(err)
|
throwServiceError(err)
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { create } from 'zustand'
|
import { create } from 'zustand'
|
||||||
import type { Inquiry, InquiryMessage } from '../domain/inquiry'
|
|
||||||
|
|
||||||
|
// Reine UI-State: der Anfrage-Dialog. Versendete Anfragen leben jetzt im Provider
|
||||||
|
// (MockupInquiryProvider) und werden via React Query gelesen — nicht mehr hier.
|
||||||
export interface PendingInquiry {
|
export interface PendingInquiry {
|
||||||
propertyTitle: string
|
propertyTitle: string
|
||||||
location: string
|
location: string
|
||||||
@@ -13,15 +14,10 @@ export interface PendingInquiry {
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface InquiryStore {
|
interface InquiryStore {
|
||||||
// Dialog state
|
|
||||||
dialogOpen: boolean
|
dialogOpen: boolean
|
||||||
pendingInquiry: PendingInquiry | null
|
pendingInquiry: PendingInquiry | null
|
||||||
openInquiryDialog: (item: PendingInquiry) => void
|
openInquiryDialog: (item: PendingInquiry) => void
|
||||||
closeInquiryDialog: () => void
|
closeInquiryDialog: () => void
|
||||||
|
|
||||||
// Sent inquiries (in-memory, persists for the session)
|
|
||||||
sentInquiries: Inquiry[]
|
|
||||||
addInquiry: (item: PendingInquiry, message: string) => void
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const useInquiryStore = create<InquiryStore>((set) => ({
|
export const useInquiryStore = create<InquiryStore>((set) => ({
|
||||||
@@ -29,44 +25,4 @@ export const useInquiryStore = create<InquiryStore>((set) => ({
|
|||||||
pendingInquiry: null,
|
pendingInquiry: null,
|
||||||
openInquiryDialog: (item) => set({ dialogOpen: true, pendingInquiry: item }),
|
openInquiryDialog: (item) => set({ dialogOpen: true, pendingInquiry: item }),
|
||||||
closeInquiryDialog: () => set({ dialogOpen: false, pendingInquiry: null }),
|
closeInquiryDialog: () => set({ dialogOpen: false, pendingInquiry: null }),
|
||||||
|
|
||||||
sentInquiries: [],
|
|
||||||
addInquiry: (item, message) => {
|
|
||||||
const now = new Date().toISOString()
|
|
||||||
const msgId = `msg-sent-${Date.now()}`
|
|
||||||
const id = `sent-${Date.now()}`
|
|
||||||
|
|
||||||
const thread: InquiryMessage = {
|
|
||||||
id: msgId,
|
|
||||||
inquiryId: id,
|
|
||||||
senderType: 'tenant',
|
|
||||||
senderName: 'Admin User',
|
|
||||||
body: message,
|
|
||||||
attachments: [],
|
|
||||||
createdAt: now,
|
|
||||||
}
|
|
||||||
|
|
||||||
const inquiry: Inquiry = {
|
|
||||||
id,
|
|
||||||
organizationId: 'org-wincasa',
|
|
||||||
propertyId: item.propertyId ?? 'unknown',
|
|
||||||
tenantName: 'Admin User',
|
|
||||||
tenantCompany: 'Mobimo Management AG',
|
|
||||||
tenantEmail: 'admin@ideal-sharing.ch',
|
|
||||||
propertyAddress: item.propertyTitle,
|
|
||||||
propertyManagerName: 'Verwalter',
|
|
||||||
propertyManagerCompany: '',
|
|
||||||
subject: 'Anfrage: ' + item.propertyTitle,
|
|
||||||
message,
|
|
||||||
status: 'new',
|
|
||||||
unreadCount: 0,
|
|
||||||
isRead: true,
|
|
||||||
matchScore: item.matchScore,
|
|
||||||
createdAt: now,
|
|
||||||
updatedAt: now,
|
|
||||||
thread: [thread],
|
|
||||||
}
|
|
||||||
|
|
||||||
set(state => ({ sentInquiries: [inquiry, ...state.sentInquiries] }))
|
|
||||||
},
|
|
||||||
}))
|
}))
|
||||||
|
|||||||
Reference in New Issue
Block a user