Skip to content

Commit

Permalink
changed api url and added Header back
Browse files Browse the repository at this point in the history
  • Loading branch information
viviannnl committed Sep 22, 2023
1 parent 3304248 commit cdd8c30
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 13 deletions.
4 changes: 2 additions & 2 deletions frontend/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<>
<Router>
<div className='container'>

<Header />
<Routes>
<Route path='/' element={<Landing />} />
<Route path='/login' element={<Login />} />
Expand Down
4 changes: 1 addition & 3 deletions frontend/src/components/header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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() {

Expand Down Expand Up @@ -44,8 +44,6 @@ function Header() {
</Link>
</li>
</>)}


</ul>
</header>
)
Expand Down
6 changes: 5 additions & 1 deletion frontend/src/features/auth/authService.js
Original file line number Diff line number Diff line change
@@ -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) => {
Expand All @@ -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
}
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/features/auth/authSlice.js
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/features/goals/goalsService.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/features/habits/habitsService.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down
5 changes: 1 addition & 4 deletions frontend/src/pages/Habits.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,7 @@ function Habits() {
</div>
</form>
</section>


</div>

</div>
)
}

Expand Down

0 comments on commit cdd8c30

Please sign in to comment.