From 104d5d78c71413157e55ac4218cac8760b2f7991 Mon Sep 17 00:00:00 2001 From: Ansh101112 Date: Sat, 22 Jun 2024 19:36:14 +0530 Subject: [PATCH] server changed --- src/pages/Login.js | 14 +++++++------- src/pages/Notification.js | 2 +- src/pages/QR.js | 4 ++-- src/pages/Settings.js | 13 ++++++++----- src/pages/Signup.js | 2 +- src/settings/AccountSettings.js | 2 +- 6 files changed, 20 insertions(+), 17 deletions(-) diff --git a/src/pages/Login.js b/src/pages/Login.js index a020697..039d436 100644 --- a/src/pages/Login.js +++ b/src/pages/Login.js @@ -36,10 +36,13 @@ const Login = () => { if (Object.keys(newErrors).length === 0) { setLoading(true); try { - const response = await axios.post("https://smartserver-production.up.railway.app/login", { - email, - password, - }); + const response = await axios.post( + "https://smartserver-scbe.onrender.com/login", + { + email, + password, + } + ); if (response && response.data.success) { localStorage.setItem("isLoggedIn", "true"); @@ -47,13 +50,11 @@ const Login = () => { // Decode the token to get the user role - const tokenPayload = JSON.parse( atob(response.data.token.split(".")[1]) ); const userRole = tokenPayload.role; - // Store user role in localStorage localStorage.setItem( "currentUser", @@ -87,7 +88,6 @@ const Login = () => { navigate("/"); } }, 2000); - } } catch (error) { if (error.response) { diff --git a/src/pages/Notification.js b/src/pages/Notification.js index 7aa3459..09015a7 100644 --- a/src/pages/Notification.js +++ b/src/pages/Notification.js @@ -15,7 +15,7 @@ const NotificationSettings = () => { try { const token = localStorage.getItem("token"); const response = await fetch( - "https://smartserver-production.up.railway.app/update-notification", + "https://smartserver-scbe.onrender.com/update-notification", { method: "PUT", headers: { diff --git a/src/pages/QR.js b/src/pages/QR.js index a1bbf29..48b835c 100644 --- a/src/pages/QR.js +++ b/src/pages/QR.js @@ -80,13 +80,13 @@ const QRCodeVerification = () => { setIsScannerOpen(false); try { const response = await axios.post( - `http://localhost:6352/scan-product`, + `https://smartserver-scbe.onrender.com/scan-product`, { barcode: data } ); setProductInfo(response.data.product); // Save the product information to the database if not already present await axios.post( - `http://localhost:6352/add-product`, + `https://smartserver-scbe.onrender.com/add-product`, response.data.product ); } catch (err) { diff --git a/src/pages/Settings.js b/src/pages/Settings.js index 1516490..ea16a21 100644 --- a/src/pages/Settings.js +++ b/src/pages/Settings.js @@ -29,11 +29,14 @@ const Settings = () => { "Are you sure you want to delete your account permanently?" ); if (confirmation) { - const response = await axios.delete("https://smartserver-production.up.railway.app/delete", { - headers: { - Authorization: `Bearer ${localStorage.getItem("token")}`, - }, - }); + const response = await axios.delete( + "https://smartserver-scbe.onrender.com/delete", + { + headers: { + Authorization: `Bearer ${localStorage.getItem("token")}`, + }, + } + ); if (response.status === 200) { setTimeout(() => { diff --git a/src/pages/Signup.js b/src/pages/Signup.js index 0ffa9dd..3ea52e7 100644 --- a/src/pages/Signup.js +++ b/src/pages/Signup.js @@ -52,7 +52,7 @@ const SignUp = () => { setLoading(true); try { const response = await axios.post( - "https://smartserver-production.up.railway.app/signup", + "https://smartserver-scbe.onrender.com/signup", { name: username, email, diff --git a/src/settings/AccountSettings.js b/src/settings/AccountSettings.js index 0a75418..07ebd5d 100644 --- a/src/settings/AccountSettings.js +++ b/src/settings/AccountSettings.js @@ -34,7 +34,7 @@ const AccountSettings = () => { try { const token = localStorage.getItem("token"); const response = await axios.put( - "https://smartserver-production.up.railway.app/settings/account", + "https://smartserver-scbe.onrender.com/settings/account", { email, password,