import { createOperationKey } from '@/lib/operation-key'; import { Head, Link, router } from '@inertiajs/react'; import { useState } from 'react'; import ProfileNavigation from '@/components/profile-navigation'; import { profileJson } from '@/lib/profile-json'; import { button, control } from '@/pages/management/shared'; type RequestEntry = { id: string; status: string; reason: string; decision_reason: string | null; created_at: string; }; export default function RequestProfile({ requests, types, organizations, documents, }: { requests: RequestEntry[]; types: string[]; organizations: { id: string; name: string }[]; documents: { id: string; file_name: string }[]; }) { const [representation, setRepresentation] = useState('individual'); const [organization, setOrganization] = useState(''); const [selected, setSelected] = useState([]); const [proofs, setProofs] = useState([]); const [reason, setReason] = useState(''); const [key, setKey] = useState(() => createOperationKey()); const [message, setMessage] = useState(''); const [busy, setBusy] = useState(false); async function send() { setBusy(true); setMessage(''); try { const result = await profileJson('/perfil/promotor', { creation_key: key, representation_type: representation, organization_id: representation === 'individual' ? null : organization, opportunity_types: selected, document_ids: proofs, reason, }); setMessage(result.message); setKey(createOperationKey()); router.reload(); } catch (error) { setMessage( error instanceof Error ? error.message : 'Resposta indisponível. Confira o acompanhamento antes de repetir.', ); } finally { setBusy(false); } } const toggle = (values: string[], id: string) => values.includes(id) ? values.filter((v) => v !== id) : [...values, id]; return (

Solicitar perfil de Promotor

A aprovação confirma identidade, representação e comprovativos. Só os tipos aprovados ficam disponíveis; o pedido não ativa o perfil.

{ e.preventDefault(); void send(); }} > {representation !== 'individual' && ( )}
Tipos pretendidos {types.map((type) => ( ))}
Comprovativos próprios analisados {documents.map((d) => ( ))}
{!documents.length && (

Sem comprovativos próprios disponíveis. Pode anexar ao seu dossier no{' '} Balcão ; o ficheiro precisa de análise antimalware concluída.

)}