update src/views/Home/Navbar/Laptop/index.js

front
Reza_ashrafi 3 years ago
parent 1a163bdac4
commit ff87895d3e
  1. 23
      src/views/Home/Navbar/Laptop/index.js

@ -25,6 +25,17 @@ const fontSize = {
}, },
}; };
const changeLanguage = (val) => {
if (val === "fa") {
localStorage.removeItem("language");
} else if (val === "en") {
localStorage.setItem("language", "en");
} else {
localStorage.setItem("language", "ar");
}
window.location.reload();
};
class LaptopNavbar extends Component { class LaptopNavbar extends Component {
state = {}; state = {};
@ -129,7 +140,11 @@ class LaptopNavbar extends Component {
{window.t("خروج")}{" "} {window.t("خروج")}{" "}
</MenuItem> </MenuItem>
</Menu> </Menu>
<select className="language-select"> <select
className="language-select"
onChange={(e) => changeLanguage(e.target.value)}
defaultValue={localStorage.getItem("language") || "fa"}
>
{["fa", "en", "ar"].map((lang, index) => ( {["fa", "en", "ar"].map((lang, index) => (
<option key={index}>{lang}</option> <option key={index}>{lang}</option>
))} ))}
@ -162,7 +177,11 @@ class LaptopNavbar extends Component {
</> </>
) : ( ) : (
<div className="d-flex"> <div className="d-flex">
<select className="language-select"> <select
className="language-select"
onChange={(e) => changeLanguage(e.target.value)}
defaultValue={localStorage.getItem("language") || "fa"}
>
{["fa", "en", "ar"].map((lang, index) => ( {["fa", "en", "ar"].map((lang, index) => (
<option key={index}>{lang}</option> <option key={index}>{lang}</option>
))} ))}

Loading…
Cancel
Save