diff --git a/frontend/src/App.js b/frontend/src/App.js index cd42c54..45b83f7 100644 --- a/frontend/src/App.js +++ b/frontend/src/App.js @@ -5,14 +5,14 @@ import Login from './pages/Login' import Register from './pages/Register' import Habits from './pages/Habits' import Goals from './pages/Goals' -//import Header from './components/Header'; +import Header from './components/Header' function App() { return ( <>
- +
} /> } /> diff --git a/frontend/src/components/header.jsx b/frontend/src/components/header.jsx index 060f9c9..b97e488 100644 --- a/frontend/src/components/header.jsx +++ b/frontend/src/components/header.jsx @@ -4,7 +4,7 @@ import {Link, useNavigate} from 'react-router-dom' import {useSelector, useDispatch} from 'react-redux' import {logout, resetAuth} from '../features/auth/authSlice' import {resetGoals} from '../features/goals/goalsSlice' -import { resetHabits} from '../features/habits/habitsSlice' +import { resetHabits } from '../features/habits/habitsSlice' function Header() { @@ -44,8 +44,6 @@ function Header() { )} - -
) diff --git a/frontend/src/features/auth/authService.js b/frontend/src/features/auth/authService.js index 9d71cfd..7ed5c3d 100644 --- a/frontend/src/features/auth/authService.js +++ b/frontend/src/features/auth/authService.js @@ -1,6 +1,6 @@ import axios from 'axios' -const API_URL = process.env.SERVER_URL + '/api/users/' +const API_URL = 'https://caraibou-demo-api.onrender.com/api/users/' // Register user const register = async (userData) => { @@ -10,17 +10,21 @@ const register = async (userData) => { if(response.data) { localStorage.setItem('user', response.data) } + //console.log(typeof response.userData) return response.data } // Login user const login = async (userData) => { + console.log(API_URL) const response = await axios.post(API_URL + 'login', userData) if(response.data) { localStorage.setItem('user', JSON.stringify(response.data)) } + console.log(JSON.stringify(response.data)) + return response.data } diff --git a/frontend/src/features/auth/authSlice.js b/frontend/src/features/auth/authSlice.js index 548febe..45c064e 100644 --- a/frontend/src/features/auth/authSlice.js +++ b/frontend/src/features/auth/authSlice.js @@ -1,7 +1,9 @@ import {createSlice, createAsyncThunk} from '@reduxjs/toolkit' import authService from './authService' -const user = localStorage.getItem('user') +//console.log(localStorage.getItem('user')) +var user = JSON.parse(localStorage.getItem('user')) + const initialState = { user: user ? user : null, diff --git a/frontend/src/features/goals/goalsService.js b/frontend/src/features/goals/goalsService.js index ad22cdc..098e22d 100644 --- a/frontend/src/features/goals/goalsService.js +++ b/frontend/src/features/goals/goalsService.js @@ -1,6 +1,6 @@ import axios from 'axios' -const API_URL = process.env.SERVER_URL + '/api/goals/' +const API_URL = 'https://caraibou-demo-api.onrender.com/api/goals/' // submit goals diff --git a/frontend/src/features/habits/habitsService.js b/frontend/src/features/habits/habitsService.js index e5506d1..25027cf 100644 --- a/frontend/src/features/habits/habitsService.js +++ b/frontend/src/features/habits/habitsService.js @@ -1,6 +1,6 @@ import axios from 'axios' -const API_URL = process.env.SERVER_URL + '/api/habits/' +const API_URL = 'https://caraibou-demo-api.onrender.com/api/habits/' // submit habits diff --git a/frontend/src/pages/Habits.jsx b/frontend/src/pages/Habits.jsx index 7c934b4..4ac0b83 100644 --- a/frontend/src/pages/Habits.jsx +++ b/frontend/src/pages/Habits.jsx @@ -127,10 +127,7 @@ function Habits() {
- - - - + ) }