feat: consolidar desenvolvimentos do portal InvestMoz
This commit is contained in:
@@ -6,6 +6,9 @@ import type { Business } from './business-types';
|
||||
import { businessModalities } from './business-types';
|
||||
import BusinessObjects from './business-objects';
|
||||
import type { BusinessObject } from './business-objects';
|
||||
import BusinessPointSummary, {
|
||||
type RegisteredBusinessLocation,
|
||||
} from '@/components/business-point-summary';
|
||||
import {
|
||||
decodeBusinessLocations,
|
||||
emptyBusinessLocation,
|
||||
@@ -13,6 +16,8 @@ import {
|
||||
hasDuplicateBusinessLocationPath,
|
||||
locationPathFromPayload,
|
||||
updateBusinessLocation,
|
||||
businessPointTerritoryKey,
|
||||
businessPointRequiredFields,
|
||||
} from '../../lib/business-locations';
|
||||
|
||||
export type FormSchema = Record<
|
||||
@@ -36,6 +41,8 @@ type Props = {
|
||||
objects: BusinessObject[];
|
||||
objectKinds: string[];
|
||||
sectors: { id: number; name: string }[];
|
||||
registeredLocation?: RegisteredBusinessLocation | null;
|
||||
pointPublicationAvailable?: boolean;
|
||||
};
|
||||
const steps = [
|
||||
['Proponente', 'Applicant'],
|
||||
@@ -185,6 +192,8 @@ export default function BusinessWizard({
|
||||
objects,
|
||||
objectKinds,
|
||||
sectors,
|
||||
registeredLocation,
|
||||
pointPublicationAvailable,
|
||||
}: Props) {
|
||||
const [english, setEnglish] = useState(false);
|
||||
const t = (pt: string, en: string) => (english ? en : pt);
|
||||
@@ -206,6 +215,7 @@ export default function BusinessWizard({
|
||||
return initial;
|
||||
});
|
||||
const modality = record.modality;
|
||||
const pointRequired = businessPointRequiredFields(payload);
|
||||
const [sectorId, setSectorId] = useState(record.sector_id ?? null);
|
||||
const [sectorSearch, setSectorSearch] = useState('');
|
||||
const [publicTitle, setPublicTitle] = useState(record.public_title ?? '');
|
||||
@@ -530,6 +540,13 @@ export default function BusinessWizard({
|
||||
<p>
|
||||
{record.code} · {t('Versão', 'Version')} {version}
|
||||
</p>
|
||||
{[5, 7, 8].includes(step) && (
|
||||
<BusinessPointSummary
|
||||
payload={payload}
|
||||
registered={registeredLocation}
|
||||
available={pointPublicationAvailable}
|
||||
/>
|
||||
)}
|
||||
<p>
|
||||
{t(
|
||||
'Área privada. Guardar ou submeter não publica a oportunidade nem confirma a titularidade ou a transmissibilidade.',
|
||||
@@ -720,7 +737,7 @@ export default function BusinessWizard({
|
||||
label={
|
||||
field.type === 'checkbox'
|
||||
? ''
|
||||
: `${english ? field.en : field.pt}${requiredFields.has(key) || ((key === 'mandate_reference' || key === 'mandate_document_reference' || key === 'disclosure_scope') && payload.acting_capacity === 'representative') || (key === 'project_stage_other' && payload.project_stage === 'other') || (key === 'available_from' && payload.availability === 'from_date') || (key === 'province_id' && payload.geography_scope === 'specific') || (key === 'locations_json' && payload.geography_scope === 'multiple') || (['value_meaning', 'currency', 'asking_value'].includes(key) && ['defined', 'indicative'].includes(payload.value_status ?? '')) || (key === 'investment_total' && payload.opportunity_type === 'investment_project') || (key === 'asset_deal_kind' && ['company_sale', 'asset_sale'].includes(payload.opportunity_type ?? '')) || (key === 'partnership_contribution' && payload.opportunity_type === 'business_partnership') || (key === 'amount_sought' && payload.opportunity_type === 'financing_request') || (key === 'asset_modality' && payload.opportunity_type === 'asset_sale') || (['concession_entity', 'concession_reference'].includes(key) && payload.opportunity_type === 'concession_opportunity') || (key === 'supply_description' && payload.opportunity_type === 'supply_opportunity') ? ' *' : ''}`
|
||||
: `${english ? field.en : field.pt}${pointRequired.has(key) || requiredFields.has(key) || ((key === 'mandate_reference' || key === 'mandate_document_reference' || key === 'disclosure_scope') && payload.acting_capacity === 'representative') || (key === 'project_stage_other' && payload.project_stage === 'other') || (key === 'available_from' && payload.availability === 'from_date') || (key === 'province_id' && payload.geography_scope === 'specific') || (key === 'locations_json' && payload.geography_scope === 'multiple') || (['value_meaning', 'currency', 'asking_value'].includes(key) && ['defined', 'indicative'].includes(payload.value_status ?? '')) || (key === 'investment_total' && payload.opportunity_type === 'investment_project') || (key === 'asset_deal_kind' && ['company_sale', 'asset_sale'].includes(payload.opportunity_type ?? '')) || (key === 'partnership_contribution' && payload.opportunity_type === 'business_partnership') || (key === 'amount_sought' && payload.opportunity_type === 'financing_request') || (key === 'asset_modality' && payload.opportunity_type === 'asset_sale') || (['concession_entity', 'concession_reference'].includes(key) && payload.opportunity_type === 'concession_opportunity') || (key === 'supply_description' && payload.opportunity_type === 'supply_opportunity') ? ' *' : ''}`
|
||||
}
|
||||
>
|
||||
{field.type === 'checkbox' ? (
|
||||
@@ -775,6 +792,71 @@ export default function BusinessWizard({
|
||||
update(key, value)
|
||||
}
|
||||
/>
|
||||
) : field.type === 'point_territory' ? (
|
||||
<select
|
||||
className={input}
|
||||
value={payload[key] ?? ''}
|
||||
onChange={(event) =>
|
||||
update(key, event.target.value)
|
||||
}
|
||||
>
|
||||
<option value="">
|
||||
{t(
|
||||
'Seleccionar uma localização declarada',
|
||||
'Select a declared location',
|
||||
)}
|
||||
</option>
|
||||
{payload[key] &&
|
||||
!locationRows.some(
|
||||
(row) =>
|
||||
businessPointTerritoryKey(
|
||||
row,
|
||||
) === payload[key],
|
||||
) && (
|
||||
<option
|
||||
value={payload[key]}
|
||||
>
|
||||
{t(
|
||||
'Selecção guardada fora das localizações actuais; reconcilie antes de submeter',
|
||||
'Saved selection is outside the current locations; reconcile before submitting',
|
||||
)}
|
||||
</option>
|
||||
)}
|
||||
{locationRows
|
||||
.map((row, index) => ({
|
||||
row,
|
||||
index,
|
||||
}))
|
||||
.filter(
|
||||
({ row }) =>
|
||||
row.province_id,
|
||||
)
|
||||
.map(({ row, index }) => (
|
||||
<option
|
||||
key={businessPointTerritoryKey(
|
||||
row,
|
||||
)}
|
||||
value={businessPointTerritoryKey(
|
||||
row,
|
||||
)}
|
||||
>
|
||||
{t(
|
||||
'Localização',
|
||||
'Location',
|
||||
)}{' '}
|
||||
{index + 1}
|
||||
{payload.locations_json ===
|
||||
resolvedLocationJson &&
|
||||
territoryPaths[index]
|
||||
?.length
|
||||
? ` — ${territoryPaths[index].join(' / ')}`
|
||||
: t(
|
||||
' (declarada nesta etapa)',
|
||||
' (declared in this step)',
|
||||
)}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
) : field.type === 'select' ? (
|
||||
<select
|
||||
className={input}
|
||||
@@ -846,8 +928,8 @@ export default function BusinessWizard({
|
||||
</h3>
|
||||
<p className="text-sm">
|
||||
{t(
|
||||
'Indique pelo menos duas localizações distintas. Não são recolhidas coordenadas neste formulário.',
|
||||
'Enter at least two distinct locations. This form does not collect coordinates.',
|
||||
'Indique pelo menos duas localizações distintas. Se preparar um ponto exacto, escolha acima a localização a que pertence. Não é escolhido automaticamente o primeiro território.',
|
||||
'Enter at least two distinct locations. If preparing an exact point, select its location above. The first territory is not selected automatically.',
|
||||
)}
|
||||
</p>
|
||||
{locationRows.map((row, index) => (
|
||||
|
||||
Reference in New Issue
Block a user