diff --git a/src/components/offers/OfferForm.jsx b/src/components/offers/OfferForm.jsx index d50de33..b9c4855 100644 --- a/src/components/offers/OfferForm.jsx +++ b/src/components/offers/OfferForm.jsx @@ -1,11 +1,10 @@ -import { useEffect, useMemo, useState } from 'react' -import { FaSpinner } from 'react-icons/fa6' -import { Card, Button, AutocompleteInput } from '../ui' +import { useEffect, useMemo, useRef, useState } from 'react' +import { Dialog, Field, Button, AutocompleteInput } from '../ui' import { useCustomers } from '../../hooks/useCustomers' +import { useScrollIntoView } from '../../hooks/useScrollIntoView' import { createOffer, getOfferContext } from '../../lib/teamApi' import { customerPickLabel, findCustomerByLabel } from '../../lib/chatFormat' import { createdMessage, evaluateOfferForm, offerConfirm } from '../../lib/offerFormat' -import '../../styles/admin-areas.css' const MONTHS = Array.from({ length: 12 }, (_, i) => i + 1) @@ -29,6 +28,8 @@ export default function OfferForm({ fixedCustomerId, fixedCustomerName, onCreate const [ctx, setCtx] = useState(null) // { customerId, data } | { customerId, error } const [busy, setBusy] = useState(false) const [error, setError] = useState('') + const errorRef = useRef(null) + useScrollIntoView(errorRef, error) useEffect(() => { setCtx(null) @@ -83,62 +84,70 @@ export default function OfferForm({ fixedCustomerId, fixedCustomerName, onCreate } let previewBox - if (!customerId) previewBox =
Bitte einen Kunden aus der Liste wählen.
+ else if (ctx?.error && ctx.customerId === customerId) previewBox ={ctx.error}
+ else if (!ready) previewBox =Lade Kunde…
else { previewBox = ( <> - {evaluation.errors.map((l) =>{l}
)} + {evaluation.previewLines.map((l) =>{l}
)} > ) } return ( -