feat: consolidar desenvolvimentos do portal InvestMoz

This commit is contained in:
2026-11-03 23:32:32 +02:00
parent 1da273f1f3
commit 36c8cadb49
345 changed files with 110714 additions and 2799 deletions
+52
View File
@@ -5,6 +5,58 @@ export type BusinessLocationPath = {
locality_id: string;
};
export function businessPointTerritoryKey(path: BusinessLocationPath): string {
return [
path.province_id,
path.district_id,
path.admin_post_id,
path.locality_id,
].join('|');
}
export function businessPointTerritoryLabel(
payload: Record<string, string | undefined>,
paths: string[][] = [],
): string {
const index =
payload.geography_scope === 'specific'
? 0
: decodeBusinessLocations(payload.locations_json).findIndex(
(path) =>
businessPointTerritoryKey(path) ===
payload.location_point_territory,
);
return paths[index]?.join(' / ') || 'Localização por reconciliar';
}
export function businessPointApplicable(
payload: Record<string, string | undefined>,
): boolean {
return (
payload.location_point_enabled === 'yes' &&
['specific', 'multiple'].includes(payload.geography_scope ?? '') &&
payload.disclosure_precision === 'exact' &&
payload.location_unknown === 'no'
);
}
export function businessPointRequiredFields(
payload: Record<string, string | undefined>,
): Set<string> {
if (!businessPointApplicable(payload)) return new Set();
return new Set([
'location_latitude',
'location_longitude',
'location_point_source_mode',
...(payload.geography_scope === 'multiple'
? ['location_point_territory']
: []),
...(payload.location_point_source_mode === 'custom'
? ['location_point_source_reference']
: []),
]);
}
export const emptyBusinessLocation = (): BusinessLocationPath => ({
province_id: '',
district_id: '',