diff --git a/Frontend/index.html b/Frontend/index.html index 16afac1..42b9240 100644 --- a/Frontend/index.html +++ b/Frontend/index.html @@ -17,6 +17,7 @@
+
@@ -90,4 +91,4 @@ - \ No newline at end of file + diff --git a/Frontend/package.json b/Frontend/package.json index 0ed73fc..23c0522 100644 --- a/Frontend/package.json +++ b/Frontend/package.json @@ -14,10 +14,14 @@ "@emotion/styled": "^11.11.5", "@mui/icons-material": "^5.15.18", "@mui/material": "^5.15.18", + "@react-oauth/google": "^0.12.1", "axios": "^1.5.0", "fuse.js": "^7.0.0", + "gapi-script": "^1.2.0", + "jwt-decode": "^4.0.0", "react": "^18.2.0", "react-dom": "^18.2.0", + "react-google-login": "^5.2.2", "react-google-recaptcha": "^3.1.0", "react-hot-toast": "^2.4.1", "react-icons": "^5.2.1", diff --git a/Frontend/src/Pages/Profile.jsx b/Frontend/src/Pages/Profile.jsx index 562ea03..ac2557f 100644 --- a/Frontend/src/Pages/Profile.jsx +++ b/Frontend/src/Pages/Profile.jsx @@ -7,13 +7,15 @@ import RemoveRedEyeIcon from "@mui/icons-material/RemoveRedEye"; import VisibilityOffIcon from "@mui/icons-material/VisibilityOff" import { FormLoader } from "../Components/Loader"; import convertToBase64 from "./convertToBase64"; +import {GoogleOAuthProvider, GoogleLogin } from "@react-oauth/google"; +import {jwtDecode} from "jwt-decode"; // components import toast from 'react-hot-toast'; import Error from "../Components/Error"; import UserProfile from "./UserProfile"; import { useCart } from "../Components/CartContext"; -import ".././CSS/Profile.css"; +import "../CSS/Profile.css"; import Reg from "/reg.png"; const Profile = () => { @@ -34,7 +36,18 @@ const Profile = () => { const backendUrl = "https://ecommerce-backend-0wr7.onrender.com/"; const [file, setFile] = useState(null); + +const responseMessage = (credentialResponse) => { + const credentialDecoded = jwtDecode(credentialResponse.credential); + console.log("Google Login Success:", credentialDecoded); +navigate("/home"); + }; + const errorMessage = (error) => { + + console.log(error); + console.log("Failed to login"); + }; useEffect(() => { const token = localStorage.getItem("token"); const userData = localStorage.getItem("userData"); @@ -207,7 +220,12 @@ const Profile = () => {

{isLogin ? "Login" : "Sign Up"}

+ {isLogin ? ( +
{ - +
+ +
+ ) : (
@@ -311,6 +341,7 @@ const Profile = () => { : "Already have an account? Login"}
+
diff --git a/Frontend/src/main.jsx b/Frontend/src/main.jsx index 9f7f4a9..08d6ad8 100644 --- a/Frontend/src/main.jsx +++ b/Frontend/src/main.jsx @@ -7,11 +7,13 @@ import FeedbackButton from "./Components/Feedbtn"; ReactDOM.createRoot(document.getElementById("root")).render( + + );