Skip to content

Commit

Permalink
switched api calls to azure
Browse files Browse the repository at this point in the history
  • Loading branch information
sjohn198 committed Jun 5, 2024
1 parent 6cc1a69 commit d3eab07
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 44 deletions.
2 changes: 1 addition & 1 deletion packages/react-frontend/src/Components/Table.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function TableBody(props) {
<button onClick={() => props.removeProduct(index)}>Delete</button>
</td>
<td>
<a href={`http://localhost:5173/product/${row._id}`}>
<a href={`safehaven307.azurewebsites.net/product/${row._id}`}>
<button>Edit</button>
</a>
</td>
Expand Down
8 changes: 4 additions & 4 deletions packages/react-frontend/src/Views/AddOrders.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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({
Expand All @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion packages/react-frontend/src/Views/EditProfile.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 3 additions & 3 deletions packages/react-frontend/src/Views/Inventory.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,15 @@ function Inventory() {
}

function fetchProducts() {
const promise = fetch("http://localhost:8000/products", {
const promise = fetch("safehaven307.azurewebsites.net/products", {
headers: addAuthHeader()
});
return promise;
}

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"
Expand All @@ -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({
Expand Down
2 changes: 1 addition & 1 deletion packages/react-frontend/src/Views/LoginPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
25 changes: 3 additions & 22 deletions packages/react-frontend/src/Views/ManageOrders.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,22 @@ 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()
});
}

function deleteOrder(id) {
const uri = `http://localhost:8000/orders/${id}`;
const uri = `safehaven307.azurewebsites.net/orders/${id}`;
return fetch(uri, {
method: "DELETE",
headers: addAuthHeader({
Expand All @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions packages/react-frontend/src/Views/OrderStatistics.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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({
Expand Down
4 changes: 2 additions & 2 deletions packages/react-frontend/src/Views/ProductPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down Expand Up @@ -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"
Expand Down
12 changes: 6 additions & 6 deletions packages/react-frontend/src/Views/Profile.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);

Expand All @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion packages/react-frontend/src/Views/SignUpPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit d3eab07

Please sign in to comment.