Entrega dashboard e correccoes transversais preservando Ofertas instalado
tests / ci (push) Canceled after 0s
tests / ci (push) Canceled after 0s
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
import CurrencySelect from '@/components/currency-select';
|
||||
import { useRef, useState } from 'react';
|
||||
import { Link, router } from '@inertiajs/react';
|
||||
import { Frame, card, input, button } from './shared';
|
||||
import { profileJson, ProfileValidationError } from '@/lib/profile-json';
|
||||
import { createOperationKey } from '@/lib/operation-key';
|
||||
import {
|
||||
companyPreparationNotice,
|
||||
preparationValues,
|
||||
type CompanyFacts,
|
||||
type Party,
|
||||
@@ -34,12 +36,17 @@ type Props = {
|
||||
>;
|
||||
history: { id: string; revision: number; at: string }[];
|
||||
historyNext: number | null;
|
||||
entity?: {
|
||||
kind: string;
|
||||
snapshot?: { name?: string; legal_form?: string };
|
||||
} | null;
|
||||
proposedForm?: string | null;
|
||||
};
|
||||
|
||||
export default function CompanyPreparation(props: Props) {
|
||||
return (
|
||||
<Preparation
|
||||
key={`${props.case.id}:${props.saved?.revision}:${props.historical}`}
|
||||
key={`${props.case.id}:${props.saved?.revision}:${props.historical}:${props.proposedForm ?? ''}`}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
@@ -86,19 +93,19 @@ function Preparation(props: Props) {
|
||||
onChange={(e) => update(key, e.target.value)}
|
||||
maxLength={2000}
|
||||
/>
|
||||
) : key === 'currency' ? (
|
||||
<CurrencySelect
|
||||
label="Moeda"
|
||||
value={facts[key] ?? ''}
|
||||
onChange={(value) => update(key, value)}
|
||||
/>
|
||||
) : (
|
||||
<input
|
||||
className={input}
|
||||
name={key}
|
||||
value={facts[key] ?? ''}
|
||||
onChange={(e) => update(key, e.target.value)}
|
||||
maxLength={
|
||||
key === 'proposed_name'
|
||||
? 250
|
||||
: key === 'currency'
|
||||
? 3
|
||||
: 25
|
||||
}
|
||||
maxLength={key === 'proposed_name' ? 250 : 25}
|
||||
/>
|
||||
)}
|
||||
</label>
|
||||
@@ -138,7 +145,7 @@ function Preparation(props: Props) {
|
||||
</label>
|
||||
);
|
||||
}
|
||||
async function save() {
|
||||
async function save(next?: string) {
|
||||
if (busy || readOnly) return;
|
||||
setBusy(true);
|
||||
setError('');
|
||||
@@ -151,7 +158,7 @@ function Preparation(props: Props) {
|
||||
operation_key: operation.current,
|
||||
facts: values,
|
||||
});
|
||||
router.visit(base, { preserveState: false });
|
||||
router.visit(next ?? base, { preserveState: false });
|
||||
} catch (e) {
|
||||
setError(
|
||||
e instanceof Error
|
||||
@@ -178,7 +185,41 @@ function Preparation(props: Props) {
|
||||
}
|
||||
}
|
||||
return (
|
||||
<Frame title="Preparar a constituição da empresa">
|
||||
<Frame
|
||||
title={
|
||||
['company', 'organization'].includes(props.entity?.kind ?? '')
|
||||
? 'Preparação da empresa existente'
|
||||
: 'Preparar a constituição da empresa'
|
||||
}
|
||||
>
|
||||
{props.entity?.snapshot?.name && (
|
||||
<p>
|
||||
Entidade associada: {props.entity.snapshot.name}. Os dados
|
||||
recuperados não alteram o cadastro nem comprovam um acto
|
||||
legal.
|
||||
</p>
|
||||
)}
|
||||
{props.proposedForm &&
|
||||
facts.form !== props.proposedForm &&
|
||||
!readOnly && (
|
||||
<aside className={card}>
|
||||
<p>
|
||||
A alternativa escolhida não substituiu a forma já
|
||||
preparada.
|
||||
</p>
|
||||
<button
|
||||
type="button"
|
||||
className="underline"
|
||||
onClick={() => {
|
||||
update('form', props.proposedForm!);
|
||||
setDirty(true);
|
||||
operation.current = createOperationKey();
|
||||
}}
|
||||
>
|
||||
Usar a alternativa escolhida nesta preparação
|
||||
</button>
|
||||
</aside>
|
||||
)}
|
||||
<p>
|
||||
<Link
|
||||
className="underline"
|
||||
@@ -194,7 +235,7 @@ function Preparation(props: Props) {
|
||||
Comparar formas jurídicas
|
||||
</Link>
|
||||
</p>
|
||||
<p>{props.definition.template_notice}</p>
|
||||
<p>{companyPreparationNotice(props.definition.template_notice)}</p>
|
||||
<p>
|
||||
Guarde mesmo que faltem dados. Só se pedem informações desta
|
||||
preparação; valores indicados como realizados são declarações,
|
||||
@@ -619,6 +660,18 @@ function Preparation(props: Props) {
|
||||
<button type="submit" className={button}>
|
||||
Guardar ficha no dossier
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className={button}
|
||||
disabled={busy}
|
||||
onClick={() =>
|
||||
void save(
|
||||
`/simulador-fiscal?context=${props.case.id}`,
|
||||
)
|
||||
}
|
||||
>
|
||||
Guardar e continuar para a viabilidade
|
||||
</button>
|
||||
</section>
|
||||
</fieldset>
|
||||
</form>
|
||||
|
||||
Reference in New Issue
Block a user