Criar Hotel: a escolha do dossier mostra a actividade de cada um
Vindo da página de um sector, os dossiers do mesmo sector aparecem primeiro, cada um com a sua actividade, e escolher um dossier de outra actividade avisa que o novo sector fica só como proposta. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MzJmxFy3izprXr5dSq91jM
This commit is contained in:
@@ -22,7 +22,13 @@ export default function ContextStart({
|
||||
entryComplements = [],
|
||||
entrySubmission = null,
|
||||
}: {
|
||||
contexts: { id: string; title: string; version: number }[];
|
||||
contexts: {
|
||||
id: string;
|
||||
title: string;
|
||||
version: number;
|
||||
sector_id?: string | null;
|
||||
sector?: string | null;
|
||||
}[];
|
||||
source: ContextReference | null;
|
||||
opportunityChoices?: OpportunityChoice[];
|
||||
step?: string | null;
|
||||
@@ -31,6 +37,23 @@ export default function ContextStart({
|
||||
entrySubmission?: { id: string; version: number } | null;
|
||||
}) {
|
||||
const [chosen, setChosen] = useState('');
|
||||
// The investor's first choice leads: dossiers of the same sector come
|
||||
// first, and a different sector is only ever proposed, never swapped in.
|
||||
const sourceSector =
|
||||
source?.kind === 'sector' ? (source.fields.sector_id ?? null) : null;
|
||||
const ordered = sourceSector
|
||||
? [
|
||||
...contexts.filter((c) => c.sector_id === sourceSector),
|
||||
...contexts.filter((c) => c.sector_id !== sourceSector),
|
||||
]
|
||||
: contexts;
|
||||
const chosenContext = contexts.find((c) => c.id === chosen);
|
||||
const otherActivity =
|
||||
sourceSector &&
|
||||
chosenContext?.sector_id &&
|
||||
chosenContext.sector_id !== sourceSector
|
||||
? chosenContext
|
||||
: null;
|
||||
const [title, setTitle] = useState(
|
||||
entryComplements[0]?.kind === 'need'
|
||||
? `Preparação de ${entryComplements[0].title} — ${entryComplements[0].origin.title}`.slice(
|
||||
@@ -174,13 +197,26 @@ export default function ContextStart({
|
||||
onChange={(e) => setChosen(e.target.value)}
|
||||
>
|
||||
<option value="">Selecionar dossier autorizado</option>
|
||||
{contexts.map((c) => (
|
||||
{ordered.map((c) => (
|
||||
<option key={c.id} value={c.id}>
|
||||
{c.title}
|
||||
{c.sector ? ` — ${c.sector}` : ''}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
{otherActivity && (
|
||||
<p
|
||||
role="note"
|
||||
className="rounded border border-amber-300 bg-amber-50 p-3"
|
||||
>
|
||||
O dossier «{otherActivity.title}» é de{' '}
|
||||
{otherActivity.sector}. Se continuar nele, {source?.title}{' '}
|
||||
fica apenas como proposta e a actividade do dossier
|
||||
mantém-se. Para preparar uma ideia em {source?.title},
|
||||
crie uma nova ideia abaixo.
|
||||
</p>
|
||||
)}
|
||||
{chosen && entrySubmission && (
|
||||
<button
|
||||
className={button}
|
||||
|
||||
Reference in New Issue
Block a user