import { router } from '@inertiajs/react'; import { useState } from 'react'; import CatalogueChoiceSelect from '@/components/catalogue-choice-select'; import DemographicEvidence, { type DemographicAnalysis, } from '@/components/demographic-evidence'; import { Frame, button } from './shared'; export default function Demography( props: Parameters[0], ) { // Server filters identify this consultation, including browser back/forward. return ( ); } function DemographySelection({ evidence, filters, territories, sectors, }: { evidence: DemographicAnalysis; filters: { territories?: string[]; start_year?: number; end_year?: number; sector?: string; }; territories: { id: string; name: string; location_type: string; parent_id: string | null; }[]; sectors: Record; }) { const [selected, setSelected] = useState(filters.territories ?? []); const [province, setProvince] = useState(''); const [district, setDistrict] = useState(''); const [selectionNotice, setSelectionNotice] = useState(''); const candidate = district || province; const [start, setStart] = useState( filters.start_year ?? new Date().getFullYear(), ); const [end, setEnd] = useState(filters.end_year ?? start); const [sector, setSector] = useState(filters.sector ?? 'general'); return (

Compare até quatro localizações no mesmo sector e período. Use esta evidência em conjunto com as condições económicas, fiscais e territoriais do investimento.

{ e.preventDefault(); router.get( '/localizacoes/demografia', { territories: selected, start_year: start, end_year: end, sector, }, { preserveState: true }, ); }} >
Localizações a comparar (até quatro) t.location_type === 'province') .map((t) => ({ value: t.id, label: t.name }))} onChange={(value) => { setProvince(value); if (district) setSelectionNotice( 'A escolha do distrito foi limpa. Os locais já acrescentados à comparação foram mantidos.', ); setDistrict(''); }} /> t.location_type === 'district' && t.parent_id === province, ) .map((t) => ({ value: t.id, label: t.name }))} onChange={setDistrict} />

Pode comparar apenas a província ou escolher um dos seus distritos.

{selectionNotice &&

{selectionNotice}

}
    {selected.map((id) => { const t = territories.find( (item) => item.id === id, ); const label = t ? `${t.name} — ${t.location_type === 'province' ? 'Província' : 'Distrito'}` : 'Localização guardada'; return (
  • {label}
  • ); })}
{evidence.territories.length > 0 && (

Transformar a análise numa ideia

Prepare uma ideia nesta localização e confronte-a com a oferta existente. Não é necessário haver uma oportunidade publicada para iniciar a análise.

{evidence.territories.map((t) => ( Preparar ideia em {t.name} ))}
)} ); }