@@ -1,3 +1,4 @@
|
||||
import { createOperationKey } from '@/lib/operation-key';
|
||||
import { Link, useForm, usePage } from '@inertiajs/react';
|
||||
import { Frame, card, input, button } from '@/pages/investment/shared';
|
||||
import {
|
||||
@@ -144,7 +145,7 @@ export default function Case({
|
||||
const actor = usePage<{ auth: { user: { id: number } } }>().props.auth.user;
|
||||
const requestForm = useForm({
|
||||
service_version_id: services[0]?.id ?? '',
|
||||
client_key: crypto.randomUUID(),
|
||||
client_key: createOperationKey(),
|
||||
});
|
||||
const stageForm = useForm({
|
||||
version: dossier.version,
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { createOperationKey } from '@/lib/operation-key';
|
||||
import { Link, useForm, usePage } from '@inertiajs/react';
|
||||
import { useEffect, useRef, useState } from 'react';
|
||||
import { Frame, input, button, card } from '@/pages/investment/shared';
|
||||
@@ -50,7 +51,7 @@ export default function Panel({
|
||||
const [failure, setFailure] = useState<string | null>(null);
|
||||
const form = useForm({
|
||||
title: '',
|
||||
client_key: crypto.randomUUID(),
|
||||
client_key: createOperationKey(),
|
||||
reuse_consent: false,
|
||||
company_id: '',
|
||||
submission_id: params.get('submission_id') ?? '',
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { createOperationKey } from '@/lib/operation-key';
|
||||
import { Link, useForm } from '@inertiajs/react';
|
||||
import { Frame, card, input, button } from '@/pages/investment/shared';
|
||||
import CountrySelect, { type Country } from '@/components/country-select';
|
||||
@@ -114,7 +115,7 @@ export default function RequestPage({
|
||||
reason: '',
|
||||
due_at: '',
|
||||
});
|
||||
const message = useForm({ body: '', client_key: crypto.randomUUID() });
|
||||
const message = useForm({ body: '', client_key: createOperationKey() });
|
||||
const canEdit = owner && fieldsEditable;
|
||||
return (
|
||||
<Frame title={definition.title}>
|
||||
@@ -150,26 +151,59 @@ export default function RequestPage({
|
||||
)}
|
||||
</section>
|
||||
{canEdit && toolPrefill && (
|
||||
<section className={card + ' space-y-3'} aria-label="Descrição guardada no projeto">
|
||||
<h2 className="text-xl font-bold">Reutilizar dados do projeto</h2>
|
||||
<p>A descrição está vazia neste pedido. Pode reutilizar o resumo já guardado na ferramenta deste dossier, versão {toolPrefill.draft_version}.</p>
|
||||
<blockquote className="rounded border p-3 whitespace-pre-wrap">{toolPrefill.description}</blockquote>
|
||||
<p>Esta ação guarda o rascunho com os dados preenchidos nesta página. Reveja-os antes de submeter.</p>
|
||||
<section
|
||||
className={card + ' space-y-3'}
|
||||
aria-label="Descrição guardada no projeto"
|
||||
>
|
||||
<h2 className="text-xl font-bold">
|
||||
Reutilizar dados do projeto
|
||||
</h2>
|
||||
<p>
|
||||
A descrição está vazia neste pedido. Pode reutilizar o
|
||||
resumo já guardado na ferramenta deste dossier, versão{' '}
|
||||
{toolPrefill.draft_version}.
|
||||
</p>
|
||||
<blockquote className="rounded border p-3 whitespace-pre-wrap">
|
||||
{toolPrefill.description}
|
||||
</blockquote>
|
||||
<p>
|
||||
Esta ação guarda o rascunho com os dados preenchidos
|
||||
nesta página. Reveja-os antes de submeter.
|
||||
</p>
|
||||
<button
|
||||
type="button"
|
||||
className={button}
|
||||
disabled={form.processing || !!form.data.payload.description?.trim()}
|
||||
disabled={
|
||||
form.processing ||
|
||||
!!form.data.payload.description?.trim()
|
||||
}
|
||||
onClick={() => {
|
||||
form.transform((data) => ({
|
||||
...data,
|
||||
version: request.version,
|
||||
submit: false,
|
||||
payload: {...data.payload, description: toolPrefill.description},
|
||||
tool_prefill: {draft_id:toolPrefill.draft_id, draft_version:toolPrefill.draft_version, snapshot_sha256:toolPrefill.snapshot_sha256},
|
||||
payload: {
|
||||
...data.payload,
|
||||
description: toolPrefill.description,
|
||||
},
|
||||
tool_prefill: {
|
||||
draft_id: toolPrefill.draft_id,
|
||||
draft_version: toolPrefill.draft_version,
|
||||
snapshot_sha256:
|
||||
toolPrefill.snapshot_sha256,
|
||||
},
|
||||
}));
|
||||
form.put(`/balcao-virtual/pedidos/${request.id}`, {onSuccess: () => form.setData('payload', {...form.data.payload, description:toolPrefill.description})});
|
||||
form.put(`/balcao-virtual/pedidos/${request.id}`, {
|
||||
onSuccess: () =>
|
||||
form.setData('payload', {
|
||||
...form.data.payload,
|
||||
description: toolPrefill.description,
|
||||
}),
|
||||
});
|
||||
}}
|
||||
>Reutilizar descrição guardada e guardar rascunho</button>
|
||||
>
|
||||
Reutilizar descrição guardada e guardar rascunho
|
||||
</button>
|
||||
</section>
|
||||
)}
|
||||
<section className={card + ' space-y-3'}>
|
||||
@@ -207,6 +241,8 @@ export default function RequestPage({
|
||||
</label>
|
||||
<CountrySelect
|
||||
id="request-country"
|
||||
label="País do requerente (opcional)"
|
||||
error={form.errors['payload.country']}
|
||||
countries={countries}
|
||||
value={form.data.payload.country ?? ''}
|
||||
allowLegacyValue
|
||||
@@ -222,14 +258,13 @@ export default function RequestPage({
|
||||
!request.editable_fields.includes('country'))
|
||||
}
|
||||
/>
|
||||
{form.errors['payload.country'] && (
|
||||
<p role="alert">{form.errors['payload.country']}</p>
|
||||
)}
|
||||
<label className="block" htmlFor="declared-origin-country">
|
||||
País de origem declarado desta solicitação
|
||||
</label>
|
||||
<CountrySelect
|
||||
id="declared-origin-country"
|
||||
label="País de origem declarado desta solicitação"
|
||||
error={form.errors['payload.declared_origin_country_code']}
|
||||
countries={countries}
|
||||
value={form.data.payload.declared_origin_country_code ?? ''}
|
||||
disabled={
|
||||
@@ -251,11 +286,6 @@ export default function RequestPage({
|
||||
A origem não é deduzida do IP nem do país de residência.
|
||||
Pedidos antigos sem declaração mantêm “não informado”.
|
||||
</p>
|
||||
{form.errors['payload.declared_origin_country_code'] && (
|
||||
<p role="alert">
|
||||
{form.errors['payload.declared_origin_country_code']}
|
||||
</p>
|
||||
)}
|
||||
{Object.entries(definition.fields)
|
||||
.filter(
|
||||
([, f]) =>
|
||||
@@ -634,7 +664,7 @@ export default function RequestPage({
|
||||
message.reset('body');
|
||||
message.setData(
|
||||
'client_key',
|
||||
crypto.randomUUID(),
|
||||
createOperationKey(),
|
||||
);
|
||||
},
|
||||
},
|
||||
@@ -645,6 +675,7 @@ export default function RequestPage({
|
||||
Mensagem privada
|
||||
<textarea
|
||||
className={input}
|
||||
disabled={message.processing}
|
||||
value={message.data.body}
|
||||
required
|
||||
onChange={(e) =>
|
||||
|
||||
Reference in New Issue
Block a user