feat: integrate private offers with existing editorial workflow
This commit is contained in:
@@ -40,6 +40,7 @@ export default function EditorialWorkflow({
|
||||
filters = {},
|
||||
resourceAccess,
|
||||
opportunitiesUrl,
|
||||
offersUrl = null,
|
||||
opportunityPending,
|
||||
clustersUrl,
|
||||
portfolioUrl,
|
||||
@@ -54,6 +55,7 @@ export default function EditorialWorkflow({
|
||||
}: {
|
||||
resourceAccess: boolean;
|
||||
opportunitiesUrl: string | null;
|
||||
offersUrl?: string | null;
|
||||
opportunityPending: number;
|
||||
clustersUrl?: string | null;
|
||||
portfolioUrl?: string | null;
|
||||
@@ -104,6 +106,10 @@ export default function EditorialWorkflow({
|
||||
href: opportunitiesUrl,
|
||||
pending: opportunityPending,
|
||||
},
|
||||
{
|
||||
label: 'Ofertas — revisão privada',
|
||||
href: offersUrl,
|
||||
},
|
||||
{
|
||||
label: 'Biblioteca e editores',
|
||||
href: resourceAccess ? '/management/portal-services' : null,
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
import { Head, Link } from '@inertiajs/react';
|
||||
import { offerStates } from '@/lib/offer-editorial';
|
||||
|
||||
export default function OfferPreparations({
|
||||
records,
|
||||
canCreate,
|
||||
filters = {},
|
||||
}: {
|
||||
records: {
|
||||
data: {
|
||||
@@ -15,6 +17,7 @@ export default function OfferPreparations({
|
||||
next_page_url: string | null;
|
||||
};
|
||||
canCreate: boolean;
|
||||
filters?: { state?: string };
|
||||
}) {
|
||||
return (
|
||||
<main className="mx-auto w-full max-w-5xl space-y-6 p-4 md:p-8">
|
||||
@@ -37,6 +40,28 @@ export default function OfferPreparations({
|
||||
</Link>
|
||||
)}
|
||||
</header>
|
||||
<nav
|
||||
aria-label="Filtrar ofertas por estado"
|
||||
className="flex flex-wrap gap-3 text-sm"
|
||||
>
|
||||
<Link
|
||||
href="/minhas-oportunidades/ofertas"
|
||||
aria-current={!filters.state ? 'page' : undefined}
|
||||
>
|
||||
Todas
|
||||
</Link>
|
||||
{Object.entries(offerStates).map(([state, label]) => (
|
||||
<Link
|
||||
key={state}
|
||||
href={`/minhas-oportunidades/ofertas?state=${state}`}
|
||||
aria-current={
|
||||
filters.state === state ? 'page' : undefined
|
||||
}
|
||||
>
|
||||
{label}
|
||||
</Link>
|
||||
))}
|
||||
</nav>
|
||||
{!records.data.length && (
|
||||
<p>Ainda não existem ofertas neste âmbito.</p>
|
||||
)}
|
||||
@@ -51,9 +76,7 @@ export default function OfferPreparations({
|
||||
</Link>
|
||||
<p className="text-muted-foreground mt-1 text-sm">
|
||||
{record.reference} ·{' '}
|
||||
{record.state === 'submitted'
|
||||
? 'Submissão privada registada'
|
||||
: 'Rascunho privado'}
|
||||
{offerStates[record.state] ?? record.state}
|
||||
</p>
|
||||
</li>
|
||||
))}
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user