Skip to content

Commit

Permalink
Posts update
Browse files Browse the repository at this point in the history
  • Loading branch information
Jose Buitron committed May 14, 2018
1 parent 3fa2f33 commit 8cebe80
Show file tree
Hide file tree
Showing 13 changed files with 141 additions and 40 deletions.
6 changes: 6 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"presets": ["latest", "react"],
"plugins": [
"transform-object-rest-spread"
]
}
5 changes: 5 additions & 0 deletions .firebaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"projects": {
"default": "laboratoria-419ca"
}
}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
bundle.js
10 changes: 1 addition & 9 deletions app/auth/Login.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,9 @@ import { connect } from 'react-redux'
import { push } from 'react-router-redux'
import { Button } from 'material-ui'

import { authSuccess, authFail } from './auth.actions'
import Base from '../components/Base'

const authSuccess = () => ({
type: 'AUTH_SUCCESS'
})

const authFail = () => ({
type: 'AUTH_FAIL'
})

class LoginContainer extends React.Component {
render() {
const onClick = () => {
Expand All @@ -32,6 +25,5 @@ class LoginContainer extends React.Component {
export default connect(null, dispatch => ({
login: () => {
dispatch(authSuccess())
dispatch(push('/'))
}
}))(LoginContainer)
4 changes: 4 additions & 0 deletions app/auth/auth.actions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { createAction } from 'redux-actions'

export const authSuccess = createAction('AUTH_SUCCESS')
export const authFail = createAction('AUTH_FAIL')
30 changes: 13 additions & 17 deletions app/auth/auth.reducer.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
import { handleActions } from 'redux-actions'

import * as actions from './auth.actions'

const initialState = {
isAuthenticated: false
}

const authReducer = (state = initialState , action) => {
switch (action.type) {
case 'AUTH_SUCCESS':
return {
...state,
isAuthenticated: true
}
case 'AUTH_FAIL':
return {
...state,
isAuthenticated: false
}
default:
return state
}
}
export default handleActions({
[actions.authSuccess]: (state, action) => ({
...state,
isAuthenticated: true
}),
[actions.authFail]: (state, action) => ({
...state,
isAuthenticated: false
})
}, initialState)

export default authReducer
34 changes: 22 additions & 12 deletions app/posts/NewPost.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,34 @@ import {
CardContent,
CardActions,
} from 'material-ui'
import { connect } from 'react-redux'

import * as actions from './posts.actions'

const postOptions = [{
value: 'friends',
label: 'Friends'
}, {
value: 'public',
label: 'Public'
}]

const PostOptions = props => (
<Select
value=""
inputProps={{
name: 'age',
id: 'age-simple',
}}
value="friends"
>
<MenuItem value="">
<em>None</em>
</MenuItem>
<MenuItem value={10}>Ten</MenuItem>
<MenuItem value={20}>Twenty</MenuItem>
<MenuItem value={30}>Thirty</MenuItem>
{postOptions.map(option => (
<MenuItem value={option.value}>{option.label}</MenuItem>
))}
</Select>
)

const NewPost = props => {

const onPublish = () => {

}

return (
<Card>
<CardContent>
Expand All @@ -45,4 +53,6 @@ const NewPost = props => {
)
}

export default NewPost
export default connect(null, dispatch => ({
addPost: post => dispatch(actions.postAdd(post))
}))(NewPost)
3 changes: 3 additions & 0 deletions app/posts/posts.actions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { createAction } from 'redux-actions'

export const postAdd = createAction('POST_ADD')
15 changes: 15 additions & 0 deletions app/posts/posts.reducer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { handleActions } from 'redux-actions'

import * as actions from './posts.actions'

const initialState = {
list: []
}

export default handleActions({
[actions.postAddSuccess]: (state, action) => ({
...state,
list: [ ...state.list, action.payload ]
})
}, initialState)

4 changes: 3 additions & 1 deletion app/reducers.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { combineReducers } from 'redux'

import auth from './auth/auth.reducer'
import posts from './posts/posts.reducer'


export default combineReducers({
auth,
auth,
posts,
})
49 changes: 49 additions & 0 deletions firebase-debug.log
Original file line number Diff line number Diff line change
Expand Up @@ -120,3 +120,52 @@
at TCP.done [as _onclose] (_tls_wrap.js:356:7)
[error]
[error] Error: An unexpected error has occurred.
[debug] [2018-05-14T02:24:46.413Z] ----------------------------------------------------------------------
[debug] [2018-05-14T02:24:46.415Z] Command: /Users/ext.jbuitron/.nvm/versions/node/v8.11.1/bin/node /Users/ext.jbuitron/.nvm/versions/node/v8.11.1/bin/firebase serve
[debug] [2018-05-14T02:24:46.415Z] CLI Version: 3.18.4
[debug] [2018-05-14T02:24:46.415Z] Platform: darwin
[debug] [2018-05-14T02:24:46.415Z] Node Version: v8.11.1
[debug] [2018-05-14T02:24:46.415Z] Time: Sun May 13 2018 21:24:46 GMT-0500 (-05)
[debug] [2018-05-14T02:24:46.415Z] ----------------------------------------------------------------------
[debug]
[debug] [2018-05-14T02:24:46.422Z] > command requires scopes: ["email","openid","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
[debug] [2018-05-14T02:24:46.422Z] > authorizing via signed-in user
[debug] [2018-05-14T02:24:46.424Z] > refreshing access token with scopes: ["email","https://www.googleapis.com/auth/cloud-platform","https://www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis.com/auth/firebase","openid"]
[debug] [2018-05-14T02:24:46.424Z] >>> HTTP REQUEST POST https://www.googleapis.com/oauth2/v3/token
{ refresh_token: '1/tNI_Yrr4lRPNJcQO2TuocbX0hxnTzbpuQYWap7YV_sw',
client_id: '563584335869-fgrhgmd47bqnekij5i8b5pr03ho849e6.apps.googleusercontent.com',
client_secret: 'j9iVZfS8kkCEFUPaAeJV0sAi',
grant_type: 'refresh_token',
scope: 'email https://www.googleapis.com/auth/cloud-platform https://www.googleapis.com/auth/cloudplatformprojects.readonly https://www.googleapis.com/auth/firebase openid' }
Sun May 13 2018 21:24:46 GMT-0500 (-05)
[debug] [2018-05-14T02:24:47.272Z] <<< HTTP RESPONSE 200
[debug] [2018-05-14T02:24:47.288Z] >>> HTTP REQUEST GET https://admin.firebase.com/v1/projects/laboratoria-419ca

Sun May 13 2018 21:24:47 GMT-0500 (-05)
[debug] [2018-05-14T02:24:48.350Z] <<< HTTP RESPONSE 200
[debug] [2018-05-14T02:24:48.351Z] >>> HTTP REQUEST GET https://admin.firebase.com/v1/database/laboratoria-419ca/tokens

Sun May 13 2018 21:24:48 GMT-0500 (-05)
[debug] [2018-05-14T02:24:49.308Z] <<< HTTP RESPONSE 200
[debug] [2018-05-14T02:24:49.309Z] >>> HTTP REQUEST GET https://cloudresourcemanager.googleapis.com/v1/projects/laboratoria-419ca

Sun May 13 2018 21:24:49 GMT-0500 (-05)
[debug] [2018-05-14T02:24:50.297Z] <<< HTTP RESPONSE 200
[info]
[info] === Serving from '/Users/ext.jbuitron/personal/projects/inter/laboratoria'...
[info]
[info] i functions: Preparing to emulate functions.
[debug] [2018-05-14T02:24:50.698Z] Fetching environment
[debug] [2018-05-14T02:24:50.700Z] >>> HTTP REQUEST GET https://mobilesdk-pa.googleapis.com/v1/projects/87445228632:getServerAppConfig

Sun May 13 2018 21:24:50 GMT-0500 (-05)
[debug] [2018-05-14T02:24:50.701Z] >>> HTTP REQUEST GET https://mobilesdk-pa.googleapis.com/v1/projects/87445228632/clients/_:getWebAppConfig

Sun May 13 2018 21:24:50 GMT-0500 (-05)
[debug] [2018-05-14T02:24:52.766Z] <<< HTTP RESPONSE 200
[debug] [2018-05-14T02:24:52.766Z] Starting @google-cloud/functions-emulator
[debug] [2018-05-14T02:24:52.848Z] <<< HTTP RESPONSE 200
[info] i hosting: Serving hosting files from: public
[info] ✔ hosting: Local server: http://localhost:5000

[debug] [2018-05-14T02:24:53.819Z] Parsing function triggers
16 changes: 16 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"react-router": "^4.2.0",
"react-router-dom": "^4.2.2",
"react-router-redux": "^5.0.0-alpha.9",
"redux": "^4.0.0"
"redux": "^4.0.0",
"redux-actions": "^2.3.2"
}
}

0 comments on commit 8cebe80

Please sign in to comment.