-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathStationCard.tsx
56 lines (52 loc) · 1.75 KB
/
StationCard.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import React from 'react';
import { formatUicToCi } from 'utils/strings';
export interface ImportStation {
trigram?: string;
name?: string;
yardname?: string;
town?: string;
department?: string;
region?: string;
uic?: number;
linename?: string;
pk?: string;
linecode?: string;
}
type Props = {
station: ImportStation;
onClick?: () => void;
fixedHeight?: boolean;
};
const yardNamesToExclude = ['BV', '00'];
export default function StationCard({ station, onClick, fixedHeight = false }: Props) {
const { trigram, name, yardname, town, department, region, uic, linename, pk, linecode } =
station;
return (
<div
className={`station-card ${fixedHeight ? 'fixed-height' : ''}`}
role="button"
tabIndex={0}
onClick={onClick}
>
<div className="station-card-head">
<span className="station-card-code">{trigram}</span>
<span className="station-card-name">{name} </span>
{yardname && !yardNamesToExclude.includes(yardname) && <small>{yardname}</small>}
{uic && <span className="station-card-uic ml-3">{formatUicToCi(uic)}</span>}
</div>
<div className="station-card-localization">
<span className="station-card-city">{town}</span>
<span className="station-card-department">{department}</span>
{department && region && <div className="station-card-separator">/</div>}
<span className="station-card-region">{region}</span>
</div>
{linename && (
<div className="station-card-footer">
<span className="station-card-line">{linename}</span>
{pk && <span className="station-card-pk">PK {pk}</span>}
<span className="station-card-line-number">{linecode}</span>
</div>
)}
</div>
);
}