fix: complete InvesteMoz validation and error corrections
This commit is contained in:
@@ -1,11 +1,24 @@
|
||||
const territoryKeys=['province_id','district_id','admin_post_id','locality_id'];
|
||||
const territoryKeys = [
|
||||
'province_id',
|
||||
'district_id',
|
||||
'admin_post_id',
|
||||
'locality_id',
|
||||
];
|
||||
/** No fallback scope: an explicit empty path means all; a selected path replaces its old descendants. */
|
||||
export function territorialSearchParams(entries: Iterable<[string,FormDataEntryValue]>, path?: {id:string;location_type:string}[]): URLSearchParams {
|
||||
const params=new URLSearchParams();
|
||||
for(const [key,value] of entries)if(typeof value==='string'&&value!==''&&key!=='page')params.set(key,value);
|
||||
if(path){
|
||||
territoryKeys.forEach(key=>params.delete(key));
|
||||
for(const node of path){const key=`${node.location_type}_id`;if(territoryKeys.includes(key))params.set(key,node.id);}
|
||||
export function territorialSearchParams(
|
||||
entries: Iterable<[string, FormDataEntryValue]>,
|
||||
path?: { id: string; location_type: string }[],
|
||||
): URLSearchParams {
|
||||
const params = new URLSearchParams();
|
||||
for (const [key, value] of entries)
|
||||
if (typeof value === 'string' && value !== '' && key !== 'page')
|
||||
params.set(key, value);
|
||||
if (path) {
|
||||
territoryKeys.forEach((key) => params.delete(key));
|
||||
for (const node of path) {
|
||||
const key = `${node.location_type}_id`;
|
||||
if (territoryKeys.includes(key)) params.set(key, node.id);
|
||||
}
|
||||
}
|
||||
return params;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user