feat(offers): add gated phase three public catalogue in QA

This commit is contained in:
2026-11-14 16:49:58 +02:00
parent 91c1857368
commit 7691cab3bc
18 changed files with 1153 additions and 6 deletions
@@ -76,6 +76,7 @@ export default function OpportunitySearchFilters({
submit,
clear,
errors,
mode = 'opportunities',
}: {
data: Values;
references: References;
@@ -85,6 +86,7 @@ export default function OpportunitySearchFilters({
submit: () => void;
clear: () => void;
errors: Record<string, string>;
mode?: 'opportunities' | 'offers';
}) {
const [expanded, setExpanded] = useState(false);
useEffect(() => {
@@ -222,6 +224,134 @@ export default function OpportunitySearchFilters({
(!Array.isArray(v) || v.length > 0) &&
!(k === 'territory_basis' && v === 'all'),
);
if (mode === 'offers')
return (
<form
className="grid min-w-0 gap-4 rounded-xl border bg-white p-4 sm:grid-cols-2 lg:grid-cols-3"
aria-label="Pesquisar ofertas"
onSubmit={(event) => {
event.preventDefault();
submit();
}}
>
<Field label="O que procura">
<input
className={input}
value={String(data.q ?? '')}
maxLength={120}
onChange={(event) => change({ q: event.target.value })}
/>
</Field>
{select('category', choicesFor('category'))}
{[0, 1].map((index) => (
<TerritoryLevel
key={`${index}-${path[index - 1]?.id ?? ''}`}
index={index}
parent={path[index - 1]?.id ?? ''}
selected={path[index]}
endpoint="/api/v1/investment/territory-options"
onChange={(value) =>
territory([
...path.slice(0, index),
...(value ? [value] : []),
])
}
/>
))}
<Field label="Preço">
<select
className={input}
value={String(data.price_mode ?? '')}
onChange={(event) =>
change({
price_mode: event.target.value,
...(event.target.value === 'negotiable'
? {
currency: '',
min_amount: '',
max_amount: '',
sort: 'recent',
}
: {}),
})
}
>
<option value="">Todos os preços</option>
<option value="amount">Com montante indicado</option>
<option value="negotiable">A negociar</option>
</select>
</Field>
<Field label="Moeda">
<select
className={input}
disabled={data.price_mode === 'negotiable'}
value={String(data.currency ?? '')}
onChange={(event) =>
change({ currency: event.target.value })
}
>
<option value="">Todas as moedas</option>
<option value="MZN">MZN</option>
<option value="USD">USD</option>
</select>
</Field>
{[
['min_amount', 'Preço mínimo'],
['max_amount', 'Preço máximo'],
].map(([key, label]) => (
<Field key={key} label={label}>
<input
className={input}
inputMode="decimal"
disabled={data.price_mode === 'negotiable'}
value={String(data[key] ?? '')}
maxLength={19}
placeholder="Ex.: 250000.00"
onChange={(event) =>
change({ [key]: event.target.value })
}
/>
</Field>
))}
<Field label="Ordenar por">
<select
className={input}
value={String(data.sort ?? 'recent')}
onChange={(event) =>
change({ sort: event.target.value })
}
>
<option value="recent">Mais recentes</option>
<option value="title">Título</option>
<option value="amount_asc">
Preço crescente, na moeda seleccionada
</option>
<option value="amount_desc">
Preço decrescente, na moeda seleccionada
</option>
</select>
</Field>
{Object.keys(errors).length > 0 && (
<ul role="alert" className="sm:col-span-2 lg:col-span-3">
{Object.entries(errors).map(([key, value]) => (
<li key={key}>{value}</li>
))}
</ul>
)}
<div className="flex flex-wrap gap-3 sm:col-span-2 lg:col-span-3">
<button type="submit" className={button}>
Pesquisar
</button>
<button
type="button"
className="rounded-lg border px-4 py-2"
onClick={clear}
>
Limpar filtros
</button>
</div>
</form>
);
return (
<form
className="catalogue-filters"
@@ -0,0 +1,43 @@
import { Link } from '@inertiajs/react';
import { modalityLabels } from '@/components/opportunity-search-filters';
import { offerPrice, type PublicOffer } from '@/lib/public-offer';
import { card } from '@/pages/investment/shared';
export default function PublicOfferCard({
offer,
detail = false,
}: {
offer: PublicOffer;
detail?: boolean;
}) {
const Heading = detail ? 'h1' : 'h2';
return (
<article className={`${card} min-w-0 space-y-3 break-words`}>
<p className="text-sm text-slate-600">
{modalityLabels[offer.category]} ·{' '}
{offer.location.map((node) => node.name).join(' / ') ||
'Localização não indicada'}
</p>
<Heading className="text-xl font-semibold">
{detail ? (
offer.title
) : (
<Link
className="underline decoration-emerald-700 underline-offset-4"
href={offer.url}
>
{offer.title}
</Link>
)}
</Heading>
<p className="whitespace-pre-line">{offer.summary}</p>
<p className="font-semibold text-emerald-900">
{offerPrice(offer.price)}
</p>
<p className="text-sm text-slate-600">
Publicada em{' '}
{new Date(offer.published_at).toLocaleDateString('pt-MZ')}
</p>
</article>
);
}