From d3eab07605af1ae589ab103df1fa8f4d1ff1c56c Mon Sep 17 00:00:00 2001 From: sjohn198 Date: Wed, 5 Jun 2024 08:21:39 -0700 Subject: [PATCH] switched api calls to azure --- .../react-frontend/src/Components/Table.jsx | 2 +- .../react-frontend/src/Views/AddOrders.jsx | 8 +++--- .../react-frontend/src/Views/EditProfile.jsx | 2 +- .../react-frontend/src/Views/Inventory.jsx | 6 ++--- .../react-frontend/src/Views/LoginPage.jsx | 2 +- .../react-frontend/src/Views/ManageOrders.jsx | 25 +++---------------- .../src/Views/OrderStatistics.jsx | 6 ++--- .../react-frontend/src/Views/ProductPage.jsx | 4 +-- packages/react-frontend/src/Views/Profile.jsx | 12 ++++----- .../react-frontend/src/Views/SignUpPage.jsx | 2 +- 10 files changed, 25 insertions(+), 44 deletions(-) diff --git a/packages/react-frontend/src/Components/Table.jsx b/packages/react-frontend/src/Components/Table.jsx index cff2540..e8422d7 100644 --- a/packages/react-frontend/src/Components/Table.jsx +++ b/packages/react-frontend/src/Components/Table.jsx @@ -31,7 +31,7 @@ function TableBody(props) { - + diff --git a/packages/react-frontend/src/Views/AddOrders.jsx b/packages/react-frontend/src/Views/AddOrders.jsx index 686dd61..3662160 100644 --- a/packages/react-frontend/src/Views/AddOrders.jsx +++ b/packages/react-frontend/src/Views/AddOrders.jsx @@ -76,13 +76,13 @@ function AddOrders() { } function fetchOrders() { - return fetch("http://localhost:8000/order-units", { + return fetch("safehaven307.azurewebsites.net/order-units", { headers: addAuthHeader() }); } function postOrderUnit(order) { - return fetch("http://localhost:8000/order-units", { + return fetch("safehaven307.azurewebsites.net/order-units", { method: "POST", headers: addAuthHeader({ "Content-Type": "application/json" @@ -92,7 +92,7 @@ function AddOrders() { } function deleteOrder(id) { - const uri = `http://localhost:8000/order-units/${id}`; + const uri = `safehaven307.azurewebsites.net/order-units/${id}`; return fetch(uri, { method: "DELETE", headers: addAuthHeader({ @@ -102,7 +102,7 @@ function AddOrders() { } function runPost(order_str) { - return fetch("http://localhost:8000/orders", { + return fetch("safehaven307.azurewebsites.net/orders", { method: "POST", headers: addAuthHeader({ "Content-Type": "application/json" diff --git a/packages/react-frontend/src/Views/EditProfile.jsx b/packages/react-frontend/src/Views/EditProfile.jsx index 62fe201..7ca8116 100644 --- a/packages/react-frontend/src/Views/EditProfile.jsx +++ b/packages/react-frontend/src/Views/EditProfile.jsx @@ -8,7 +8,7 @@ import { useNavigate } from "react-router-dom"; function EditProfile() { const navigate = useNavigate(); function changeProfile(profile){ - fetch("http://localhost:8000/users/profile", { + fetch("safehaven307.azurewebsites.net/users/profile", { method: "POST", headers: addAuthHeader({ "Content-Type": "application/json" diff --git a/packages/react-frontend/src/Views/Inventory.jsx b/packages/react-frontend/src/Views/Inventory.jsx index 4b84ec1..875f49d 100644 --- a/packages/react-frontend/src/Views/Inventory.jsx +++ b/packages/react-frontend/src/Views/Inventory.jsx @@ -71,7 +71,7 @@ function Inventory() { } function fetchProducts() { - const promise = fetch("http://localhost:8000/products", { + const promise = fetch("safehaven307.azurewebsites.net/products", { headers: addAuthHeader() }); return promise; @@ -79,7 +79,7 @@ function Inventory() { function postProduct(product) { console.log("posting:", product); - return fetch("http://localhost:8000/products", { + return fetch("safehaven307.azurewebsites.net/products", { method: "POST", headers: addAuthHeader({ "Content-Type": "application/json" @@ -89,7 +89,7 @@ function Inventory() { } function deleteProduct(id) { - const uri = `http://localhost:8000/products/${id}`; + const uri = `safehaven307.azurewebsites.net/products/${id}`; return fetch(uri, { method: "DELETE", headers: addAuthHeader({ diff --git a/packages/react-frontend/src/Views/LoginPage.jsx b/packages/react-frontend/src/Views/LoginPage.jsx index 840eee8..4678311 100644 --- a/packages/react-frontend/src/Views/LoginPage.jsx +++ b/packages/react-frontend/src/Views/LoginPage.jsx @@ -9,7 +9,7 @@ function Login() { const navigate = useNavigate(); function authenticateUser(user) { console.log(user); - fetch("http://localhost:8000/login", { + fetch("safehaven307.azurewebsites.net/login", { method: "POST", headers: { "Content-Type": "application/json" diff --git a/packages/react-frontend/src/Views/ManageOrders.jsx b/packages/react-frontend/src/Views/ManageOrders.jsx index a869d4e..d32eae8 100644 --- a/packages/react-frontend/src/Views/ManageOrders.jsx +++ b/packages/react-frontend/src/Views/ManageOrders.jsx @@ -42,14 +42,14 @@ function ManageOrders() { }; function fetchOrders() { - return fetch("http://localhost:8000/orders", { + return fetch("safehaven307.azurewebsites.net/orders", { headers: addAuthHeader() }); } function fetchSearch(search) { search = "search=" + search; - const uri = `http://localhost:8000/orders/?${search}`; + const uri = `safehaven307.azurewebsites.net/orders/?${search}`; console.log(uri); return fetch(uri, { headers: addAuthHeader() @@ -57,7 +57,7 @@ function ManageOrders() { } function deleteOrder(id) { - const uri = `http://localhost:8000/orders/${id}`; + const uri = `safehaven307.azurewebsites.net/orders/${id}`; return fetch(uri, { method: "DELETE", headers: addAuthHeader({ @@ -67,25 +67,6 @@ function ManageOrders() { } function searchOrder(str) { - /*let temp_orders = orders; - let match_items = []; - temp_orders = temp_orders.filter((o) => - { - let items = o["items"]; - console.log(items); - items = items.filter((i) => - { - console.log(i); - console.log(i["product"].includes(str)); - return(i["product"].includes(str)); - }); - console.log(items); - console.log(o); - if (items.length != 0){ - return true; - } - }); - console.log(temp_orders);*/ console.log(str); fetchSearch(str) diff --git a/packages/react-frontend/src/Views/OrderStatistics.jsx b/packages/react-frontend/src/Views/OrderStatistics.jsx index 6c6f74e..80cde4a 100644 --- a/packages/react-frontend/src/Views/OrderStatistics.jsx +++ b/packages/react-frontend/src/Views/OrderStatistics.jsx @@ -64,13 +64,13 @@ function Inventory() { } function fetchProducts() { - return fetch("http://localhost:8000/products", { + return fetch("safehaven307.azurewebsites.net/products", { headers: addAuthHeader() }); } function postProduct(product) { - return fetch("http://localhost:8000/products", { + return fetch("safehaven307.azurewebsites.net/products", { method: "POST", headers: addAuthHeader({ "Content-Type": "application/json" @@ -80,7 +80,7 @@ function Inventory() { } function deleteProduct(id) { - const uri = `http://localhost:8000/products/${id}`; + const uri = `safehaven307.azurewebsites.net/products/${id}`; return fetch(uri, { method: "DELETE", headers: addAuthHeader({ diff --git a/packages/react-frontend/src/Views/ProductPage.jsx b/packages/react-frontend/src/Views/ProductPage.jsx index 2565fc6..c14a34e 100644 --- a/packages/react-frontend/src/Views/ProductPage.jsx +++ b/packages/react-frontend/src/Views/ProductPage.jsx @@ -33,7 +33,7 @@ function ProductPage() { function fetchProduct(id) { console.log(`Fetching product with id: ${id}`); - return fetch(`http://localhost:8000/products/${id}`, { + return fetch(`safehaven307.azurewebsites.net/products/${id}`, { headers: addAuthHeader() }) .then((res) => { @@ -76,7 +76,7 @@ function ProductPage() { function patchProduct(product) { console.log("patching: ", product); - return fetch(`http://localhost:8000/products/${id}`, { + return fetch(`safehaven307.azurewebsites.net/products/${id}`, { method: "PATCH", headers: addAuthHeader({ "Content-Type": "application/json" diff --git a/packages/react-frontend/src/Views/Profile.jsx b/packages/react-frontend/src/Views/Profile.jsx index cf3a9d0..7f17ee1 100644 --- a/packages/react-frontend/src/Views/Profile.jsx +++ b/packages/react-frontend/src/Views/Profile.jsx @@ -13,19 +13,19 @@ function Profile() { useEffect(() => { async function getUser() { - const user_details = await axios.get(`http://localhost:8000/users`, { + const user_details = await axios.get(`safehaven307.azurewebsites.net/users`, { headers: addAuthHeader() }); const user = user_details.data; setUser(user); - const imageUrl = `http://localhost:8000/profile-picture/${user.profilePicture}`; + const imageUrl = `safehaven307.azurewebsites.net/profile-picture/${user.profilePicture}`; setProfilePicture(imageUrl); } async function fetchProfilePicture() { try { - const imageUrl = `http://localhost:8000/profile-picture/${user.profilePicture}`; + const imageUrl = `safehaven307.azurewebsites.net/profile-picture/${user.profilePicture}`; setProfilePicture(imageUrl); } catch (error) { console.error("Failed to load user profile picture", error); @@ -49,14 +49,14 @@ function Profile() { try { // Send the file to the server for processing and storage in MongoDB - const response = await axios.post("http://localhost:8000/profile-picture", formData, { + const response = await axios.post("safehaven307.azurewebsites.net/profile-picture", formData, { headers: addAuthHeader({ "Content-Type": "multipart/form-data" }) }); console.log(response); - const imageUrl = `http://localhost:8000/profile-picture/${response.data}`; + const imageUrl = `safehaven307.azurewebsites.net/profile-picture/${response.data}`; setProfilePicture(imageUrl); @@ -68,7 +68,7 @@ function Profile() { }; function deleteProfile() { - fetch("http://localhost:8000/users", { + fetch("safehaven307.azurewebsites.net/users", { method: "DELETE", headers: addAuthHeader({ "Content-Type": "application/json" diff --git a/packages/react-frontend/src/Views/SignUpPage.jsx b/packages/react-frontend/src/Views/SignUpPage.jsx index 7b4b489..869b2ad 100644 --- a/packages/react-frontend/src/Views/SignUpPage.jsx +++ b/packages/react-frontend/src/Views/SignUpPage.jsx @@ -8,7 +8,7 @@ function Signup() { const navigate = useNavigate(); function createUser(user) { console.log(user); - fetch("http://localhost:8000/users", { + fetch("safehaven307.azurewebsites.net/users", { method: "POST", headers: { "Content-Type": "application/json"