Skip to content

Commit 684a5e4

Browse files
committed
trim FilterStore to vehicleStore
1 parent 472bd78 commit 684a5e4

3 files changed

Lines changed: 25 additions & 59 deletions

File tree

src/components/filter/CardFilterWhatVehicle.tsx

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,13 @@ import '../../styles/accordion.css'
1010
const CardFilterWhatVehicle = observer(() => {
1111
const { t } = useTranslation();
1212
const { filterStore } = useStore();
13-
const { injTypes,
14-
updateInjuerdType,
15-
vehicleType,
16-
updateVehicleType,
17-
involvedVehicle,
18-
setInvolvedVehicle,
19-
isValidWhatVehicle,
20-
setFormCardKey
21-
} = filterStore;
13+
const { vehicleStore, setFormCardKey } = filterStore;
14+
const {
15+
injTypes, updateInjuerdType,
16+
vehicleType, updateVehicleType,
17+
involvedVehicle,setInvolvedVehicle,
18+
isValidWhatVehicle,
19+
} = vehicleStore;
2220

2321
return (
2422
<Card>
@@ -52,4 +50,4 @@ const CardFilterWhatVehicle = observer(() => {
5250
</Card>
5351
);
5452
});
55-
export default CardFilterWhatVehicle;
53+
export default CardFilterWhatVehicle;

src/components/molecules/InfoPanel.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ const WhatTitle: React.FC<{}> = observer(() => {
6868
const WhatVehicleTitle: React.FC<{}> = observer(() => {
6969
const { t } = useTranslation();
7070
const { filterStore } = useStore();
71-
const { injTypes, vehicleType , involvedVehicle} = filterStore;
71+
const { vehicleStore: {injTypes, vehicleType , involvedVehicle}} = filterStore;
7272
let res = (injTypes.text !== '') ? `, ${injTypes.text}` : '';
7373
if (vehicleType.text !== '') res += `, ${t('VehicleType')}: ${vehicleType.text}`;
7474
if (involvedVehicle.text !== '') res += `, ${t('Vehicles')}: ${involvedVehicle.text}`;
@@ -87,7 +87,7 @@ const YearsTitle: React.FC<{}> = observer(() => {
8787
const InjuriesCountTitle: React.FC<{}> = observer(() => {
8888
const { t } = useTranslation();
8989
const { filterStore } = useStore();
90-
const { injTypes, injuriesCount , casualtiesNames} = filterStore;
90+
const { injuriesCount , casualtiesNames} = filterStore;
9191
let res = (injuriesCount > 0)? `, ${t('Found')} ${injuriesCount} ${t(casualtiesNames)}`: `, ${t('NoResultsFound')}`;
9292
return (
9393
<span>{res}</span>

src/stores/filter/FilterStore.ts

Lines changed: 15 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -297,39 +297,7 @@ class FilterStore implements IFilterStore {
297297
@computed get isValidWhat() {
298298
return this.getWhatStore().isValidWhat;
299299
}
300-
301-
// ///////////////////////////////////////////////////////////////////////////////////////////////
302-
// What Vehicle
303-
// ///////////////////////////////////////////////////////////////////////////////////////////////
304-
305-
get injTypes() {
306-
return this.vehicleStore.injTypes;
307-
}
308-
309-
updateInjuerdType = (aType: number, val: boolean) => {
310-
this.vehicleStore.updateInjuerdType(aType, val);
311-
}
312-
313-
get vehicleType() {
314-
return this.vehicleStore.vehicleType;
315-
}
316-
317-
updateVehicleType = (aType: number, val: boolean) => {
318-
this.vehicleStore.updateVehicleType(aType, val);
319-
}
320-
321-
get involvedVehicle() {
322-
return this.vehicleStore.involvedVehicle;
323-
}
324-
325-
setInvolvedVehicle = (aType: number, val: boolean) => {
326-
this.vehicleStore.setInvolvedVehicle(aType, val);
327-
}
328-
329-
@computed get isValidWhatVehicle() {
330-
return this.vehicleStore.isValidWhatVehicle;
331-
}
332-
300+
333301
// ///////////////////////////////////////////////////////////////////////////////////////////////
334302
// What Road (delegated to RoadFilterStore)
335303
// ///////////////////////////////////////////////////////////////////////////////////////////////
@@ -438,7 +406,7 @@ class FilterStore implements IFilterStore {
438406

439407
@computed get isValidAllFilters() {
440408
const res = this.severityStore.isValidSeverity && this.timeStore.isValidWhen && this.isValidWho
441-
&& this.isValidWhere && this.isValidWhat && this.isValidWhatVehicle && this.isValidWhatRoad;
409+
&& this.isValidWhere && this.isValidWhat && this.vehicleStore.isValidWhatVehicle && this.isValidWhatRoad;
442410
return res;
443411
}
444412

@@ -729,13 +697,13 @@ class FilterStore implements IFilterStore {
729697
query += this.streets.getFilter();
730698
query += this.roads.getFilter();
731699
query += this.roadSegment.getFilter();
732-
query += this.injTypes.getFilter();
700+
query += this.vehicleStore.injTypes.getFilter();
733701
query += this.genderTypes.getFilter();
734702
query += this.ageTypes.getFilter();
735703
query += this.populationTypes.getFilter();
736704
query += this.accidentType.getFilter();
737-
query += this.vehicleType.getFilter();
738-
query += this.involvedVehicle.getFilter();
705+
query += this.vehicleStore.vehicleType.getFilter();
706+
query += this.vehicleStore.involvedVehicle.getFilter();
739707
query += this.locationAccuracy.getFilter();
740708
query += this.roadTypes.getFilter();
741709
query += this.speedLimit.getFilter();
@@ -754,7 +722,7 @@ class FilterStore implements IFilterStore {
754722
setFiltersText = (ignoreIfAll: boolean) => {
755723
this.timeStore.startYear.setText();
756724
this.timeStore.endYear.setText();
757-
this.injTypes.setText(ignoreIfAll);
725+
this.vehicleStore.injTypes.setText(ignoreIfAll);
758726
this.timeStore.dayNight.setText(ignoreIfAll);
759727
this.genderTypes.setText(ignoreIfAll);
760728
this.ageTypes.setText(ignoreIfAll);
@@ -767,8 +735,8 @@ class FilterStore implements IFilterStore {
767735
this.roads.setText();
768736
this.cityPopSizeRange.setText();
769737
this.accidentType.setText(ignoreIfAll);
770-
this.vehicleType.setText(ignoreIfAll);
771-
this.involvedVehicle.setText(ignoreIfAll);
738+
this.vehicleStore.vehicleType.setText(ignoreIfAll);
739+
this.vehicleStore.involvedVehicle.setText(ignoreIfAll);
772740
}
773741

774742
/**
@@ -783,7 +751,7 @@ class FilterStore implements IFilterStore {
783751
this.timeStore.endYear.setBrowserQueryString(params, false);
784752
this.severityStore.injurySeverity.setBrowserQueryString(params, false);
785753
this.roadTypes.setBrowserQueryString(params);
786-
this.injTypes.setBrowserQueryString(params);
754+
this.vehicleStore.injTypes.setBrowserQueryString(params);
787755
this.genderTypes.setBrowserQueryString(params);
788756
this.ageTypes.setBrowserQueryString(params);
789757
this.populationTypes.setBrowserQueryString(params);
@@ -792,8 +760,8 @@ class FilterStore implements IFilterStore {
792760
this.roads.setBrowserQueryString(params);
793761
this.locationAccuracy.setBrowserQueryString(params);
794762
this.accidentType.setBrowserQueryString(params);
795-
this.vehicleType.setBrowserQueryString(params);
796-
this.involvedVehicle.setBrowserQueryString(params);
763+
this.vehicleStore.vehicleType.setBrowserQueryString(params);
764+
this.vehicleStore.involvedVehicle.setBrowserQueryString(params);
797765
this.speedLimit.setBrowserQueryString(params);
798766
this.roadWidth.setBrowserQueryString(params);
799767
this.separator.setBrowserQueryString(params);
@@ -824,13 +792,13 @@ class FilterStore implements IFilterStore {
824792
this.setRoads(roads);
825793
this.locationAccuracy.setValuesByQuery(params);
826794
this.roadTypes.setValuesByQuery(params);
827-
this.injTypes.setValuesByQuery(params);
795+
this.vehicleStore.injTypes.setValuesByQuery(params);
828796
this.genderTypes.setValuesByQuery(params);
829797
this.ageTypes.setValuesByQuery(params);
830798
this.populationTypes.setValuesByQuery(params);
831799
this.accidentType.setValuesByQuery(params);
832-
this.vehicleType.setValuesByQuery(params);
833-
this.involvedVehicle.setValuesByQuery(params);
800+
this.vehicleStore.vehicleType.setValuesByQuery(params);
801+
this.vehicleStore.involvedVehicle.setValuesByQuery(params);
834802
this.speedLimit.setValuesByQuery(params);
835803
this.roadWidth.setValuesByQuery(params);
836804
this.separator.setValuesByQuery(params);
@@ -957,4 +925,4 @@ class FilterStore implements IFilterStore {
957925
}
958926
}
959927

960-
export default FilterStore;
928+
export default FilterStore;

0 commit comments

Comments
 (0)