fix: correct V13 and public presentation patterns in isolated QA
This commit is contained in:
@@ -14,6 +14,7 @@ const catalogueKeys: Record<string, string[]> = {
|
||||
'legal_regime',
|
||||
'development_status',
|
||||
'availability_status',
|
||||
'activity',
|
||||
'province',
|
||||
],
|
||||
'/oportunidades': [
|
||||
@@ -49,6 +50,34 @@ const catalogueKeys: Record<string, string[]> = {
|
||||
'subsector_id',
|
||||
],
|
||||
};
|
||||
/** Remove actual filter keys, including indexed arrays and dependent selections. */
|
||||
export function catalogueFilterHref(
|
||||
pageUrl: string,
|
||||
keys: string[],
|
||||
remove?: string,
|
||||
): string {
|
||||
const url = new URL(pageUrl, 'https://portal.invalid');
|
||||
const dependencies: Record<string, string[]> = {
|
||||
province_id: ['district_id', 'admin_post_id', 'locality_id'],
|
||||
district_id: ['admin_post_id', 'locality_id'],
|
||||
admin_post_id: ['locality_id'],
|
||||
sector: ['subsector_id', 'chain_id'],
|
||||
};
|
||||
const selected = new Set(
|
||||
remove ? [remove, ...(dependencies[remove] ?? [])] : keys,
|
||||
);
|
||||
const presentKeys = Array.from(url.searchParams.keys());
|
||||
for (const key of presentKeys)
|
||||
if (
|
||||
selected.has(key) ||
|
||||
[...selected].some((base) =>
|
||||
key.startsWith(base.replace(/\[\]$/, '') + '['),
|
||||
)
|
||||
)
|
||||
url.searchParams.delete(key);
|
||||
url.searchParams.delete('page');
|
||||
return url.pathname + url.search;
|
||||
}
|
||||
function family(path: string): string {
|
||||
if (path.startsWith('/management/portfolio')) return '/carteira';
|
||||
if (path.startsWith('/management/investment/zones')) return '/zonas';
|
||||
|
||||
Reference in New Issue
Block a user