Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

logout functionality #17

Merged
merged 1 commit into from
Jul 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions Client/actionCreator/actionCreator.js
Original file line number Diff line number Diff line change
@@ -7,15 +7,14 @@ export const updateExercisesFromAPI = (array) => ({

export const updateUSER_LOG_ON = (userObj) => ({
type: types.USER_LOG_ON,
payload: userObj
})
payload: userObj,
});

export const updateUSER_LOG_OFF = () => ({
type: types.USER_LOG_OFF,
payload: 'probably none'
})
});

export const updateDifficultyAndMuscle = ([muscle, difficulty]) => ({
type: types.UPDATE_MUSCLE_DIFFICULTY,
payload: [muscle, difficulty]
})
payload: [muscle, difficulty],
});
10 changes: 5 additions & 5 deletions Client/components/login.jsx
Original file line number Diff line number Diff line change
@@ -36,17 +36,17 @@ const login = () => {
alert(data.err);
}
})
.catch((error) => alert(error));
.catch((error) => alert('Invalid Username/Password'));
};

return (
<div>
<form>
<input type="text" id="usernameLogin" placeholder="Username"></input>
<input type='text' id='usernameLogin' placeholder='Username'></input>
<input
type="password"
id="passwordLogin"
placeholder="Password"
type='password'
id='passwordLogin'
placeholder='Password'
></input>
<button onClick={(event) => loginFunc(event)}>Login</button>
</form>
14 changes: 14 additions & 0 deletions Client/components/star-style.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.star_true {
/* represents on state */
color: #d4af37;
}

.star_false {
/* represents off state */
color: black;
}

.star-button {
background: none;
border: none;
}
16 changes: 13 additions & 3 deletions Client/containers/HeaderContainer.jsx
Original file line number Diff line number Diff line change
@@ -11,12 +11,22 @@

import React from 'react';
import * as actions from '../actionCreator/actionCreator.js';
import { useDispatch } from 'react-redux';

const HeaderContainer = () => {
const dispatch = useDispatch();

const logoutHandler = () => {
dispatch(actions.updateUSER_LOG_OFF());
document.getElementById('overlay').style.display = 'block';
};

return (
<div className="appHeaderBox">
<h4 className="mainHeader">Stretch</h4>
<button className="logoutBtn">Logout</button>
<div className='appHeaderBox'>
<h4 className='mainHeader'>Stretch</h4>
<button onClick={logoutHandler} className='logoutBtn'>
Logout
</button>
</div>
);
};
26 changes: 0 additions & 26 deletions Client/containers/OldHeaderContainer.jsx

This file was deleted.

59 changes: 0 additions & 59 deletions Client/containers/OldMainContainer.jsx

This file was deleted.

13 changes: 0 additions & 13 deletions Client/login and signup/WelcomeScreen.html

This file was deleted.

21 changes: 0 additions & 21 deletions Client/login and signup/WelcomeScreen.js

This file was deleted.

4 changes: 0 additions & 4 deletions Client/login and signup/signup-login.css

This file was deleted.

53 changes: 0 additions & 53 deletions Client/login and signup/signup-login.html

This file was deleted.

21 changes: 15 additions & 6 deletions Client/reducers/stretchReducer.js
Original file line number Diff line number Diff line change
@@ -15,31 +15,40 @@ const initialState = {
loggedInUser: '',
favorites: [],
muscle: '',
difficulty: ''
difficulty: '',
};

const stretchReducer = (state = initialState, action) => {
switch (action.type) {
// Get's a list of exercises from the server and updates the array with objects of exercises
case types.UPDATE_FROM_API: {
return {...state, exercisesFromAPI : action.payload};
return { ...state, exercisesFromAPI: action.payload };
}

// Logs user on
case types.USER_LOG_ON: {
// get authentication status of user
return {...state, loggedInUser: action.payload.username, favorites : action.payload.favorites}

document.getElementById('usernameLogin').value = '';
document.getElementById('passwordLogin').value = '';
document.getElementById('usernameSignup').value = '';
document.getElementById('passwordSignup').value = '';
document.getElementById('passwordSignupConfirm').value = '';
return {
...state,
loggedInUser: action.payload.username,
favorites: action.payload.favorites,
};
}

// Logs user off
case types.USER_LOG_OFF: {
return {...state, loggedInUser : ''}
// reset the state including the logged-in user
return { ...initialState };
}

case types.UPDATE_MUSCLE_DIFFICULTY: {
const [muscle, difficulty] = action.payload;
return {...state, muscle:muscle, difficulty,difficulty}
return { ...state, muscle: muscle, difficulty, difficulty };
}
default:
return state;
2 changes: 1 addition & 1 deletion Client/stylesheets/_flexios.scss
Original file line number Diff line number Diff line change
@@ -112,5 +112,5 @@ li:last-child {
bottom: 0;
background-color: black;
z-index: 2;
cursor: pointer;
// cursor: pointer;
}
52 changes: 0 additions & 52 deletions Client/stylesheets/styles.css

This file was deleted.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -34,7 +34,6 @@
"mongodb": "^5.6.0",
"mongoose": "^6.8.0",
"react": "^18.2.0",
"react-countdown-clock": "^2.10.0",
"react-dom": "^18.2.0",
"react-hot-loader": "^4.6.3",
"react-redux": "^8.1.1",