Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/Components/Dashboard/Home/HomeHeader.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import styles from "./Home.module.css";

function HomeHeader() {
const { user } = useSelector((state) => state.authReducer);

return (
<div className={styles.home__header}>
<Link to="/settings">
Expand Down
101 changes: 77 additions & 24 deletions src/Components/Dashboard/Settings/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,34 +16,34 @@ import CustomPhoneInput from "../../../common/components/CustomPhoneInput/Custom
import { API_BASE_URL } from "../../../Utils/config";
import AppLoader from "../../Generic/AppLoader";
import { isValidFullName } from "../../../Utils/utils";
import { LOGOUT } from "../../../Reducers/ActionTypes";
import { LOGOUT, SET_SESSION } from "../../../Reducers/ActionTypes";

const labels = {
email: "Email Address",
phone: "Phone Number",
full_name: "Full Name",
}
};

function Settings() {
const navigate = useNavigate();
const dispatch = useDispatch();
const [connectedModal, setConnectedModal] = useState(false);
const [changeInfo, setChangeInfo] = useState(false);
const [details, setDetails] = useState("");
const [checked, setChecked] = useState(0);
// const [checked, setChecked] = useState(0);
// const [enable2fa, setEnable2fa] = useState(false);
const [info, setinfo] = useState("");
const { user } = useSelector((state) => state.authReducer);
const [isLoading, setIsloading] = useState(false);

const [inputFields, setinputFields] = useState({
email: user.email,
phone: user.phone,
full_name: user.full_name,
email: user?.email,
phone: user?.phone,
full_name: user?.full_name,
});

useEffect(() => 0, [info]);

const allWallets = JSON.parse(localStorage.getItem("allWallets") || []);
const closeChangeInfo = () => {
setChangeInfo(false);
};
Expand All @@ -52,6 +52,9 @@ function Settings() {
setDetails(infovalue);
};

// useEffect(() => {
// console.log(user);
// }, [user]);
const validateEmail = (email) => String(email)
.toLowerCase()
.match(
Expand Down Expand Up @@ -176,21 +179,34 @@ function Settings() {
state: { user }
});
};
const check = (i) => {
if (checked !== i) {
setChecked(i);
setConnectedModal(false);
}
const check = (data) => {
localStorage.setItem("user", JSON.stringify(data));
setConnectedModal(false);
dispatch({
type: SET_SESSION,
payload: { user: data },
});
navigate("/");
};

const SignOut = () => {
const SignOutAll = () => {
dispatch({ type: LOGOUT });
localStorage.removeItem("user");
localStorage.removeItem("welcome")
localStorage.removeItem("firstImport")
localStorage.removeItem("allWallets")
navigate("/");
};

const SignOut = () => {
const wallets = [...allWallets];
const index = allWallets.findIndex(wallet => wallet?.user_info?.user_id === user?.user_id);
if (index > -1) {
wallets.splice(index, 1);
localStorage.setItem("allWallets", JSON.stringify(wallets));
localStorage.setItem("user", JSON.stringify(wallets[0]));
navigate("/");
}
};
const HandleInputChange = (field) => e => {
if (details === "email" && e.target.value.length > 64) {
return false;
Expand Down Expand Up @@ -281,18 +297,45 @@ function Settings() {
<IoIosArrowForward />
</button>
</div>

{allWallets.length > 1 && (
<div
className={styles.settings__acc__content}
onClick={() => SignOut()}
>
<div className={styles.personal__settings}>
<p>Sign Out</p>
<p>
Sign Out
<b>
{" "}
{user?.full_name}
</b>
</p>
</div>
<button>
<IoIosLogOut />
</button>
</div>
)}
<div
className={styles.settings__acc__content}
onClick={() => SignOutAll()}
>
<div className={styles.personal__settings}>
<p>
Sign Out
{allWallets.length > 1 && (
<b>
{" "}
All Accounts
</b>
)}
</p>
</div>
<button>
<IoIosLogOut />
</button>
</div>

</div>
</div>
</div>
Expand Down Expand Up @@ -324,15 +367,25 @@ function Settings() {
</Modal.Header>
<Modal.Body>
<div className={styles.modal__body__wrapper}>
<div className={styles.name__wrapper} onClick={() => check(0)}>
{/* <h6>{user?.email?.split("@")[0] + ".near"}</h6> */}
<span>{user?.wallet_id}</span>
{checked === 0 && (
<div className={styles.checked}>
<AiOutlineCheck />
{
allWallets.map((wallet) => (
<div
key={wallet?.user_info?.wallet_id}
className={styles.name__wrapper}
onClick={() => check(wallet)}
>
{/* <h6>{user?.email?.split("@")[0] + ".near"}</h6> */}
<span>{wallet?.user_info?.wallet_id}</span>
{wallet?.user_info?.user_id === user?.user_id
? (
<div className={styles.checked}>
<AiOutlineCheck />
</div>
)
: <div className={styles.unChecked} />}
</div>
)}
</div>
))
}
{/* <div className={styles.name__wrapper} onClick={() => check(1)}>
<h6>demo.near</h6>
{checked === 1 && (
Expand Down
17 changes: 16 additions & 1 deletion src/Components/Dashboard/Settings/settings.module.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions src/Components/ImportContactsDialog/ImportContactsDialog.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Dialog from "@material-ui/core/Dialog";
import Slide from "@material-ui/core/Slide";
import Typography from "@material-ui/core/Typography";
import { makeStyles } from "@material-ui/core/styles";
import React, { useEffect } from "react";
import { FcGoogle } from "react-icons/fc";
Expand Down Expand Up @@ -50,6 +51,9 @@ const useStyles = makeStyles((theme) => ({
color: "#dc3e15",
fontSize: "30px",
},
note: {
cursor: "default"
}
}));

const ImportContactsDialog = ({
Expand Down Expand Up @@ -189,6 +193,10 @@ const ImportContactsDialog = ({
className="contactDialogBack"
onClose={contacts.length > 0 ? callback : null}
>
<Typography variant="h6" className={`text-center mb-3 ${classes.note}`}>
Import your contacts to generate & share your free NFT
</Typography>

<button
className={`${classes.mainContainer} cloudsponge-launch`}
data-cloudsponge-source="gmail"
Expand All @@ -212,6 +220,7 @@ const ImportContactsDialog = ({
<IoLogoMicrosoft className={classes.microsofticon} />
<p> Connect Microsoft 365 Contacts</p>
</button>

</Dialog>
</div>
);
Expand Down
2 changes: 2 additions & 0 deletions src/Components/SignUp/CreateAnAccount/CreateAnAccount.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ const CreateAnAccount = () => {
// @ToDo
// save user details
localStorage.setItem("user", JSON.stringify(response.data));
const allWallets = JSON.parse(localStorage.getItem("allWallets")) || [];
localStorage.setItem("allWallets", JSON.stringify([...allWallets, response.data]));

// cloudsponge import on signup
localStorage.setItem("welcome", true);
Expand Down
3 changes: 2 additions & 1 deletion src/Components/SignUp/Verification/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ const Verification = () => {
// @ToDo
// save user details
localStorage.setItem("user", JSON.stringify(response.data));

const allWallets = localStorage.getItem("allWallets") || [];
localStorage.setItem("allWallets", JSON.stringify([...allWallets, JSON.stringify(response.data)]));
navigate(redirectUrl ? redirectUrl : "/");
})
.catch((error) => {
Expand Down
6 changes: 5 additions & 1 deletion src/layout/PrivateRoute.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,11 @@ const PrivateRoute = (props) => {
// @ToDo
const user = JSON.parse(localStorage.getItem("user"));
const isAuthenticated = user ? true : false;

// console.log(user);
// dispatch({
// type: "auth/set_session",
// payload: user,
// });
if (isAuthenticated) {
// save user details in redux state
dispatch({ type: "login_Successfully", payload: user.user_info });
Expand Down