| Total Complexity | 7 |
| Complexity/F | 1.4 |
| Lines of Code | 39 |
| Function Count | 5 |
| Duplicated Lines | 0 |
| Ratio | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | import L from 'leaflet'; |
||
| 2 | import marker2x from 'leaflet/dist/images/marker-icon-2x.png'; |
||
| 3 | import marker from 'leaflet/dist/images/marker-icon.png'; |
||
| 4 | import markerShadow from 'leaflet/dist/images/marker-shadow.png'; |
||
| 5 | |||
| 6 | 3 | const DEFAULT_TIMEOUT_DELAY = 2000; |
|
| 7 | |||
| 8 | 3 | export const stateFlagTimeout = (setTimeout) => ( |
|
| 9 | setState, |
||
| 10 | flagName, |
||
| 11 | initialValue = true, |
||
| 12 | delay = DEFAULT_TIMEOUT_DELAY |
||
| 13 | ) => { |
||
| 14 | 1 | setState({ [flagName]: initialValue }); |
|
| 15 | 1 | setTimeout(() => setState({ [flagName]: !initialValue }), delay); |
|
| 16 | }; |
||
| 17 | |||
| 18 | 3 | export const determineOrderDir = (clickedField, currentOrderField, currentOrderDir) => { |
|
| 19 | 11 | if (currentOrderField !== clickedField) { |
|
| 20 | 4 | return 'ASC'; |
|
| 21 | } |
||
| 22 | |||
| 23 | 7 | const newOrderMap = { |
|
| 24 | ASC: 'DESC', |
||
| 25 | DESC: undefined, |
||
| 26 | }; |
||
| 27 | |||
| 28 | 7 | return currentOrderDir ? newOrderMap[currentOrderDir] : 'ASC'; |
|
| 29 | }; |
||
| 30 | |||
| 31 | 3 | export const fixLeafletIcons = () => { |
|
| 32 | 1 | delete L.Icon.Default.prototype._getIconUrl; |
|
| 33 | |||
| 34 | 1 | L.Icon.Default.mergeOptions({ |
|
| 35 | iconRetinaUrl: marker2x, |
||
| 36 | iconUrl: marker, |
||
| 37 | shadowUrl: markerShadow, |
||
| 38 | }); |
||
| 39 | }; |
||
| 40 |