mirror of
https://github.com/HSLdevcom/digitransit-ui
synced 2026-02-22 16:35:47 +01:00
43 lines
1.2 KiB
JavaScript
43 lines
1.2 KiB
JavaScript
import PropTypes from 'prop-types';
|
|
import React from 'react';
|
|
import SettingsToggle from './SettingsToggle';
|
|
import { saveRoutingSettings } from '../../../action/SearchSettingsActions';
|
|
import Icon from '../../Icon';
|
|
import { addAnalyticsEvent } from '../../../util/analyticsUtils';
|
|
import { settingsShape } from '../../../util/shapes';
|
|
|
|
export default function Personalisation(
|
|
{ currentSettings },
|
|
{ executeAction },
|
|
) {
|
|
const onToggle = () => {
|
|
addAnalyticsEvent({
|
|
category: 'ItinerarySettings',
|
|
action: `Settings${
|
|
currentSettings.personalisation ? 'Disable' : 'Enable'
|
|
}Personalisation`,
|
|
name: null,
|
|
});
|
|
executeAction(saveRoutingSettings, {
|
|
personalisation: !currentSettings.personalisation,
|
|
});
|
|
};
|
|
|
|
return (
|
|
<SettingsToggle
|
|
id="settings-toggle-personalisation"
|
|
labelId="personalisation"
|
|
leftElement={<Icon img="icon_star-with-circle" height={2} width={2} />}
|
|
toggled={!!currentSettings.personalisation}
|
|
onToggle={onToggle}
|
|
/>
|
|
);
|
|
}
|
|
|
|
Personalisation.propTypes = {
|
|
currentSettings: settingsShape.isRequired,
|
|
};
|
|
|
|
Personalisation.contextTypes = {
|
|
executeAction: PropTypes.func.isRequired,
|
|
};
|