Skip to content

Commit 012706e

Browse files
authored
Merge pull request #75 from iranpsc/fix/package
fix some bugs in url
2 parents 06268c6 + 34c0d2e commit 012706e

2 files changed

Lines changed: 23 additions & 33 deletions

File tree

src/layouts/menu/BtnsMenu.jsx

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useState, useEffect,useContext } from "react";
1+
import React, { useState, useEffect, useContext } from "react";
22
import styled from "styled-components";
33
import { getFieldTranslationByNames } from "../../services/Utility";
44
import AccountSecurityIcon from "../../assets/svg/accountSecurity.svg";
@@ -18,10 +18,9 @@ import Tippy from "@tippyjs/react";
1818
import "tippy.js/animations/scale.css";
1919
import { useTranslation } from "react-i18next";
2020
import { UserContext } from "../../services/reducers/UserContext";
21-
const Container=styled.div`
22-
height: 100vh;
23-
`
24-
;
21+
const Container = styled.div`
22+
height: 100vh;
23+
`;
2524
const Btn = styled.button`
2625
display: flex;
2726
width: 100%;
@@ -162,27 +161,29 @@ const BtnsMenu = () => {
162161
const { isOpen } = useMenuContext();
163162
const navigate = useNavigate();
164163
const location = useLocation();
165-
const [selectedItem, setSelectedItem] = useState(null);
164+
const [selectedItem, setSelectedItem] = useState(null);
166165
const lang = useTranslation();
167-
const [user] = useContext(UserContext);
166+
const [user] = useContext(UserContext);
168167
useEffect(() => {
169168
const currentItem = menuItems.find(
170-
(item) => `/metaverse/${item.navigate}` === location.pathname
169+
(item) => `/metaverse/${item.navigate}` === location.pathname,
171170
);
172171
if (currentItem) {
173172
setSelectedItem(currentItem.translationId);
174173
} else {
175-
setSelectedItem(null);
174+
setSelectedItem(null);
176175
}
177176
}, [location.pathname]);
178-
179-
const handleClick = (item) => {
177+
const handleClick = (item) => {
180178
if (!item.navigate) return;
181179

182180
const targetPath = `/metaverse/${item.navigate}`;
183181

182+
if (location.pathname.startsWith(targetPath)) {
183+
return;
184+
}
184185

185-
setSelectedItem(item.translationId);
186+
setSelectedItem(item.translationId);
186187
navigate(targetPath);
187188
};
188189

@@ -232,7 +233,7 @@ const BtnsMenu = () => {
232233
</Btn>
233234
</Tippy>
234235
))}
235-
</Container>
236+
</Container>
236237
);
237238
};
238239

src/pages/Verification/Tabs/identity-tab/UploadCards.jsx

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { HiOutlineTrash } from "react-icons/hi";
22
import styled from "styled-components";
33
import { useState, useEffect } from "react";
44
import { getFieldTranslationByNames } from "../../../../services/Utility";
5-
import DOMPurify from "dompurify";
65

76
const Container = styled.div`
87
display: flex;
@@ -22,18 +21,6 @@ const NationCard = styled.div`
2221
}
2322
`;
2423

25-
const BankCard = styled.div`
26-
width: 240px;
27-
@media (min-width: 1500px) {
28-
width: 185px;
29-
}
30-
@media (min-width: 1920px) {
31-
width: 240px;
32-
}
33-
input {
34-
opacity: 0;
35-
}
36-
`;
3724

3825
const Image = styled.div`
3926
position: relative;
@@ -107,7 +94,7 @@ const UploadCards = ({ setImageError, setNationImageURL }) => {
10794
const [nationImage, setNationImage] = useState(null);
10895
const [imageError, setImageErrorState] = useState(false); // State for image upload error
10996
const [previewUrl, setPreviewUrl] = useState(null);
110-
useEffect(() => {
97+
useEffect(() => {
11198
if (!nationImage) {
11299
setPreviewUrl(null);
113100
return;
@@ -120,21 +107,23 @@ const UploadCards = ({ setImageError, setNationImageURL }) => {
120107
URL.revokeObjectURL(url);
121108
};
122109
}, [nationImage]);
110+
123111
const handleNationImageChange = (e) => {
124112
const file = e.target.files && e.target.files[0];
125-
if (file) {
113+
114+
if (file && file.type.startsWith("image/")) {
126115
setNationImage(file);
127116
setNationImageURL(file);
128-
setImageErrorState(false); // Clear the error when a file is selected
117+
setImageErrorState(false);
129118
} else {
130-
setImageErrorState(true); // Set the error if no file is selected
119+
setImageErrorState(true);
120+
if (file) alert("Please upload a valid image file.");
131121
}
132122
};
133-
134123
const handleDeleteClick = () => {
135124
setNationImage(null);
136125
setNationImageURL(null);
137-
setImageErrorState(true); // Set the error when the image is deleted
126+
setImageErrorState(true);
138127
};
139128

140129
return (
@@ -161,7 +150,7 @@ const UploadCards = ({ setImageError, setNationImageURL }) => {
161150
// codeql[js/xss-through-dom]: previewUrl is safe (from File API / trusted source)
162151
}
163152

164-
<img src={previewUrl} alt="nation card" />
153+
<img src={previewUrl || ""} alt="nation card" />
165154
</Image>
166155
)}
167156
</UploadWrapper>

0 commit comments

Comments
 (0)