Skip to content

Commit

Permalink
feat(incidents): add incidents filter
Browse files Browse the repository at this point in the history
Fixes: #1863
  • Loading branch information
r0xsh committed Sep 5, 2024
1 parent e3c65cf commit 774b93a
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 7 deletions.
3 changes: 2 additions & 1 deletion src/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,7 @@
"FEATURED": "Featured",
"EXCLUSIVE": "Exclusive",
"NEW": "New",
"RESTAURANT_MORE_INFOS": "More information"
"RESTAURANT_MORE_INFOS": "More information",
"HIDE_INCIDENTS_TASKS": "Hide incidents"
}
}
3 changes: 2 additions & 1 deletion src/i18n/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,7 @@
"CART_ZERO_WASTE_POPUP_BUTTON_TEXT": "Jʼai compris",
"TERMS_OF_SERVICE": "Conditions générales",
"PRIVACY": "Confidentialité",
"RESTAURANT_MORE_INFOS": "En savoir plus"
"RESTAURANT_MORE_INFOS": "En savoir plus",
"HIDE_INCIDENTS_TASKS": "Cacher les incidents"
}
}
24 changes: 19 additions & 5 deletions src/navigation/courier/Settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@ import {
setSignatureScreenFirst,
setTasksChangedAlertSound,
} from '../../redux/Courier';
import { doneIconName, failedIconName } from '../task/styles/common';
import {
doneIconName,
failedIconName,
incidentIconName,
} from '../task/styles/common';
import { selectAreIncidentsHidden } from '../../redux/Courier/taskSelectors';

const SettingsItemInner = ({ item }) => (
<HStack alignItems="center" justifyContent="space-between" py="3">
Expand Down Expand Up @@ -55,6 +60,8 @@ const Settings = ({
tasksChangedAlertSound,
toggleDisplayDone,
toggleDisplayFailed,
toggleDisplayIncidens,
areIncidentsHidden,
toggleTasksChangedAlertSound,
togglePolylineOn,
setKeepAwakeDisabled,
Expand All @@ -76,10 +83,10 @@ const Settings = ({
isChecked: areDoneTasksHidden,
},
{
icon: failedIconName,
label: t('HIDE_FAILED_TASKS'),
onToggle: () => toggleDisplayFailed(areFailedTasksHidden),
isChecked: areFailedTasksHidden,
icon: incidentIconName,
label: t('HIDE_INCIDENTS_TASKS'),
onToggle: () => toggleDisplayIncidens(areIncidentsHidden),
isChecked: areIncidentsHidden,
},
{
icon: 'tag',
Expand Down Expand Up @@ -139,6 +146,7 @@ function mapStateToProps(state) {
tags: selectTagNames(state),
areDoneTasksHidden: selectAreDoneTasksHidden(state),
areFailedTasksHidden: selectAreFailedTasksHidden(state),
areIncidentsHidden: selectAreIncidentsHidden(state),
tasksChangedAlertSound: selectTasksChangedAlertSound(state),
isKeepAwakeDisabled: !selectKeepAwake(state),
isPolylineOn: selectIsPolylineOn(state),
Expand All @@ -160,6 +168,12 @@ function mapDispatchToProps(dispatch) {
? clearTasksFilter({ status: 'FAILED' })
: filterTasks({ status: 'FAILED' }),
),
toggleDisplayIncidens: hidden =>
dispatch(
hidden
? clearTasksFilter({ hasIncidents: true })
: filterTasks({ hasIncidents: true }),
),
toggleTasksChangedAlertSound: enabled =>
dispatch(setTasksChangedAlertSound(enabled)),
togglePolylineOn: enabled => dispatch(setPolylineOn(enabled)),
Expand Down
5 changes: 5 additions & 0 deletions src/redux/Courier/taskSelectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ export const selectAreFailedTasksHidden = createSelector(
filters => filters.some(f => f.status === 'FAILED'),
);

export const selectAreIncidentsHidden = createSelector(
selectTaskFilters,
filters => filters.some(f => f.hasIncidents),
)

/**
* @param {State} state Redux state
* @returns {Tag[]} List of unique tag objects
Expand Down

0 comments on commit 774b93a

Please sign in to comment.