Skip to content

Commit de6cd0f

Browse files
author
Tigran Harutyunyan
committed
Merge branch 'dev' into tigran/LP-41_code_cleaning
# Conflicts: # src/Components/Dashboard/Home/RecentTransactions.jsx # src/Components/Dashboard/Home/index.jsx # src/Components/Dashboard/SendNFT/sendNft.js # src/Components/Dashboard/SendNFT/sendNft.module.css # src/Components/Dashboard/SendNFT/sendNft.module.css.map # src/Components/Dashboard/Transactions/TransactionHistory.js # src/Components/Home/index.jsx # src/Components/NFT/Detail/index.js # src/Components/SignIn/SignIn.jsx # src/Components/SignIn/SignIn.module.css # src/Components/SignUp/CreateAnAccount/CreateAnAccount.jsx # src/Components/SignUp/CreateAnAccount/CreateAnAccount.module.css # src/Components/SignUp/SignUpWith/index.jsx # src/Components/SignUp/SignUpWith/index.module.css # src/layout/PublicRoute.module.css
2 parents 49f1602 + bde0870 commit de6cd0f

File tree

10 files changed

+154
-57
lines changed

10 files changed

+154
-57
lines changed

public/favicon.ico

-313 Bytes
Binary file not shown.

src/Components/Dashboard/SendNFT/sendNft.module.scss

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,20 @@
154154
font-size: 16.68px;
155155
}
156156
}
157+
.selectAllTextContainer{
158+
display: flex;
159+
align-items: flex-start;
160+
flex-direction: column;
161+
justify-content: center;
162+
margin-left: 2vw;
163+
h6{
164+
margin: 0;
165+
padding: 0;
166+
color: #2f80ed;
167+
font-weight: 500;
168+
font-size: 16.68px;
169+
}
170+
}
157171
.icon {
158172
margin: 10px 13px 20px auto;
159173
cursor: pointer;

src/Components/SignIn/SignIn.module.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
@media screen and (max-width: 800px) {
8888
.half_container {
8989
position: absolute;
90-
top: 56vh;
90+
top: 20vh;
9191
max-width: 100%;
9292
min-height: 100vh;
9393
margin-left: 0;

src/Components/SignUp/CreateAnAccount/CreateAnAccount.jsx

Lines changed: 10 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ import { IoIosArrowForward } from "react-icons/io";
77
import { useNavigate, useParams, useLocation } from "react-router-dom";
88
import { toast } from "react-toastify";
99
import TextFieldComponent from "../../../Assets/FrequentlUsedComponents/TextFieldComponent";
10-
import { mapUserSession } from "../../../Utils/utils";
10+
import { isValidFullName, mapUserSession } from "../../../Utils/utils";
1111
import AppLoader from "../../Generic/AppLoader";
12-
13-
import styles from "./CreateAnAccount.module.scss";
12+
import TooltipButton from "../../../common/components/TooltipButton";
1413
import { actionSetSession } from "../../../Store/Auth/actions";
1514
import { createUserRequest } from "../../../api/user";
15+
import styles from "./CreateAnAccount.module.scss";
1616

1717
const CreateAnAccount = () => {
1818
const dispatch = useDispatch();
@@ -62,7 +62,7 @@ const CreateAnAccount = () => {
6262

6363
useEffect(() => {
6464
if (signupEmail === "" && signupPhone === "") {
65-
HandleClick();
65+
// HandleClick();
6666
}
6767
}, [info]);
6868

@@ -82,12 +82,6 @@ const CreateAnAccount = () => {
8282

8383
// HandleClick for cancel button
8484

85-
// HandleLogin
86-
const HandleLogin = () => {
87-
// window.open(`${API_BASE_URL}/near_login/login.html`, "_self");
88-
navigate("/signin");
89-
};
90-
9185
// HandleFocus for input
9286
const HandleFocus = (ClickedInput) => {
9387
setinfo(ClickedInput);
@@ -106,8 +100,8 @@ const CreateAnAccount = () => {
106100
const onAccountChange = (e) => {
107101
const { value } = e.target;
108102

109-
if (!value || doesAccountStringHaveValidCharacters(value.toLowerCase())) {
110-
if (value.length <= 56) setAccountId(value.toLowerCase());
103+
if (!value || doesAccountStringHaveValidCharacters(value)) {
104+
if (value.length <= 56) setAccountId(value);
111105
}
112106

113107
// setDetails((preValue) => {
@@ -172,16 +166,11 @@ const CreateAnAccount = () => {
172166
});
173167
};
174168

175-
const isFullNameValid = (fullName) => {
176-
const format = /[`!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?~]/;
177-
return format.test(fullName);
178-
};
179-
180169
const isFormValid = () => {
181170
let returnVal = true;
182171
if (fullName === "") {
183172
returnVal = false;
184-
} else if (isFullNameValid(fullName)) {
173+
} else if (isValidFullName(fullName)) {
185174
returnVal = false;
186175
} else if (
187176
accountId === ""
@@ -310,16 +299,9 @@ const CreateAnAccount = () => {
310299

311300
{!accId && (
312301
<>
313-
<h6 className={styles.link}>Already have Near Account?</h6>
314-
315-
<button className={styles.primary_button} onClick={HandleLogin}>
316-
Launch
317-
{
318-
<span>
319-
<IoIosArrowForward />
320-
</span>
321-
}
322-
</button>
302+
<h6 className={styles.link}>Already have a NearApps ID?</h6>
303+
304+
<TooltipButton tooltipText="Coming soon..." buttonText="Login with NEAR" buttonStyle={`${styles.comingSoonBtn}`} />
323305
</>
324306
)}
325307
</div>

src/Components/SignUp/Verification/index.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,9 @@ const Verification = () => {
128128

129129
<div className={styles.childContainer}>
130130
<p>
131-
We&apos;ve sent a 6-digit verification code on your
131+
Check your&nbsp;
132132
{otp_medium}
133-
.
133+
&nbsp;and enter your 6 Digit One-time passcode.
134134
</p>
135135

136136
<div className={styles.verficationContainer}>

src/Pages/SignUp.jsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
import React from 'react'
2+
import useRedirectIfUserLoggedIn from '../common/hooks/useRedirectIfUserLoggedIn';
23
import SignUpWith from '../Components/SignUp/SignUpWith';
34

4-
const SignUp = () => (
5-
<div>
6-
<SignUpWith />
7-
</div>
8-
)
5+
const SignUp = () => {
6+
useRedirectIfUserLoggedIn();
7+
return (
8+
<div>
9+
<SignUpWith />
10+
</div>
11+
)
12+
}
913

1014
export default SignUp;

src/common/components/ContactPopup.js

Lines changed: 78 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,10 @@ function ContactPopup({
6262
};
6363

6464
useEffect(() => {
65-
setFilteredData(contacts);
66-
checkAllContacts(contacts);
65+
if (contacts && !isLoading) {
66+
setFilteredData(contacts);
67+
checkAllContacts(contacts);
68+
}
6769
}, [contacts, isLoading]);
6870

6971
// get contacts
@@ -112,7 +114,7 @@ function ContactPopup({
112114
.finally(() => {
113115
setIsloading(false);
114116
});
115-
}, 1500)
117+
}, 0);
116118
}, [show]);
117119

118120
const getPrimaryEmail = (contact) => {
@@ -154,9 +156,52 @@ function ContactPopup({
154156

155157
const importContact = (data) => {
156158
if (data) {
157-
checkAllContacts(data);
158-
setimportContactDialog(false);
159-
setFilteredData(data);
159+
axios
160+
.get(`${API_BASE_URL}/contacts/list/${user?.user_id}`)
161+
.then((response) => {
162+
// save user details
163+
// before saving contacts to the reducer make all the emails unique
164+
const {
165+
data: { data: contacts = [] }
166+
} = response;
167+
const uniqueEmails = [];
168+
// console.log(`Got ${contacts.length} contacts from server`);
169+
const uniqueContacts = contacts.filter((contactObj) => {
170+
if (contactObj.email && contactObj.email.length) {
171+
let emailExists = false;
172+
for (let i = 0; i < contactObj.email.length; i++) {
173+
const emailObj = { ...contactObj.email[i] };
174+
if (
175+
emailObj && emailObj.address && uniqueEmails.indexOf(emailObj.address) !== -1
176+
) {
177+
emailExists = true;
178+
break;
179+
} else {
180+
uniqueEmails.push(emailObj.address);
181+
}
182+
}
183+
if (emailExists) {
184+
return false;
185+
}
186+
return true;
187+
}
188+
return true;
189+
});
190+
checkAllContacts(uniqueContacts);
191+
setimportContactDialog(false);
192+
setFilteredData(uniqueContacts);
193+
dispatch({ type: "update_contacts", payload: uniqueContacts });
194+
})
195+
.catch((error) => {
196+
if (error?.response?.data) {
197+
toast.error(error.response.data.message);
198+
} else {
199+
toast.error('Failed to Load Contacts');
200+
}
201+
})
202+
.finally(() => {
203+
setIsloading(false);
204+
});
160205
}
161206
};
162207

@@ -299,23 +344,36 @@ function ContactPopup({
299344
Import
300345
</button>
301346
</div>
302-
<div className={styles.search__wrapper}>
303-
<button
304-
className={styles.import__button}
305-
onClick={() => {
306-
if (selectedContacts.length === contacts.length) {
307-
setSelectedContacts([])
308-
} else {
309-
setSelectedContacts(contacts)
310-
}
311-
}}
312-
>
313-
{selectedContacts.length === contacts.length ? 'Unselect All' : 'Select All'}
314-
</button>
315-
</div>
347+
316348
<div className={styles.data__wrapper}>
317349
<div>{isLoading && <LoaderIconBlue />}</div>
318350

351+
{filteredData.length > 0 && (
352+
<div className={styles.data_row_container}>
353+
{/* TEXT */}
354+
<div className={styles.selectAllTextContainer}>
355+
<h6>{selectedContacts.length === contacts.length ? 'Unselect All' : 'Select All'}</h6>
356+
</div>
357+
{/* ICONS */}
358+
<div
359+
className={styles.icon}
360+
onClick={() => {
361+
if (selectedContacts.length === contacts.length) {
362+
setSelectedContacts([])
363+
} else {
364+
setSelectedContacts(contacts)
365+
}
366+
}}
367+
>
368+
{selectedContacts.length === contacts.length ? (
369+
<BsCheckCircleFill className={styles.checked} />
370+
) : (
371+
<GoPrimitiveDot className={styles.unchecked} />
372+
)}
373+
</div>
374+
</div>
375+
)}
376+
319377
{filteredData.map((contact) => (
320378
<div className={styles.data_row_container} key={nanoid()}>
321379
{/* TEXT */}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import React from 'react';
2+
import { OverlayTrigger, Tooltip } from 'react-bootstrap';
3+
// props -> TooltipText, buttonText, buttonstyle
4+
5+
function TooltipButton({ tooltipText, buttonStyle, buttonText }) {
6+
return (
7+
<OverlayTrigger placement="top" overlay={<Tooltip>{tooltipText}</Tooltip>}>
8+
{({ ref, ...triggerHandler }) => (
9+
<button
10+
{...triggerHandler}
11+
className={buttonStyle}
12+
>
13+
<span ref={ref}>{buttonText}</span>
14+
</button>
15+
)}
16+
</OverlayTrigger>
17+
);
18+
}
19+
20+
export default TooltipButton;
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { useEffect } from 'react';
2+
import { useSelector } from 'react-redux';
3+
import { useLocation, useNavigate } from 'react-router-dom';
4+
5+
export default function useRedirectIfUserLoggedIn() {
6+
const { user } = useSelector((state) => state.authReducer);
7+
const navigate = useNavigate();
8+
const location = useLocation();
9+
10+
useEffect(() => {
11+
if (user) {
12+
if (/(\/signup)(\/)?$/.test(location.pathname)) {
13+
navigate('/signup/create-account', { replace: true });
14+
} else {
15+
navigate('/', { replace: true });
16+
}
17+
}
18+
}, [user]);
19+
}

src/layout/PublicRoute.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ import Logo from "../Assets/Images/prime-lab-logo.png";
66

77
const Layout = ({ children }) => (
88
<div className={styles.background}>
9+
<img src={Img} alt="Vector Graphics" className={styles.vector} />
910
<Link to="/">
1011
<img src={Logo} alt="Brand Logo" className={styles.logo} />
1112
</Link>
12-
<img src={Img} alt="Vector Graphics" className={styles.vector} />
1313
{children}
1414
</div>
1515
);

0 commit comments

Comments
 (0)