2021-04-07 17:46:07 +00:00
|
|
|
import React, { useEffect } from "react";
|
2021-03-31 04:30:37 +00:00
|
|
|
import Footer from "./shared-components/footer-component/Footer";
|
|
|
|
import Navbar from "./shared-components/navbar-component/Navbar";
|
2021-04-07 17:46:07 +00:00
|
|
|
import { BrowserRouter, Route, Switch } from "react-router-dom";
|
|
|
|
import i18next from "i18next";
|
|
|
|
import Cookies from "js-cookie";
|
2021-04-01 01:01:55 +00:00
|
|
|
import HomePage from "./homePage/Homepage";
|
2021-03-31 18:26:10 +00:00
|
|
|
import ListingsPage from "./listings-page/ListingsPage";
|
|
|
|
import AgentPage from "./agent-page/AgentPage";
|
2021-04-05 18:58:04 +00:00
|
|
|
import ListingPage from "./listings-page/single-listing/listing-page";
|
2021-04-05 22:23:55 +00:00
|
|
|
import Login from "./login-page/Login";
|
2021-04-07 17:46:07 +00:00
|
|
|
import Account from "./login-page/account/Account";
|
2021-04-04 01:01:15 +00:00
|
|
|
import ContactUs from "./shared-components/contact-us/contact-us";
|
2021-03-28 15:39:48 +00:00
|
|
|
|
2021-04-07 17:46:07 +00:00
|
|
|
const langauges = [
|
|
|
|
{
|
|
|
|
code: "fr",
|
|
|
|
name: "Français",
|
|
|
|
country_code: "fr",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
code: "en",
|
|
|
|
name: "English",
|
|
|
|
country_code: "gb",
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
function App() {
|
|
|
|
const currentLanguageCode = Cookies.get("i18next") || "en";
|
|
|
|
const currentLanguage = langauges.find(
|
|
|
|
(lang) => lang.code === currentLanguageCode
|
|
|
|
);
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
document.body.dir = currentLanguage.dir || "ltr";
|
|
|
|
}, [currentLanguage]);
|
|
|
|
return (
|
|
|
|
<div className="App">
|
|
|
|
{/* create the translations button */}
|
|
|
|
<div className="container">
|
|
|
|
<div className="d-flex justify-content-end">
|
|
|
|
{/* <!-- Example single danger button --> */}
|
|
|
|
<div class="btn-group">
|
|
|
|
<button
|
|
|
|
type="button"
|
|
|
|
class="btn btn-link dropdown-toggle"
|
|
|
|
data-toggle="dropdown"
|
|
|
|
aria-haspopup="true"
|
|
|
|
aria-expanded="false"
|
|
|
|
>
|
|
|
|
<i class="fas fa-globe"></i>
|
|
|
|
</button>
|
|
|
|
<div class="dropdown-menu">
|
|
|
|
{langauges.map(({ code, name, country_code }) => (
|
|
|
|
<button
|
|
|
|
class="dropdown-item"
|
|
|
|
key={code}
|
|
|
|
onClick={() => i18next.changeLanguage(code)}
|
|
|
|
disabled={code === currentLanguageCode}
|
|
|
|
>
|
|
|
|
<span
|
|
|
|
className={`flag-icon flag-icon-${country_code} mx-2`}
|
|
|
|
></span>
|
|
|
|
{name}
|
|
|
|
</button>
|
|
|
|
))}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<BrowserRouter>
|
|
|
|
<Navbar></Navbar>
|
|
|
|
<Switch>
|
2021-03-31 19:35:29 +00:00
|
|
|
<Route exact path="/" component={HomePage}></Route>
|
2021-03-31 04:30:37 +00:00
|
|
|
<Route path="/listings" component={ListingsPage}></Route>
|
|
|
|
<Route path="/agents" component={AgentPage}></Route>
|
2021-04-05 18:58:04 +00:00
|
|
|
<Route path="/listing-page" component={ListingPage}></Route>
|
2021-04-05 22:23:55 +00:00
|
|
|
<Route path="/login" component={Login}></Route>
|
2021-04-04 01:01:15 +00:00
|
|
|
<Route path="/contact-us" component={ContactUs}></Route>
|
2021-04-07 17:46:07 +00:00
|
|
|
<Route path="/account" component={Account}></Route>
|
|
|
|
</Switch>
|
|
|
|
</BrowserRouter>
|
|
|
|
<Footer></Footer>
|
|
|
|
</div>
|
|
|
|
);
|
2021-03-28 15:39:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export default App;
|