forked from avvazana/Spoofify
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
1,180 additions
and
974 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
ruby-2.3.7 | ||
ruby-2.5.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
debugger | ||
json.partial! 'api/users/user', user: @user |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import React from 'react'; | ||
import { Route, Redirect, Switch } from 'react-router-dom'; | ||
import { AuthRoute, ProtectedRoute } from '../util/route_util'; | ||
|
||
import MainContentContainer from './main/main_content_container'; | ||
import Splash from './session/splash'; | ||
|
||
const App = (props) => { | ||
const splashOrMain = Boolean(props.store.getState().session.currentUserId) ? ( | ||
<ProtectedRoute path="/" component={MainContentContainer} /> | ||
) : ( | ||
<AuthRoute path="/" component={Splash} /> | ||
) | ||
|
||
return ( | ||
<div className="page"> | ||
{splashOrMain} | ||
</div> | ||
) | ||
}; | ||
|
||
export default App; |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import React from 'react'; | ||
import { Provider } from 'react-redux'; | ||
import App from './App'; | ||
import { HashRouter } from 'react-router-dom'; | ||
|
||
const Root = ({store}) => ( | ||
<Provider store={store} > | ||
<HashRouter> | ||
<App store={store} /> | ||
</HashRouter> | ||
</Provider> | ||
); | ||
|
||
export default Root; |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,11 @@ | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import configureStore from './store/store'; | ||
|
||
document.addEventListener("DOMContentLoaded", () => { | ||
const store = configureStore(); | ||
window.getState = store.getState; | ||
window.dispatch = store.dispatch; | ||
const root = document.getElementById('root'); | ||
ReactDOM.render(<h1>HELLO</h1>, root); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { combineReducers } from 'redux'; | ||
import usersReducer from './users_reducer'; | ||
|
||
export default combineReducers({ | ||
users: usersReducer | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { RECEIVE_CURRENT_USER, RECEIVE_USER} from '../../actions/session_actions'; | ||
|
||
const usersReducer = (state = {}, action) => { | ||
Object.freeze(state); | ||
|
||
switch(action.type) { | ||
case RECEIVE_CURRENT_USER: | ||
const currentUser = {[action.user.id]: action.user} | ||
return Object.assign({}, state, currentUser); | ||
case RECEIVE_USER: | ||
const newUser = {[action.user.id]: action.user} | ||
return Object.assign({}, state, newUser) | ||
default: | ||
return state | ||
} | ||
} | ||
|
||
export default usersReducer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { combineReducers } from 'redux'; | ||
import sessionErrorsReducer from './session_errors_reducer'; | ||
import userErrorsReducer from './user_errors_reducer'; | ||
|
||
const errorsReducer = combineReducers({ | ||
session: sessionErrorsReducer, | ||
user: userErrorsReducer | ||
}); | ||
|
||
export default errorsReducer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { | ||
RECEIVE_SIGNIN_ERRORS | ||
} from '../../actions/session_actions'; | ||
|
||
const sessionErrorsReducer = (state = [], action) => { | ||
switch(action.type) { | ||
case RECEIVE_SIGNIN_ERRORS: | ||
return action.errors; | ||
default: | ||
return state; | ||
} | ||
} | ||
|
||
export default sessionErrorsReducer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { RECEIVE_SIGNUP_ERRORS } from '../../actions/session_actions'; | ||
|
||
const userErrorsReducer = (state = [], action) => { | ||
Object.freeze(state); | ||
|
||
switch(action.type) { | ||
case RECEIVE_SIGNUP_ERRORS: | ||
return action.errors; | ||
default: | ||
return state; | ||
} | ||
} | ||
|
||
export default userErrorsReducer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
// import { combineReducers } from 'redux'; | ||
// import entitiesReducer from './entities/entities_reducer'; | ||
// import sessionReducer from './session/session_reducer'; | ||
// import errorsReducer from './errors/errors_reducer'; | ||
// import uiReducer from './ui/ui_reducer'; | ||
// | ||
// const rootReducer = combineReducers({ | ||
// entities: entitiesReducer, | ||
// session: sessionReducer, | ||
// errors: errorsReducer, | ||
// ui: uiReducer | ||
// }); | ||
// | ||
// export default rootReducer; | ||
import { combineReducers } from 'redux'; | ||
import entitiesReducer from './entities/entities_reducer'; | ||
import sessionReducer from './session/session_reducer'; | ||
import errorsReducer from './errors/errors_reducer'; | ||
import uiReducer from './ui/ui_reducer'; | ||
|
||
const rootReducer = combineReducers({ | ||
entities: entitiesReducer, | ||
session: sessionReducer, | ||
errors: errorsReducer, | ||
ui: uiReducer | ||
}); | ||
|
||
export default rootReducer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { RECEIVE_CURRENT_USER, LOGOUT_CURRENT_USER} from '../../actions/session_actions'; | ||
|
||
const empty = { currentUserId: null } | ||
|
||
const sessionReducer = (state = empty, action) => { | ||
Object.freeze(state); | ||
|
||
switch(action.type) { | ||
case RECEIVE_CURRENT_USER: | ||
return {currentUserId: action.user.id}; | ||
case LOGOUT_CURRENT_USER: | ||
return empty; | ||
default: | ||
return state; | ||
} | ||
}; | ||
|
||
export default sessionReducer; |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { createStore, applyMiddleware } from 'redux'; | ||
import rootReducer from '../reducers/root_reducer'; | ||
import logger from 'redux-logger'; | ||
import thunk from 'redux-thunk'; | ||
|
||
const configureStore = (preloadedState = {}) => { | ||
return createStore( | ||
rootReducer, | ||
preloadedState, | ||
applyMiddleware(thunk, logger) | ||
); | ||
}; | ||
|
||
export default configureStore; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { Route, Redirect, withRouter } from 'react-router-dom'; | ||
import { connect } from 'react-redux'; | ||
import React from 'react'; | ||
|
||
const Auth = ( { component: Component, path, exact, loggedIn}) => ( | ||
<Route path={path} exact={exact} render={(props) => ( | ||
loggedIn ? ( | ||
<Redirect to="/" /> | ||
) : ( | ||
<Component {...props} /> | ||
) | ||
)} /> | ||
); | ||
|
||
const Protected = ( { component: Component, path, exact, loggedIn}) => ( | ||
<Route path={path} exact={exact} render={(props) => ( | ||
loggedIn ? ( | ||
<Component {...props} /> | ||
) : ( | ||
<Redirect to="/" /> | ||
) | ||
)} /> | ||
); | ||
|
||
const mapStateToProps = state => ({ | ||
loggedIn: Boolean(state.session.currentUserId) | ||
}); | ||
|
||
export const AuthRoute = withRouter(connect(mapStateToProps, null)(Auth)); | ||
export const ProtectedRoute = withRouter(connect(mapStateToProps)(Protected)); |
Oops, something went wrong.