diff --git a/src/components/supply/PropertyMarketSignalsTab.tsx b/src/components/supply/PropertyMarketSignalsTab.tsx index 6ad31d2..4268f5d 100644 --- a/src/components/supply/PropertyMarketSignalsTab.tsx +++ b/src/components/supply/PropertyMarketSignalsTab.tsx @@ -1,7 +1,9 @@ import { useEffect, useRef, useState } from 'react' +import { useNavigate } from 'react-router' import { Alert, Box, Button, Chip, CircularProgress, Dialog, DialogContent, DialogTitle, LinearProgress, Typography } from '@mui/material' -import { BarChart2, Building2, CheckCircle, Download, FileText, Lightbulb, TrendingUp } from 'lucide-react' +import { BarChart2, Building2, CheckCircle, Download, FileText, Lightbulb, Send, TrendingUp } from 'lucide-react' import { marketReportService } from '../../services/marketReportService' +import { useOfferWizardStore } from '../../stores/offerWizardStore' import type { MarketReport, PropertyMarketSignal, SignalCategory } from '../../domain/marketReport' interface Props { @@ -220,6 +222,13 @@ export function PropertyMarketSignalsTab({ propertyId }: Props) { const [report, setReport] = useState(null) const [loading, setLoading] = useState(true) const [dialogOpen, setDialogOpen] = useState(false) + const navigate = useNavigate() + const setSelectedProperties = useOfferWizardStore(s => s.setSelectedProperties) + + function handleAngebotErstellen() { + setSelectedProperties([propertyId]) + navigate('/supply/anfragen', { state: { tab: 1 } }) + } useEffect(() => { let cancelled = false @@ -251,15 +260,26 @@ export function PropertyMarketSignalsTab({ propertyId }: Props) { )} - + + + + {!report ? ( @@ -288,6 +308,13 @@ export function PropertyMarketSignalsTab({ propertyId }: Props) { ) }) )} + + setDialogOpen(false)} + report={report} + propertyId={propertyId} + /> ) } diff --git a/src/pages/supply/Anfragencenter.tsx b/src/pages/supply/Anfragencenter.tsx index a5d7ae0..08d665e 100644 --- a/src/pages/supply/Anfragencenter.tsx +++ b/src/pages/supply/Anfragencenter.tsx @@ -1,9 +1,12 @@ import { useState } from 'react' +import { useLocation } from 'react-router' import { Box, Tab, Tabs, Typography } from '@mui/material' import { ActiveInquiriesTab, LatentInquiriesTab, OfferWizard } from '../../components/anfragencenter' export default function Anfragencenter() { - const [tab, setTab] = useState(0) + const location = useLocation() + const initialTab = (location.state as { tab?: number } | null)?.tab ?? 0 + const [tab, setTab] = useState(initialTab) return ( diff --git a/src/stores/offerWizardStore.ts b/src/stores/offerWizardStore.ts index ec2437c..71ffa8e 100644 --- a/src/stores/offerWizardStore.ts +++ b/src/stores/offerWizardStore.ts @@ -43,11 +43,11 @@ export const useOfferWizardStore = create((set) => ({ messageSubject: '', attachments: [], open: (needId, needTitle) => - set({ + set((s) => ({ isOpen: true, selectedNeedId: needId, needTitle, - selectedPropertyIds: [], + selectedPropertyIds: s.selectedPropertyIds, currentStep: 'select_properties', offerDraftId: null, editableFields: {}, @@ -55,7 +55,7 @@ export const useOfferWizardStore = create((set) => ({ messageDraft: '', messageSubject: '', attachments: [], - }), + })), close: () => set({ isOpen: false }), toggleProperty: (id) => set((s) => ({