deleted protected routes

This commit is contained in:
Joshua Hsueh 2021-04-10 13:33:33 -04:00
commit 100f2f815f
8 changed files with 20 additions and 12 deletions

1
.env Normal file
View File

@ -0,0 +1 @@
REACT_APP_API_ENDPOINT=http://localhost:8080/api

View File

@ -24,8 +24,6 @@ function App() {
<BrowserRouter> <BrowserRouter>
<Nav /> <Nav />
<Switch> <Switch>
<Route component={Signup} path="/register" />
<Route component={Signin} path="/login" />
<Route component={Main} path="/about" /> <Route component={Main} path="/about" />
<Route component={CreatePool} path="/create_pool" /> <Route component={CreatePool} path="/create_pool" />
<Route component={CreateGroup} path="/create_group" /> <Route component={CreateGroup} path="/create_group" />

2
src/api.js Normal file
View File

@ -0,0 +1,2 @@
const dev = process.env.NODE_ENV === 'development';
export const API_ENDPOINT = 'http://localhost/api';

View File

@ -1,4 +1,5 @@
import React, { useState, useEffect } from 'react'; import React, { useState, useEffect } from 'react';
import { API_ENDPOINT } from '../api';
const Group = (props) => { const Group = (props) => {
const id = props.match.params.id; const id = props.match.params.id;
@ -55,20 +56,17 @@ const Group = (props) => {
], ],
}); });
const callAPI = () => { useEffect(() => {
fetch(`${process.env.REACT_APP_API_ENDPOINT}/pools/`) console.log(process.env);
fetch(`${API_ENDPOINT}/my_pools`)
.then((response) => response.json()) .then((response) => response.json())
.then((data) => { .then((json) => {
if (data !== undefined) { if (json) {
setPools(data.Pools); setPools(json.data);
} }
}); });
};
useEffect(() => {
console.log('hello');
callAPI();
}, []); }, []);
const maybePluralize = (count, noun, suffix = 's') => const maybePluralize = (count, noun, suffix = 's') =>
`${count} ${noun}${count !== 1 ? suffix : ''}`; `${count} ${noun}${count !== 1 ? suffix : ''}`;
return ( return (

View File

@ -0,0 +1,7 @@
export default function Main() {
return (
<div className="d-flex flex-column">
<h1>About Us</h1>
</div>
);
}

View File

@ -2,6 +2,8 @@ import React, { useState, useEffect, useCallback } from 'react';
const UpdatePool = (props) => { const UpdatePool = (props) => {
const id = props.match.params.id; const id = props.match.params.id;
// eslint-disable-next-line
const [pool, setPool] = useState({ const [pool, setPool] = useState({
id: 1, id: 1,
pool_title: 'TJ Carpool', pool_title: 'TJ Carpool',