@@ -0,0 +1,88 @@
|
||||
import { controlClass } from '@/components/procurement';
|
||||
|
||||
export const requisitionCategoryLabels: Record<string, string> = {
|
||||
production_input: 'Insumos de produção',
|
||||
spare_part: 'Peças sobressalentes',
|
||||
capital_equipment: 'Maquinaria',
|
||||
office_equipment: 'Equipamento de escritório',
|
||||
other: 'Outra categoria',
|
||||
};
|
||||
|
||||
const guidance: Record<string, string> = {
|
||||
production_input:
|
||||
'Seleccione um material de stock no catálogo publicado. A categoria original do artigo é conservada.',
|
||||
spare_part:
|
||||
'Seleccione o tipo Peça e associe a peça ao equipamento. Os controlos de stock e criticidade existentes mantêm-se.',
|
||||
capital_equipment:
|
||||
'Seleccione o tipo Equipamento e justifique o investimento. Mantêm-se a validação técnica, Finanças e o orçamento de investimento.',
|
||||
office_equipment:
|
||||
'Prefira um artigo do catálogo; se usar texto livre, explique a necessidade.',
|
||||
other: 'Identifique a categoria do artigo e justifique o uso de texto livre quando não existir selecção do catálogo.',
|
||||
};
|
||||
|
||||
export function RequisitionCategoryFields({
|
||||
index,
|
||||
category,
|
||||
reason,
|
||||
options,
|
||||
onChange,
|
||||
}: {
|
||||
index: number;
|
||||
category: string;
|
||||
reason: string;
|
||||
options: Record<string, string>;
|
||||
onChange: (
|
||||
field: 'procurement_category' | 'category_reason',
|
||||
value: string,
|
||||
) => void;
|
||||
}) {
|
||||
const prefix = `rq-category-${index}`;
|
||||
return (
|
||||
<div className="grid gap-3 rounded-lg border p-4 sm:col-span-3">
|
||||
<label className="grid gap-2 text-sm" htmlFor={prefix}>
|
||||
Categoria da necessidade
|
||||
<select
|
||||
id={prefix}
|
||||
className={controlClass}
|
||||
value={category}
|
||||
aria-describedby={`${prefix}-help`}
|
||||
onChange={(event) =>
|
||||
onChange('procurement_category', event.target.value)
|
||||
}
|
||||
>
|
||||
<option value="">Sem classificação adicional</option>
|
||||
{Object.entries(options).map(([value, label]) => (
|
||||
<option key={value} value={value}>
|
||||
{label}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
<p id={`${prefix}-help`} className="text-sm text-muted-foreground">
|
||||
{(!category && reason
|
||||
? 'Seleccione a categoria para este motivo ou limpe-o se não quiser classificação adicional.'
|
||||
: guidance[category]) ??
|
||||
'Conserva a categoria original do artigo. Uma classificação anterior não é inferida nem alterada automaticamente.'}
|
||||
</p>
|
||||
{(category || reason) && (
|
||||
<label
|
||||
className="grid gap-2 text-sm"
|
||||
htmlFor={`${prefix}-reason`}
|
||||
>
|
||||
{category === 'capital_equipment'
|
||||
? 'Justificação do investimento'
|
||||
: 'Justificação da categoria ou do texto livre'}
|
||||
<textarea
|
||||
id={`${prefix}-reason`}
|
||||
className={controlClass}
|
||||
maxLength={2000}
|
||||
value={reason}
|
||||
onChange={(event) =>
|
||||
onChange('category_reason', event.target.value)
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user