-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.tsx
65 lines (57 loc) · 1.88 KB
/
App.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
57
58
59
60
61
62
63
64
65
import { BrowserRouter, Route, Routes } from "react-router-dom";
import Home from './Home/Home.tsx';
import "./index.css"
import {
Nav30DataSource,
Footer10DataSource,
} from './Home/data.source.tsx';
import Nav from './Home/Nav.tsx';
import Footer from './Home/Footer1.tsx';
import { isMobile } from 'react-device-detect';
import 'antd/dist/reset.css';
import { connect } from 'react-redux';
import { useEffect, useState } from 'react';
import Service from "./Service/index.tsx";
import Login from "./Login/Login.tsx";
import DashboardRoutes from "./Consumer/DashboardRoutes.tsx";
import { RootState } from "./store.ts";
import VendorRoutes from "./Vendor/VendorRoutes.tsx";
const App = ({ logged, type }: { logged?: boolean, type?: string }) => {
const [show, setShow] = useState(false);
useEffect(() => {
if (!show) {
setTimeout(() => {
setShow(true);
}, 100);
}
}, [show]);
return (
<div>
{show && logged ? type === "Vendor" ?
<BrowserRouter children={<VendorRoutes />} />
:
<BrowserRouter children={<DashboardRoutes />} />
:
<BrowserRouter>
<Nav key="Nav3_0" dataSource={Nav30DataSource} isMobile={isMobile} />
<Routes>
<Route path="/" element={<Home />} />
<Route path="*" element={<Home />} />
<Route path="/Home" element={<Home />} />
<Route path="/Service" element={<Service />} />
<Route path="/Access" element={<Login />} />
</Routes>
<Footer key="Footer1_0" dataSource={Footer10DataSource} isMobile={isMobile} />
</BrowserRouter>
}
</div>
);
};
const mapStateToProps = (state: RootState) => {
const logged = state.user.logged;
const type = state.user.user.type;
return { logged, type };
};
const connector = connect(mapStateToProps);
const ReturnApp = connector(App)
export default ReturnApp;