feat: integrate private offers with existing editorial workflow

This commit is contained in:
2026-11-14 16:20:30 +02:00
parent 6e302db62e
commit 91c1857368
19 changed files with 1353 additions and 30 deletions
+27 -2
View File
@@ -8,6 +8,8 @@ import OpportunityContactForm from '@/components/opportunity-contact-form';
import { modalityLabels } from '@/components/opportunity-search-filters';
import { createOperationKey } from '@/lib/operation-key';
import { profileJson, ProfileValidationError } from '@/lib/profile-json';
import OfferEditorialReview from '@/components/offer-editorial-review';
import { type OfferEditorialRecord } from '@/lib/offer-editorial';
type Offer = {
price_mode?: string | null;
@@ -20,7 +22,7 @@ type Context = {
organization_name: string | null;
type: string;
};
type RecordData = {
type RecordData = OfferEditorialRecord & {
id: number;
reference: string;
etag: string;
@@ -28,6 +30,7 @@ type RecordData = {
canEdit: boolean;
organization_id: string | null;
territory: TerritoryOption[];
contactLabel?: string | null;
values: {
title?: string;
description?: string;
@@ -76,7 +79,19 @@ export default function OfferPreparation({
},
);
const [territory, setTerritory] = useState(record?.territory ?? emptyPath);
const [contactChoices, setContactChoices] = useState(contacts);
const [contactChoices, setContactChoices] = useState(() => {
const selected = record?.values.private_offer?.contact_id;
return selected && !contacts.some((contact) => contact.id === selected)
? [
...contacts,
{
id: selected,
full_name:
record?.contactLabel ?? 'Contacto indisponível',
},
]
: contacts;
});
const [dirty, setDirty] = useState(!record);
const [busy, setBusy] = useState(false);
const [confirmed, setConfirmed] = useState(false);
@@ -159,6 +174,16 @@ export default function OfferPreparation({
</p>
{saved && <p className="mt-2 text-sm">{saved.reference}</p>}
</header>
{saved && (
<OfferEditorialReview
record={saved}
onChanged={(next) => {
setSaved(next);
setDirty(false);
setConfirmed(false);
}}
/>
)}
<div role="status" aria-live="polite">
{message}
</div>