|
1 | 1 | import { DateTime } from 'luxon'; |
2 | 2 | import { FC } from 'react'; |
3 | 3 | import { useTranslation } from 'react-i18next'; |
4 | | -import { LineAllFieldsFragment } from '../../../generated/graphql'; |
| 4 | +import { twJoin } from 'tailwind-merge'; |
| 5 | +import { |
| 6 | + LineAllFieldsFragment, |
| 7 | + ReusableComponentsVehicleModeEnum, |
| 8 | +} from '../../../generated/graphql'; |
5 | 9 | import { useAppDispatch, useAppSelector } from '../../../hooks'; |
6 | 10 | import { Column, Container, Row, Visible } from '../../../layoutComponents'; |
7 | 11 | import { |
@@ -29,6 +33,53 @@ import { MapPreview } from './MapPreview'; |
29 | 33 | import { LineFetchError, useGetLineDetails } from './useGetLineDetails'; |
30 | 34 | import { useGetRoutesDisplayedInList } from './useGetRoutesDisplayedInList'; |
31 | 35 |
|
| 36 | +export function showIconForVehicleMode( |
| 37 | + vehicleMode: ReusableComponentsVehicleModeEnum | null, |
| 38 | + className?: string, |
| 39 | +) { |
| 40 | + switch (vehicleMode) { |
| 41 | + case ReusableComponentsVehicleModeEnum.Bus: |
| 42 | + return ( |
| 43 | + <i className={twJoin('icon-bus-alt text-tweaked-brand', className)} /> |
| 44 | + ); |
| 45 | + case ReusableComponentsVehicleModeEnum.Tram: |
| 46 | + return ( |
| 47 | + <i |
| 48 | + className={twJoin( |
| 49 | + 'icon-tram-filled text-hsl-tram-dark-green', |
| 50 | + className, |
| 51 | + )} |
| 52 | + /> |
| 53 | + ); |
| 54 | + case ReusableComponentsVehicleModeEnum.Metro: |
| 55 | + return ( |
| 56 | + <i |
| 57 | + className={twJoin( |
| 58 | + 'icon-metro-filled text-hsl-metro-orange', |
| 59 | + className, |
| 60 | + )} |
| 61 | + /> |
| 62 | + ); |
| 63 | + case ReusableComponentsVehicleModeEnum.Ferry: |
| 64 | + return ( |
| 65 | + <i |
| 66 | + className={twJoin('icon-ferry-filled text-hsl-ferry-blue', className)} |
| 67 | + /> |
| 68 | + ); |
| 69 | + case ReusableComponentsVehicleModeEnum.Train: |
| 70 | + return ( |
| 71 | + <i |
| 72 | + className={twJoin( |
| 73 | + 'icon-train-filled text-hsl-train-purple', |
| 74 | + className, |
| 75 | + )} |
| 76 | + /> |
| 77 | + ); |
| 78 | + default: |
| 79 | + return null; |
| 80 | + } |
| 81 | +} |
| 82 | + |
32 | 83 | export const LineDetailsByIdPage: FC = () => { |
33 | 84 | const { t } = useTranslation(); |
34 | 85 |
|
@@ -75,7 +126,10 @@ export const LineDetailsByIdPage: FC = () => { |
75 | 126 | <div> |
76 | 127 | <PageHeader className={getHeaderBorderClassName()}> |
77 | 128 | <Row> |
78 | | - <i className="icon-bus-alt mt-2 text-6xl text-tweaked-brand" /> |
| 129 | + {showIconForVehicleMode( |
| 130 | + line?.primary_vehicle_mode ?? null, |
| 131 | + 'text-6xl mt-2', |
| 132 | + )} |
79 | 133 | {line && <LineTitle line={line} onCreateRoute={onCreateRoute} />} |
80 | 134 | </Row> |
81 | 135 | </PageHeader> |
|
0 commit comments