@banch0u/core-project-test-repository 2.1.16 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
2
  import React, { useEffect, useState, useRef } from "react";
3
- import { Badge, Dropdown, Tooltip, Modal, Form, Input } from "antd";
3
+ import { Badge, Dropdown, Tooltip, Modal, Form, Input, Select as AntdSelect } from "antd";
4
4
  import { SunOutlined } from "@ant-design/icons";
5
5
  import style from "./index.module.scss";
6
6
  import { useDispatch, useSelector } from "react-redux";
@@ -11,10 +11,14 @@ import NotificationDropdown from "../NotificationDropdown";
11
11
  import { Link, useNavigate } from "react-router-dom";
12
12
  import { LOGIN_PATH } from "../../utils/path";
13
13
  import Button from "../Button";
14
+ import Select from "../Select";
15
+ var Option = AntdSelect.Option;
16
+ import { useLang } from "../../hooks/useLang";
14
17
  var ProfileOptions = function ProfileOptions() {
15
18
  var _profileInfo$name;
16
19
  var dispatch = useDispatch();
17
20
  var navigate = useNavigate();
21
+ var lang = useLang();
18
22
  var profileInfo = useSelector(function (state) {
19
23
  return state.auth.profileInfo;
20
24
  });
@@ -145,7 +149,23 @@ var ProfileOptions = function ProfileOptions() {
145
149
 
146
150
  return /*#__PURE__*/React.createElement("div", {
147
151
  className: style.profile
148
- }, /*#__PURE__*/React.createElement(Dropdown, {
152
+ }, /*#__PURE__*/React.createElement(Select, {
153
+ className: style.lang_select,
154
+ popupClassName: style.lang_select_dropdown,
155
+ suffixIcon: null,
156
+ allowClear: false,
157
+ showSearch: false,
158
+ onChange: function onChange(val) {
159
+ localStorage.setItem("lang", val);
160
+ },
161
+ value: lang
162
+ }, /*#__PURE__*/React.createElement(Option, {
163
+ value: "az"
164
+ }, "AZ"), /*#__PURE__*/React.createElement(Option, {
165
+ value: "en"
166
+ }, "EN"), /*#__PURE__*/React.createElement(Option, {
167
+ value: "ru"
168
+ }, "RU")), /*#__PURE__*/React.createElement(Dropdown, {
149
169
  overlay: /*#__PURE__*/React.createElement(NotificationDropdown, {
150
170
  size: size,
151
171
  page: page,
@@ -0,0 +1,36 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
+ import { useEffect, useState } from "react";
3
+ var LANG_KEY = "lang";
4
+ var DEFAULT_LANG = "az";
5
+ var getLang = function getLang() {
6
+ return localStorage.getItem(LANG_KEY) || DEFAULT_LANG;
7
+ };
8
+ export function useLang() {
9
+ var _useState = useState(getLang),
10
+ _useState2 = _slicedToArray(_useState, 2),
11
+ lang = _useState2[0],
12
+ setLang = _useState2[1];
13
+ useEffect(function () {
14
+ setLang(getLang());
15
+ var onStorage = function onStorage(e) {
16
+ if (e.key === LANG_KEY) setLang(e.newValue || DEFAULT_LANG);
17
+ };
18
+ window.addEventListener("storage", onStorage);
19
+ var origSetItem = localStorage.setItem.bind(localStorage);
20
+ var origRemoveItem = localStorage.removeItem.bind(localStorage);
21
+ localStorage.setItem = function (key, value) {
22
+ origSetItem(key, value);
23
+ if (key === LANG_KEY) setLang(value || DEFAULT_LANG);
24
+ };
25
+ localStorage.removeItem = function (key) {
26
+ origRemoveItem(key);
27
+ if (key === LANG_KEY) setLang(DEFAULT_LANG);
28
+ };
29
+ return function () {
30
+ window.removeEventListener("storage", onStorage);
31
+ localStorage.setItem = origSetItem;
32
+ localStorage.removeItem = origRemoveItem;
33
+ };
34
+ }, []);
35
+ return lang;
36
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@banch0u/core-project-test-repository",
3
- "version": "2.1.16",
3
+ "version": "2.2.0",
4
4
  "description": "Shared core features for all projects",
5
5
  "main": "dist/index.js",
6
6
  "files": [