From ff87895d3e963ac625240fa0425fc17ffb655125 Mon Sep 17 00:00:00 2001 From: Reza_ashrafi Date: Thu, 2 Jun 2022 17:22:03 +0430 Subject: [PATCH] update src/views/Home/Navbar/Laptop/index.js --- src/views/Home/Navbar/Laptop/index.js | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/views/Home/Navbar/Laptop/index.js b/src/views/Home/Navbar/Laptop/index.js index 1d839b3..73f1685 100644 --- a/src/views/Home/Navbar/Laptop/index.js +++ b/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 { state = {}; @@ -129,7 +140,11 @@ class LaptopNavbar extends Component { {window.t("خروج")}{" "} - changeLanguage(e.target.value)} + defaultValue={localStorage.getItem("language") || "fa"} + > {["fa", "en", "ar"].map((lang, index) => ( ))} @@ -162,7 +177,11 @@ class LaptopNavbar extends Component { ) : (
- changeLanguage(e.target.value)} + defaultValue={localStorage.getItem("language") || "fa"} + > {["fa", "en", "ar"].map((lang, index) => ( ))}