l-min-components 1.0.761 → 1.0.768

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "l-min-components",
3
- "version": "1.0.761",
3
+ "version": "1.0.768",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "src/assets",
@@ -153,7 +153,7 @@ const AppMainLayout = () => {
153
153
  const currentPlan = userPlanData?.data?.current_plan;
154
154
  const planState = userPlanData?.data?.state;
155
155
 
156
- const { textSchema, setDefaultLang, findText } = useTranslation();
156
+ const { textSchema, setDefaultLang, defaultLang, findText } = useTranslation();
157
157
  // console.log(findText());
158
158
  return (
159
159
  textSchema && (
@@ -161,6 +161,7 @@ const AppMainLayout = () => {
161
161
  value={{
162
162
  textSchema,
163
163
  findText,
164
+ defaultLang,
164
165
  setDefaultLang,
165
166
  setRightComponent,
166
167
  setRightLayout,
@@ -1,5 +1,6 @@
1
1
  import React, { useCallback, CSSProperties } from "react";
2
2
  import styled from "styled-components";
3
+ import useTranslation from "../../hooks/useTranslation";
3
4
  /**
4
5
  * @param {{
5
6
  * type?: ("primary" | "secondary" | "tertiary"),
@@ -19,6 +20,8 @@ import styled from "styled-components";
19
20
  *
20
21
  */
21
22
  const ButtonComponent = (props) => {
23
+ const { textSchema, findText } = useTranslation();
24
+
22
25
  const handleClick = useCallback((e) => {
23
26
  props.onClick && props.onClick(e);
24
27
  }, []);
@@ -26,6 +29,7 @@ const ButtonComponent = (props) => {
26
29
  switch (props.type) {
27
30
  case "primary":
28
31
  return (
32
+ textSchema &&
29
33
  <Button
30
34
  disabled={props.disabled}
31
35
  onClick={handleClick}
@@ -49,7 +53,7 @@ const ButtonComponent = (props) => {
49
53
  />
50
54
  )
51
55
  )}
52
- {props.text ?? "Text"}
56
+ {findText(props.text) ?? "Text"}
53
57
  {props.icon?.right && props.icon.jsx ? (
54
58
  <props.icon.jsx
55
59
  {...{
@@ -73,6 +77,7 @@ const ButtonComponent = (props) => {
73
77
  );
74
78
  case "secondary":
75
79
  return (
80
+ textSchema &&
76
81
  <SecondaryButton
77
82
  disabled={props.disabled}
78
83
  onClick={handleClick}
@@ -96,7 +101,7 @@ const ButtonComponent = (props) => {
96
101
  />
97
102
  )
98
103
  )}
99
- {props.text ?? "Text"}
104
+ {findText(props.text) ?? "Text"}
100
105
  {props.icon?.right && props.icon.jsx ? (
101
106
  <props.icon.jsx
102
107
  {...{
@@ -143,7 +148,7 @@ const ButtonComponent = (props) => {
143
148
  />
144
149
  )
145
150
  )}
146
- {props.text ?? "Text"}
151
+ {findText(props.text) ?? "Text"}
147
152
  {props.icon?.right && props.icon.jsx ? (
148
153
  <props.icon.jsx
149
154
  {...{
@@ -167,6 +172,7 @@ const ButtonComponent = (props) => {
167
172
  );
168
173
  default:
169
174
  return (
175
+ textSchema &&
170
176
  <Button
171
177
  disabled={props.disabled}
172
178
  onClick={handleClick}
@@ -190,7 +196,7 @@ const ButtonComponent = (props) => {
190
196
  />
191
197
  )
192
198
  )}
193
- {props.text ?? "Text"}
199
+ {findText(props.text) ?? "Text"}
194
200
  {props.icon?.right && props.icon.jsx ? (
195
201
  <props.icon.jsx
196
202
  {...{
@@ -61,7 +61,7 @@ const HeaderComponent = (props) => {
61
61
  handleGetNotification,
62
62
  } = useHeader();
63
63
  const { pathname } = useLocation();
64
- const { setGeneralData, generalData, notificationMarkReadData, findText } =
64
+ const { setGeneralData, generalData, notificationMarkReadData, findText, defaultLang } =
65
65
  useContext(OutletContext);
66
66
  const [selectedAccount, setSelectedAccount] = useState();
67
67
  const { setDefaultAccount, handleSetDefaultAccount } = useHeader();
@@ -365,7 +365,7 @@ const HeaderComponent = (props) => {
365
365
  }, [notificationMarkReadData?.response]);
366
366
  const value = JSON?.parse(localStorage.getItem("defaultLang"));
367
367
  const currentFlag = value?.flag;
368
-
368
+ console.log("defaultLang", defaultLang)
369
369
  return (
370
370
  <Navbar>
371
371
  <img src={logo} alt="Learngual logo" />
@@ -1,4 +1,10 @@
1
- import React, { useState, useEffect, useRef, useCallback, useContext } from "react";
1
+ import React, {
2
+ useState,
3
+ useEffect,
4
+ useRef,
5
+ useCallback,
6
+ useContext,
7
+ } from "react";
2
8
  import ReactFlagsSelect from "react-flags-select";
3
9
  import logo from "./assets/images/logo.png";
4
10
  import { Navbar2, NavGroup2, Nav2, CountryFlagGroup2 } from "./index.styled";
@@ -8,6 +14,7 @@ import { useLocation, useNavigate } from "react-router-dom";
8
14
  import usFlag from "../../assets/images/usFlag.png";
9
15
  import koreanFlag from "../../assets/images/koreaFlag.png";
10
16
  import { OutletContext } from "..";
17
+ import useTranslation from "../../hooks/useTranslation";
11
18
 
12
19
  /**
13
20
  * @param {{
@@ -19,8 +26,8 @@ import { OutletContext } from "..";
19
26
  *
20
27
  */
21
28
  const HeaderComponentTwo = (props) => {
22
- const { setGeneralData, generalData, setDefaultLang, findText } =
23
- useContext(OutletContext);
29
+ // const { setDefaultLang, } = useTranslation();
30
+
24
31
  const [selected, setSelected] = useState("ES");
25
32
  const [isOpen, setIsOpen] = useState(false);
26
33
  const [searchResultOpen, setSearchResultOpen] = useState(false);
@@ -30,7 +37,6 @@ const HeaderComponentTwo = (props) => {
30
37
 
31
38
  const navigate = useNavigate();
32
39
  const location = useLocation();
33
- // console.log(location);
34
40
  useEffect(() => {
35
41
  setIsOpen(false);
36
42
  }, []);
@@ -115,7 +121,7 @@ const HeaderComponentTwo = (props) => {
115
121
  <li
116
122
  onClick={() => {
117
123
  setLanguageDropdown();
118
- setDefaultLang(item?.slug);
124
+ props?.setDefaultLang(item?.slug);
119
125
  localStorage.setItem("defaultLang", JSON.stringify(item));
120
126
  }}
121
127
  >
@@ -1,5 +1,7 @@
1
- import React, { useState, useEffect } from "react";
1
+ import React, { useState, useEffect, useContext } from "react";
2
2
  import { Input, Label, ErrorMsg } from "./index.styled";
3
+ import { OutletContext } from "../AppMainLayout";
4
+ import useTranslation from "../../hooks/useTranslation";
3
5
 
4
6
  /**
5
7
  * @param {{
@@ -17,6 +19,8 @@ import { Input, Label, ErrorMsg } from "./index.styled";
17
19
  const InputComponent = (props) => {
18
20
  const [value, setValue] = useState("");
19
21
  const [formErrors, setFormErrors] = useState(false);
22
+ const { textSchema, findText } = useTranslation();
23
+
20
24
 
21
25
  const validate = (e) => {
22
26
  if (!e.target.value) {
@@ -35,16 +39,17 @@ const InputComponent = (props) => {
35
39
  };
36
40
 
37
41
  return (
42
+ textSchema &&
38
43
  <div style={props.style}>
39
44
  <Label htmlFor={props.in} style={props.customLabelStyle}>
40
- {props.label}
45
+ {findText(props.label)}
41
46
  </Label>
42
47
  <Input
43
48
  type={props.inputType}
44
49
  name={props.inputName}
45
50
  value={props.value}
46
51
  id={props.inputId}
47
- placeholder={props.placeholder}
52
+ placeholder={findText(props.placeholder)}
48
53
  style={props.customInputStyle}
49
54
  disabled={props.disabled}
50
55
  hasError={props.hasError}
@@ -2,10 +2,10 @@ import React, { useCallback, useEffect, useState } from "react";
2
2
  import loadTranslations from "./utils/translation";
3
3
 
4
4
  const useTranslation = () => {
5
- const value = localStorage.getItem("defaultLang");
5
+ const value = JSON?.parse(localStorage.getItem("defaultLang"));
6
6
  const [textSchema, setTextSchema] = useState(null);
7
7
 
8
- const [defaultLang, setDefaultLang] = useState(value || "en");
8
+ const [defaultLang, setDefaultLang] = useState(value?.slug || "en");
9
9
  const findText = useCallback((str) => textSchema[str] ?? str, [textSchema]);
10
10
 
11
11
  useEffect(() => {