1- import { SetVehicleProfile , UpdateSettings } from '@/actions/Actions'
1+ import { SetVehicleProfile , UpdateSettings } from '@/actions/Actions'
22import Dispatcher from '@/stores/Dispatcher'
33import styles from '@/sidebar/SettingsBox.module.css'
4- import { tr } from '@/translation/Translation'
4+ import { tr } from '@/translation/Translation'
55import PlainButton from '@/PlainButton'
66import OnIcon from '@/sidebar/toggle_on.svg'
77import OffIcon from '@/sidebar/toggle_off.svg'
8- import { useContext } from 'react'
9- import { SettingsContext } from '@/contexts/SettingsContext'
10- import { RoutingProfile } from '@/api/graphhopper'
11- import { ProfileGroupMap } from " @/stores/QueryStore" ;
12- import * as config from " config" ;
8+ import { useContext } from 'react'
9+ import { SettingsContext } from '@/contexts/SettingsContext'
10+ import { RoutingProfile } from '@/api/graphhopper'
11+ import { ProfileGroupMap } from ' @/stores/QueryStore'
12+ import * as config from ' config'
1313
14- export default function SettingsBox ( { profile} : { profile : RoutingProfile } ) {
14+ export default function SettingsBox ( { profile } : { profile : RoutingProfile } ) {
1515 const settings = useContext ( SettingsContext )
1616
1717 function setProfile ( n : string ) {
18- Dispatcher . dispatch ( new SetVehicleProfile ( { name : profile . name === n ? 'car' : n } ) )
18+ Dispatcher . dispatch ( new SetVehicleProfile ( { name : profile . name === n ? 'car' : n } ) )
1919 }
2020
2121 const groupName = ProfileGroupMap . create ( config . profile_group_mapping ) [ profile . name ]
2222 const group = config . profile_group_mapping [ groupName ]
2323 return (
2424 < div className = { styles . parent } >
25- { groupName && < span className = { styles . groupProfileOptionsHeader } >
26- { tr ( groupName + "_settings" ) }
27- </ span > }
28- { groupName && < div className = { styles . settingsTable } >
29- < div className = { styles . groupProfileOptions } >
30- { group . options . map ( ( option ) => (
31- < div key = { option . profile } >
32- < input checked = { profile . name === option . profile } type = "radio" id = { option . profile }
33- name = { groupName } value = { option . profile }
34- onClick = { ( ) => setProfile ( option . profile ) } />
35- < label htmlFor = { option . profile } >
36- { tr ( groupName + '_settings_' + option . profile ) }
37- </ label >
38- </ div >
39- ) ) }
25+ { groupName && < span className = { styles . groupProfileOptionsHeader } > { tr ( groupName + '_settings' ) } </ span > }
26+ { groupName && (
27+ < div className = { styles . settingsTable } >
28+ < div className = { styles . groupProfileOptions } >
29+ { group . options . map ( option => (
30+ < div key = { option . profile } >
31+ < input
32+ checked = { profile . name === option . profile }
33+ type = "radio"
34+ id = { option . profile }
35+ name = { groupName }
36+ value = { option . profile }
37+ onClick = { ( ) => setProfile ( option . profile ) }
38+ />
39+ < label htmlFor = { option . profile } > { tr ( groupName + '_settings_' + option . profile ) } </ label >
40+ </ div >
41+ ) ) }
42+ </ div >
4043 </ div >
41- </ div > }
44+ ) }
4245 < div className = { styles . title } > { tr ( 'settings' ) } </ div >
4346 < div className = { styles . settingsTable } >
4447 < SettingsToggle
4548 title = { tr ( 'distance_unit' , [ tr ( settings . showDistanceInMiles ? 'mi' : 'km' ) ] ) }
4649 enabled = { settings . showDistanceInMiles }
4750 onClick = { ( ) =>
48- Dispatcher . dispatch ( new UpdateSettings ( { showDistanceInMiles : ! settings . showDistanceInMiles } ) )
51+ Dispatcher . dispatch ( new UpdateSettings ( { showDistanceInMiles : ! settings . showDistanceInMiles } ) )
4952 }
5053 />
5154 </ div >
@@ -56,23 +59,23 @@ export default function SettingsBox({profile}: { profile: RoutingProfile }) {
5659 title = { tr ( 'settings_gpx_export_trk' ) }
5760 enabled = { settings . gpxExportTrk }
5861 onClick = { ( ) =>
59- Dispatcher . dispatch ( new UpdateSettings ( { gpxExportTrk : ! settings . gpxExportTrk } ) )
62+ Dispatcher . dispatch ( new UpdateSettings ( { gpxExportTrk : ! settings . gpxExportTrk } ) )
6063 }
6164 />
6265
6366 < SettingsCheckbox
6467 title = { tr ( 'settings_gpx_export_rte' ) }
6568 enabled = { settings . gpxExportRte }
6669 onClick = { ( ) =>
67- Dispatcher . dispatch ( new UpdateSettings ( { gpxExportRte : ! settings . gpxExportRte } ) )
70+ Dispatcher . dispatch ( new UpdateSettings ( { gpxExportRte : ! settings . gpxExportRte } ) )
6871 }
6972 />
7073
7174 < SettingsCheckbox
7275 title = { tr ( 'settings_gpx_export_wpt' ) }
7376 enabled = { settings . gpxExportWpt }
7477 onClick = { ( ) =>
75- Dispatcher . dispatch ( new UpdateSettings ( { gpxExportWpt : ! settings . gpxExportWpt } ) )
78+ Dispatcher . dispatch ( new UpdateSettings ( { gpxExportWpt : ! settings . gpxExportWpt } ) )
7679 }
7780 />
7881 </ div >
@@ -88,23 +91,22 @@ export default function SettingsBox({profile}: { profile: RoutingProfile }) {
8891 )
8992}
9093
91- function SettingsToggle ( { title, enabled, onClick} : { title : string ; enabled : boolean ; onClick : ( ) => void } ) {
94+ function SettingsToggle ( { title, enabled, onClick } : { title : string ; enabled : boolean ; onClick : ( ) => void } ) {
9295 return (
9396 < div className = { styles . settingsToggle } onClick = { onClick } >
94- < PlainButton style = { { color : enabled ? '' : 'lightgray' } } className = { styles . toggleButton } >
95- { enabled ? < OnIcon /> : < OffIcon /> }
97+ < PlainButton style = { { color : enabled ? '' : 'lightgray' } } className = { styles . toggleButton } >
98+ { enabled ? < OnIcon /> : < OffIcon /> }
9699 </ PlainButton >
97- < div style = { { color : enabled ? '#5b616a' : 'gray' } } > { title } </ div >
100+ < div style = { { color : enabled ? '#5b616a' : 'gray' } } > { title } </ div >
98101 </ div >
99102 )
100103}
101104
102- function SettingsCheckbox ( { title, enabled, onClick} : { title : string ; enabled : boolean ; onClick : ( ) => void } ) {
105+ function SettingsCheckbox ( { title, enabled, onClick } : { title : string ; enabled : boolean ; onClick : ( ) => void } ) {
103106 return (
104107 < div className = { styles . settingsCheckbox } onClick = { onClick } >
105- < input type = "checkbox" checked = { enabled } onChange = { ignore => {
106- } } > </ input >
107- < label style = { { color : enabled ? '#5b616a' : 'gray' } } > { title } </ label >
108+ < input type = "checkbox" checked = { enabled } onChange = { ignore => { } } > </ input >
109+ < label style = { { color : enabled ? '#5b616a' : 'gray' } } > { title } </ label >
108110 </ div >
109111 )
110112}
0 commit comments