feat(offers): complete phase five operational controls in QA
This commit is contained in:
@@ -41,6 +41,7 @@ export default function EditorialWorkflow({
|
||||
resourceAccess,
|
||||
opportunitiesUrl,
|
||||
offersUrl = null,
|
||||
offerOperationsUrl = null,
|
||||
opportunityPending,
|
||||
clustersUrl,
|
||||
portfolioUrl,
|
||||
@@ -56,6 +57,7 @@ export default function EditorialWorkflow({
|
||||
resourceAccess: boolean;
|
||||
opportunitiesUrl: string | null;
|
||||
offersUrl?: string | null;
|
||||
offerOperationsUrl?: string | null;
|
||||
opportunityPending: number;
|
||||
clustersUrl?: string | null;
|
||||
portfolioUrl?: string | null;
|
||||
@@ -110,6 +112,7 @@ export default function EditorialWorkflow({
|
||||
label: 'Ofertas — revisão privada',
|
||||
href: offersUrl,
|
||||
},
|
||||
{ label: 'Ofertas — acompanhamento', href: offerOperationsUrl },
|
||||
{
|
||||
label: 'Biblioteca e editores',
|
||||
href: resourceAccess ? '/management/portal-services' : null,
|
||||
|
||||
@@ -12,12 +12,17 @@ export default function OfferPreparations({
|
||||
title: string | null;
|
||||
reference: string;
|
||||
state: string;
|
||||
availability?: string;
|
||||
}[];
|
||||
prev_page_url: string | null;
|
||||
next_page_url: string | null;
|
||||
};
|
||||
canCreate: boolean;
|
||||
filters?: { state?: string };
|
||||
filters?: {
|
||||
state?: string;
|
||||
operational?: boolean;
|
||||
pending_reports?: boolean;
|
||||
};
|
||||
}) {
|
||||
return (
|
||||
<main className="mx-auto w-full max-w-5xl space-y-6 p-4 md:p-8">
|
||||
@@ -25,7 +30,9 @@ export default function OfferPreparations({
|
||||
<header className="flex flex-wrap items-center justify-between gap-4">
|
||||
<div>
|
||||
<h1 className="text-2xl font-semibold">
|
||||
As minhas ofertas
|
||||
{filters.operational || filters.pending_reports
|
||||
? 'Ofertas — acompanhamento'
|
||||
: 'As minhas ofertas'}
|
||||
</h1>
|
||||
<p className="text-muted-foreground mt-2">
|
||||
Prepare e guarde as suas ofertas num espaço privado.
|
||||
@@ -62,6 +69,19 @@ export default function OfferPreparations({
|
||||
</Link>
|
||||
))}
|
||||
</nav>
|
||||
{filters.operational && (
|
||||
<nav
|
||||
className="flex flex-wrap gap-4"
|
||||
aria-label="Acompanhamento de ofertas"
|
||||
>
|
||||
<Link href="/minhas-oportunidades/ofertas?operational=1">
|
||||
Todas no meu âmbito
|
||||
</Link>
|
||||
<Link href="/minhas-oportunidades/ofertas?operational=1&pending_reports=1">
|
||||
Denúncias pendentes
|
||||
</Link>
|
||||
</nav>
|
||||
)}
|
||||
{!records.data.length && (
|
||||
<p>Ainda não existem ofertas neste âmbito.</p>
|
||||
)}
|
||||
@@ -77,6 +97,24 @@ export default function OfferPreparations({
|
||||
<p className="text-muted-foreground mt-1 text-sm">
|
||||
{record.reference} ·{' '}
|
||||
{offerStates[record.state] ?? record.state}
|
||||
{record.availability && (
|
||||
<>
|
||||
{' '}
|
||||
·{' '}
|
||||
{
|
||||
(
|
||||
{
|
||||
available: 'Disponível',
|
||||
withdrawn: 'Retirada',
|
||||
expired: 'Expirada',
|
||||
revalidation:
|
||||
'Aguarda nova validação',
|
||||
unavailable: 'Indisponível',
|
||||
} as Record<string, string>
|
||||
)[record.availability]
|
||||
}
|
||||
</>
|
||||
)}
|
||||
</p>
|
||||
</li>
|
||||
))}
|
||||
|
||||
@@ -15,6 +15,7 @@ import OfferParticularsFields, {
|
||||
} from '@/components/offer-particulars';
|
||||
import OfferPrivateResources from '@/components/offer-private-resources';
|
||||
import OfferConfidentialAccess from '@/components/offer-confidential-access';
|
||||
import OfferOperations from '@/components/offer-operations';
|
||||
|
||||
type Offer = OfferParticulars & {
|
||||
price_mode?: string | null;
|
||||
@@ -196,6 +197,23 @@ export default function OfferPreparation({
|
||||
<div role="status" aria-live="polite">
|
||||
{message}
|
||||
</div>
|
||||
{saved && (
|
||||
<OfferOperations
|
||||
id={saved.id}
|
||||
onChanged={() => {
|
||||
void profileJson(
|
||||
`/minhas-oportunidades/ofertas/${saved.id}`,
|
||||
{},
|
||||
'GET',
|
||||
)
|
||||
.then((result) => {
|
||||
setSaved(result.record);
|
||||
setConfirmed(false);
|
||||
})
|
||||
.catch((error) => setMessage(error.message));
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
{Object.keys(errors).length > 0 && (
|
||||
<div
|
||||
role="alert"
|
||||
|
||||
@@ -12,6 +12,12 @@ export default function OfferPublicDetail({ offer }: { offer: PublicOffer }) {
|
||||
Voltar às ofertas
|
||||
</Link>
|
||||
<PublicOfferCard offer={offer} detail />
|
||||
<Link
|
||||
className="my-4 inline-block underline"
|
||||
href={`/minhas-oportunidades/ofertas/${offer.id}/denunciar`}
|
||||
>
|
||||
Denunciar esta oferta
|
||||
</Link>
|
||||
{territoryId && (
|
||||
<section className="mt-6">
|
||||
<h2 className="mb-3 text-xl font-semibold">
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
import { Head } from '@inertiajs/react';
|
||||
import { useState } from 'react';
|
||||
import { profileJson } from '@/lib/profile-json';
|
||||
import { createOperationKey } from '@/lib/operation-key';
|
||||
export default function OfferReport({ offerId }: { offerId: number }) {
|
||||
const [key] = useState(createOperationKey);
|
||||
const [reason, setReason] = useState('');
|
||||
const [confirm, setConfirm] = useState(false);
|
||||
const [busy, setBusy] = useState(false);
|
||||
const [sent, setSent] = useState(false);
|
||||
const [message, setMessage] = useState('');
|
||||
async function submit() {
|
||||
setBusy(true);
|
||||
try {
|
||||
const result = await profileJson(
|
||||
`/minhas-oportunidades/ofertas/${offerId}/denuncias`,
|
||||
{ client_key: key, reason, confirm },
|
||||
);
|
||||
setSent(true);
|
||||
setMessage(`Denúncia registada. Referência: ${result.id}.`);
|
||||
} catch (error) {
|
||||
setMessage(
|
||||
error instanceof Error
|
||||
? error.message
|
||||
: 'Não foi possível registar a denúncia.',
|
||||
);
|
||||
} finally {
|
||||
setBusy(false);
|
||||
}
|
||||
}
|
||||
return (
|
||||
<main className="mx-auto w-full max-w-2xl space-y-5 p-4">
|
||||
<Head title="Denunciar oferta" />
|
||||
<h1 className="text-2xl font-semibold">Denunciar oferta</h1>
|
||||
<p>
|
||||
Explique os factos que justificam a denúncia. A equipa
|
||||
responsável irá analisá-la em privado.
|
||||
</p>
|
||||
<form
|
||||
onSubmit={(event) => {
|
||||
event.preventDefault();
|
||||
void submit();
|
||||
}}
|
||||
className="space-y-4"
|
||||
>
|
||||
<fieldset disabled={busy || sent} className="space-y-4">
|
||||
<label className="block">
|
||||
Fundamento
|
||||
<textarea
|
||||
className="mt-2 block w-full rounded border p-3"
|
||||
required
|
||||
minLength={20}
|
||||
maxLength={2000}
|
||||
value={reason}
|
||||
onChange={(event) => setReason(event.target.value)}
|
||||
/>
|
||||
</label>
|
||||
<label className="flex gap-2">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={confirm}
|
||||
onChange={(event) =>
|
||||
setConfirm(event.target.checked)
|
||||
}
|
||||
/>
|
||||
Confirmo o envio destes factos para análise da equipa.
|
||||
</label>
|
||||
<button
|
||||
type="submit"
|
||||
className="rounded border px-4 py-2"
|
||||
disabled={!confirm || reason.trim().length < 20}
|
||||
>
|
||||
Registar denúncia
|
||||
</button>
|
||||
</fieldset>
|
||||
</form>
|
||||
<p role="status">{message}</p>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user