-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathHome.jsx
66 lines (59 loc) · 2.04 KB
/
Home.jsx
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
57
58
59
60
61
62
63
64
65
66
import { Route, Routes } from 'react-router-dom';
import MastNavItemSNCF from 'common/BootstrapSNCF/MastNavItemSNCF';
import MastNavSNCF from 'common/BootstrapSNCF/MastNavSNCF';
import NavBarSNCF from 'common/BootstrapSNCF/NavBarSNCF';
import React from 'react';
import logo from 'assets/pictures/home/customget.svg';
import { useTranslation } from 'react-i18next';
import { useDispatch } from 'react-redux';
import { updateSimulation } from 'reducers/osrdsimulation/actions';
import convertData from 'applications/customget/components/convertData';
import CustomGET from 'applications/customget/views/CustomGET';
import './Home.scss';
import { useModal } from 'common/BootstrapSNCF/ModalSNCF';
import UploadFileModal from './components/uploadFileModal';
function HomeCustomGET() {
const { t } = useTranslation(['customget', 'home/home']);
const { openModal, closeModal } = useModal();
const dispatch = useDispatch();
const handleSubmit = async (file) => {
closeModal();
if (file) {
dispatch(
updateSimulation({
trains: convertData(JSON.parse(file)),
})
);
}
};
return (
<div className="customget-home">
<MastNavSNCF
items={
<div className="mast-nav-sncf-items">
<MastNavItemSNCF
link="/customget/"
linkname={t('results')}
icon="icons-itinerary-train-station"
/>
<li>
<button
type="button"
className="mastnav-item"
onClick={() => openModal(<UploadFileModal handleSubmit={handleSubmit} />)}
>
<i className="icons-add icons-size-1x5" aria-hidden="true" />
<span className="font-weight-medium">{t('customget:uploadFile')}</span>
</button>
</li>
</div>
}
/>
<NavBarSNCF appName={t('home/home:customget')} logo={logo} />
<Routes>
<Route path="" element={<CustomGET />} />
</Routes>
</div>
);
}
export default HomeCustomGET;