Fix FE
This commit is contained in:
parent
1241132095
commit
54a5c3ca9a
28 changed files with 826 additions and 422 deletions
|
|
@ -12,7 +12,6 @@ import {
|
|||
createSchoolFilterKey,
|
||||
getSchoolFilterConfig,
|
||||
isSchoolFilterName,
|
||||
type SchoolDistance,
|
||||
type SchoolPhase,
|
||||
type SchoolRating,
|
||||
} from './school-filter';
|
||||
|
|
@ -122,22 +121,22 @@ function parseFilters(params: URLSearchParams): FeatureFilters {
|
|||
|
||||
schoolParams.forEach((entry, index) => {
|
||||
const parts = entry.split(':');
|
||||
if (parts.length !== 5) return;
|
||||
// 4 parts is the current phase:rating:min:max form; 5 parts is the legacy
|
||||
// phase:rating:distance:min:max form, whose distance segment is ignored.
|
||||
if (parts.length !== 4 && parts.length !== 5) return;
|
||||
const phase = parts[0] as SchoolPhase;
|
||||
const rating = parts[1] as SchoolRating;
|
||||
const distance = Number(parts[2]) as SchoolDistance;
|
||||
const min = Number(parts[3]);
|
||||
const max = Number(parts[4]);
|
||||
const min = Number(parts[parts.length - 2]);
|
||||
const max = Number(parts[parts.length - 1]);
|
||||
if (
|
||||
(phase !== 'primary' && phase !== 'secondary') ||
|
||||
(rating !== 'good' && rating !== 'outstanding') ||
|
||||
(distance !== 2 && distance !== 5) ||
|
||||
isNaN(min) ||
|
||||
isNaN(max)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
filters[createSchoolFilterKey(phase, rating, distance, index)] = [min, max];
|
||||
filters[createSchoolFilterKey(phase, rating, index)] = [min, max];
|
||||
});
|
||||
|
||||
crimeParams.forEach((entry, index) => {
|
||||
|
|
@ -379,10 +378,7 @@ export function stateToParams(
|
|||
const schoolConfig = getSchoolFilterConfig(name);
|
||||
if (schoolConfig && isSchoolFilterName(name)) {
|
||||
const [min, max] = value as [number, number];
|
||||
params.append(
|
||||
'school',
|
||||
`${schoolConfig.phase}:${schoolConfig.rating}:${schoolConfig.distance}:${min}:${max}`
|
||||
);
|
||||
params.append('school', `${schoolConfig.phase}:${schoolConfig.rating}:${min}:${max}`);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue