-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathInfraLoadingState.tsx
45 lines (40 loc) · 1.06 KB
/
InfraLoadingState.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
import cx from 'classnames';
import { useTranslation } from 'react-i18next';
import type { InfraWithState } from 'common/api/osrdEditoastApi';
const STEPS = [
'INITIALIZING',
'DOWNLOADING',
'PARSING_JSON',
'PARSING_INFRA',
'LOADING_SIGNALS',
'BUILDING_BLOCKS',
'CACHED',
];
type Props = {
infra: InfraWithState;
};
export default function InfraLoadingState({ infra }: Props) {
const { t } = useTranslation('operationalStudies/scenario');
return (
<div
className={cx(
'infra-loading-state',
infra.state && infra.state === 'CACHED' ? 'cached' : 'loading'
)}
title={infra.state}
>
{infra.state && infra.state === 'CACHED' ? (
<span className="infra-loaded" />
) : (
<>
<span className="infra-loader">•</span>
<span className="infra-loader">•</span>
<span className="infra-loader">•</span>
<div className="steps">
{t('infraLoadingState', { step: STEPS.indexOf(infra.state) + 1 })}
</div>
</>
)}
</div>
);
}