Skip to content

Commit

Permalink
removed every single instance of localhost:5000 from the webap
Browse files Browse the repository at this point in the history
  • Loading branch information
ludvij committed May 3, 2022
1 parent efb7f9f commit fefc1c3
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 16 deletions.
8 changes: 4 additions & 4 deletions webapp/src/api/api.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import {Order} from "../shared/shareddtypes";

export async function getOrdersForUser(webId: string): Promise<Order[]> {
const apiEndPoint = process.env.REACT_APP_API_URI || "http://localhost:5000";
const apiEndPoint = process.env.REACT_APP_API_URI;
let response = await fetch(apiEndPoint + "/order/list/user/" + encodeURIComponent(webId));
return response.json();
}

export async function getOrders(): Promise<Order[]> {
const apiEndPoint = process.env.REACT_APP_API_URI || "http://localhost:5000";
const apiEndPoint = process.env.REACT_APP_API_URI;
let response = await fetch(apiEndPoint + "/order/list");
return response.json();
}

export async function deleteProduct(id: string): Promise<boolean> {
const apiEndPoint = process.env.REACT_APP_API_URI || 'http://localhost:5000/api';
const apiEndPoint = process.env.REACT_APP_API_URI;
let response = await fetch(apiEndPoint + '/product/' + id, {
method: 'DELETE',
headers: {'Content-Type': 'application/json', 'auth-token': localStorage.getItem('token') as string},
Expand All @@ -23,7 +23,7 @@ export async function deleteProduct(id: string): Promise<boolean> {
}

export async function deleteOrder(id: string): Promise<boolean> {
const apiEndPoint = process.env.REACT_APP_API_URI || 'http://localhost:5000/api';
const apiEndPoint = process.env.REACT_APP_API_URI;
let response = await fetch(apiEndPoint + '/order/' + id, {
method: 'DELETE',
headers: {'Content-Type': 'application/json', 'auth-token': localStorage.getItem('token') as string},
Expand Down
4 changes: 2 additions & 2 deletions webapp/src/components/checkout/Form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ const Form = (props: Props) => {
const [contactData, setContactData] = useState<Address[]>([]);

const {session} = useSession()

const apiEndPoint = process.env.REACT_APP_API_URI;
useEffect(() => {
if(session.info.webId) {
axios.get((process.env.REACT_APP_API_URI || "http://localhost:5000") + "/solid/fetch/" + encrypt(session.info.webId)).then(
axios.get(apiEndPoint + "/solid/fetch/" + encrypt(session.info.webId)).then(
response => {
localStorage.setItem("fn", response.data.fn)
setContactData(response.data.addresses)
Expand Down
2 changes: 1 addition & 1 deletion webapp/src/helpers/authService.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import axios from "axios";

const API_URL = process.env.REACT_APP_API_URI || "http://localhost:5000";
const API_URL = process.env.REACT_APP_API_URI;

class AuthService {
login(username: string, password: string) {
Expand Down
2 changes: 1 addition & 1 deletion webapp/src/helpers/getData.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const getProducts = async () => {
const apiEndPoint = process.env.REACT_APP_API_URI || "http://localhost:5000";
const apiEndPoint = process.env.REACT_APP_API_URI;
let response = await fetch(apiEndPoint + "/product/list");
return response.json();
}
Expand Down
2 changes: 1 addition & 1 deletion webapp/src/helpers/postData.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {OrderAdd} from "../shared/shareddtypes";

const postData = async (order: OrderAdd) => {
const apiEndPoint = process.env.REACT_APP_API_URI || "http://localhost:5000";
const apiEndPoint = process.env.REACT_APP_API_URI;

let response = await fetch(apiEndPoint + '/order/add', {
method: 'POST',
Expand Down
5 changes: 3 additions & 2 deletions webapp/src/hooks/usePodData.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {useEffect, useState} from "react";
import axios from "axios";
import {SessionInfo} from "@inrupt/solid-ui-react/dist/src/hooks/useSession";
import { appendFile } from "fs";

function encrypt(webId: string): string {
return encodeURIComponent(webId)
Expand All @@ -11,10 +12,10 @@ export const usePodData = (session: SessionInfo["session"]) => {
fn: "",
addresses: []
})

const apiEndPoint = process.env.REACT_APP_API_URI;
useEffect(() => {
if(session.info.webId) {
axios.get((process.env.REACT_APP_API_URI || "http://localhost:5000") + "/solid/fetch/" + encrypt(session.info.webId)).then(
axios.get(apiEndPoint + "/solid/fetch/" + encrypt(session.info.webId)).then(
response => {
setContactData({
fn: response.data.fn,
Expand Down
4 changes: 2 additions & 2 deletions webapp/src/hooks/useShipping.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ export const useShipping = (address: string) => {
distance: 0.0,
price: 0.0,
})

const apiEndPoint = process.env.REACT_APP_API_URI;
useEffect(() => {
if(address.length !== 0) {
axios.post((process.env.REACT_APP_API_URI || "http://localhost:5000") + "/geocode", parseAddress(address))
axios.post(apiEndPoint + "/geocode", parseAddress(address))
.then(res => {
setShipping({
distance: res.data.distance,
Expand Down
3 changes: 2 additions & 1 deletion webapp/src/pages/Checkout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ const Checkout = () => {
distance: 0.0,
price: 0.0,
})
const apiEndPoint = process.env.REACT_APP_API_URI;

useEffect(() => {
axios.post((process.env.REACT_APP_API_URI || "http://localhost:5000") + "/geocode",
axios.post(apiEndPoint + "/geocode",
{
"street": address[3],
"city": address[2],
Expand Down
2 changes: 1 addition & 1 deletion webapp/src/pages/DetailsView/DetailsView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const DetailsView: React.FC = () => {
const [item, setItem] = useState<Product>()

useEffect(() => {
const apiEndPoint = process.env.REACT_APP_API_URI || "http://localhost:5000";
const apiEndPoint = process.env.REACT_APP_API_URI;
Axios.get(apiEndPoint + '/product/details/' + _id).then(
response => {
const product = response.data
Expand Down
2 changes: 1 addition & 1 deletion webapp/src/pages/admin/AdminPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {Footer} from "../../components/footer/Footer";


const AdminPanel = () => {
const apiEndPoint = process.env.REACT_APP_API_URI || "http://localhost:5000";
const apiEndPoint = process.env.REACT_APP_API_URI;
const {token} = useUser()
const [orders, setOrders] = useState<Order[]>([]);
const [users, setUsers] = useState<string[]>([])
Expand Down

0 comments on commit fefc1c3

Please sign in to comment.