@@ -15,6 +15,8 @@ export default function OpportunityProfileActions({
|
||||
publishers = [],
|
||||
opinions = [],
|
||||
publicationVisibility,
|
||||
conditions = [],
|
||||
conditionResponsibles = [],
|
||||
}: {
|
||||
id: number;
|
||||
etag: string;
|
||||
@@ -23,6 +25,16 @@ export default function OpportunityProfileActions({
|
||||
documents: { id: string; title: string }[];
|
||||
approvalHash?: string;
|
||||
publicationVisibility?: string;
|
||||
conditions?: {
|
||||
id: string;
|
||||
gate: string;
|
||||
description: string;
|
||||
responsible_name: string;
|
||||
due_on: string | null;
|
||||
blocking_action: string;
|
||||
status: string;
|
||||
}[];
|
||||
conditionResponsibles?: { id: number; name: string }[];
|
||||
onErrors?: (errors: Record<string, string>) => void;
|
||||
publishers?: { id: number; name: string }[];
|
||||
participants?: {
|
||||
@@ -49,6 +61,11 @@ export default function OpportunityProfileActions({
|
||||
const [confirmed, setConfirmed] = useState(false);
|
||||
const [recipient, setRecipient] = useState('');
|
||||
const [opinion, setOpinion] = useState('');
|
||||
const [conditionDescription, setConditionDescription] = useState('');
|
||||
const [conditionResponsible, setConditionResponsible] = useState('');
|
||||
const [conditionDue, setConditionDue] = useState('');
|
||||
const [conditionBlocking, setConditionBlocking] = useState('approve');
|
||||
const [resolvedConditions, setResolvedConditions] = useState<string[]>([]);
|
||||
const [actionErrors, setActionErrors] = useState<Record<string, string>>(
|
||||
{},
|
||||
);
|
||||
@@ -97,6 +114,23 @@ export default function OpportunityProfileActions({
|
||||
evidence_document_ids: evidence,
|
||||
}
|
||||
: {}),
|
||||
...(action === 'review_gate'
|
||||
? {
|
||||
resolve_condition_ids: resolvedConditions,
|
||||
...(conditionDescription.trim()
|
||||
? {
|
||||
condition: {
|
||||
description:
|
||||
conditionDescription.trim(),
|
||||
responsible_user_id:
|
||||
Number(conditionResponsible),
|
||||
due_on: conditionDue || null,
|
||||
blocking_action: conditionBlocking,
|
||||
},
|
||||
}
|
||||
: {}),
|
||||
}
|
||||
: {}),
|
||||
...(action === 'pending_opinion'
|
||||
? { gate, recipient_user_id: Number(recipient) }
|
||||
: {}),
|
||||
@@ -120,6 +154,14 @@ export default function OpportunityProfileActions({
|
||||
if (error instanceof ProfileValidationError) {
|
||||
setActionErrors(error.fields);
|
||||
onErrors?.(error.fields);
|
||||
const first = Object.keys(error.fields)[0];
|
||||
requestAnimationFrame(() =>
|
||||
document
|
||||
.getElementById(
|
||||
`workflow-${id}-${first?.startsWith('conditions.') ? 'conditions' : first}`,
|
||||
)
|
||||
?.focus(),
|
||||
);
|
||||
}
|
||||
setMessage(
|
||||
error instanceof Error
|
||||
@@ -148,17 +190,56 @@ export default function OpportunityProfileActions({
|
||||
público e ação independente do Publicador; não representa uma
|
||||
decisão externa.
|
||||
</p>
|
||||
{conditions.length > 0 && (
|
||||
<section
|
||||
aria-label="Condições de revisão"
|
||||
id={`workflow-${id}-conditions`}
|
||||
tabIndex={-1}
|
||||
>
|
||||
<h3>Condições e evidências</h3>
|
||||
{conditions.map((c) => (
|
||||
<p key={c.id}>
|
||||
{c.description} —{' '}
|
||||
{c.status === 'resolved'
|
||||
? 'Verificada internamente'
|
||||
: 'Pendente'}
|
||||
; responsável: {c.responsible_name}; prazo:{' '}
|
||||
{c.due_on ?? 'não definido'}; impede:{' '}
|
||||
{c.blocking_action === 'approve'
|
||||
? 'aprovação'
|
||||
: 'publicação'}
|
||||
. A verificação interna não constitui decisão
|
||||
externa.
|
||||
</p>
|
||||
))}
|
||||
</section>
|
||||
)}
|
||||
{!!actions.length && (
|
||||
<>
|
||||
<label className="block">
|
||||
Fundamentação
|
||||
<textarea
|
||||
id={`workflow-${id}-reason`}
|
||||
aria-invalid={!!actionErrors.reason}
|
||||
aria-describedby={
|
||||
actionErrors.reason
|
||||
? `workflow-${id}-reason-error`
|
||||
: undefined
|
||||
}
|
||||
className={control}
|
||||
minLength={20}
|
||||
maxLength={1000}
|
||||
value={reason}
|
||||
onChange={(e) => setReason(e.target.value)}
|
||||
/>
|
||||
{actionErrors.reason && (
|
||||
<span
|
||||
id={`workflow-${id}-reason-error`}
|
||||
role="alert"
|
||||
>
|
||||
{actionErrors.reason}
|
||||
</span>
|
||||
)}
|
||||
</label>
|
||||
{actions.includes('request_correction') && (
|
||||
<label className="block">
|
||||
@@ -178,6 +259,7 @@ export default function OpportunityProfileActions({
|
||||
<label>
|
||||
Revisão
|
||||
<select
|
||||
id={`workflow-${id}-gate`}
|
||||
className={control}
|
||||
value={gate}
|
||||
onChange={(e) => setGate(e.target.value)}
|
||||
@@ -222,6 +304,145 @@ export default function OpportunityProfileActions({
|
||||
))}
|
||||
</fieldset>
|
||||
)}
|
||||
{actions.includes('review_gate') && (
|
||||
<fieldset className="space-y-2">
|
||||
<legend>Condição explícita desta revisão</legend>
|
||||
<p>
|
||||
Opcional. Só bloqueia a ação indicada. Sem prazo
|
||||
automático ou responsabilidade externa
|
||||
atribuída.
|
||||
</p>
|
||||
<label className="block">
|
||||
Descrição da condição
|
||||
<textarea
|
||||
className={control}
|
||||
id={`workflow-${id}-condition.description`}
|
||||
value={conditionDescription}
|
||||
onChange={(e) =>
|
||||
setConditionDescription(e.target.value)
|
||||
}
|
||||
aria-invalid={
|
||||
!!actionErrors['condition.description']
|
||||
}
|
||||
aria-describedby={
|
||||
actionErrors['condition.description']
|
||||
? `workflow-${id}-condition.description-error`
|
||||
: undefined
|
||||
}
|
||||
/>
|
||||
{actionErrors['condition.description'] && (
|
||||
<span
|
||||
id={`workflow-${id}-condition.description-error`}
|
||||
role="alert"
|
||||
>
|
||||
{actionErrors['condition.description']}
|
||||
</span>
|
||||
)}
|
||||
</label>
|
||||
<label className="block">
|
||||
Responsável pela preparação da evidência
|
||||
<select
|
||||
className={control}
|
||||
id={`workflow-${id}-condition.responsible_user_id`}
|
||||
value={conditionResponsible}
|
||||
onChange={(e) =>
|
||||
setConditionResponsible(e.target.value)
|
||||
}
|
||||
aria-invalid={
|
||||
!!actionErrors[
|
||||
'condition.responsible_user_id'
|
||||
]
|
||||
}
|
||||
aria-describedby={
|
||||
actionErrors[
|
||||
'condition.responsible_user_id'
|
||||
]
|
||||
? `workflow-${id}-condition.responsible_user_id-error`
|
||||
: undefined
|
||||
}
|
||||
>
|
||||
<option value="">Selecione</option>
|
||||
{conditionResponsibles.map((p) => (
|
||||
<option key={p.id} value={p.id}>
|
||||
{p.name}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
{actionErrors[
|
||||
'condition.responsible_user_id'
|
||||
] && (
|
||||
<span
|
||||
id={`workflow-${id}-condition.responsible_user_id-error`}
|
||||
role="alert"
|
||||
>
|
||||
{
|
||||
actionErrors[
|
||||
'condition.responsible_user_id'
|
||||
]
|
||||
}
|
||||
</span>
|
||||
)}
|
||||
</label>
|
||||
<label className="block">
|
||||
Prazo específico da condição, se definido
|
||||
<input
|
||||
className={control}
|
||||
type="date"
|
||||
id={`workflow-${id}-condition.due_on`}
|
||||
value={conditionDue}
|
||||
onChange={(e) =>
|
||||
setConditionDue(e.target.value)
|
||||
}
|
||||
aria-invalid={
|
||||
!!actionErrors['condition.due_on']
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
<label className="block">
|
||||
Ação impedida até verificação
|
||||
<select
|
||||
className={control}
|
||||
value={conditionBlocking}
|
||||
onChange={(e) =>
|
||||
setConditionBlocking(e.target.value)
|
||||
}
|
||||
>
|
||||
<option value="approve">Aprovação</option>
|
||||
<option value="publish">Publicação</option>
|
||||
</select>
|
||||
</label>
|
||||
{conditions
|
||||
.filter(
|
||||
(c) =>
|
||||
c.gate === gate && c.status === 'open',
|
||||
)
|
||||
.map((c) => (
|
||||
<label key={c.id} className="block">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={resolvedConditions.includes(
|
||||
c.id,
|
||||
)}
|
||||
onChange={(e) =>
|
||||
setResolvedConditions(
|
||||
e.target.checked
|
||||
? [
|
||||
...resolvedConditions,
|
||||
c.id,
|
||||
]
|
||||
: resolvedConditions.filter(
|
||||
(id) =>
|
||||
id !== c.id,
|
||||
),
|
||||
)
|
||||
}
|
||||
/>
|
||||
Verifiquei com os documentos
|
||||
selecionados: {c.description}
|
||||
</label>
|
||||
))}
|
||||
</fieldset>
|
||||
)}
|
||||
{(actions.includes('assign_review') ||
|
||||
actions.includes('assign_publication')) && (
|
||||
<label className="block">
|
||||
@@ -297,7 +518,10 @@ export default function OpportunityProfileActions({
|
||||
.filter(([key]) => !key.startsWith('canonical'))
|
||||
.map(([key, msg]) => (
|
||||
<p key={key} role="alert">
|
||||
{key}: {msg}
|
||||
{key.startsWith('conditions.')
|
||||
? 'Condição de revisão'
|
||||
: key}
|
||||
: {msg}
|
||||
</p>
|
||||
))}
|
||||
{actions.includes('publish') && (
|
||||
|
||||
Reference in New Issue
Block a user