This file contains hidden or 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
import { FETCH_TODOS } from '../actions/index'; | |
const INITIAL_STATE = { all: [], todo: null}; | |
export default function(state = INITIAL_STATE, action) { | |
switch(action.type) { | |
case FETCH_TODOS: | |
return {...state, all: action.payload.data }; |
This file contains hidden or 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
import React, { Component, PropTypes } from 'react'; | |
import { connect } from 'react-redux'; | |
import { fetchTodo, updateTodo } from '../actions/index'; | |
import { Link } from 'react-router'; | |
class ShowTodo extends Component { | |
static contextTypes = { | |
router: PropTypes.object | |
}; |
This file contains hidden or 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
import React, { Component, PropTypes } from 'react'; | |
import { reduxForm } from 'redux-form'; | |
import { connect } from 'react-redux'; | |
import LogoutHeader from './LogoutHeader'; | |
import { fetchTodo, updateTodo, deleteTodo } from '../actions/index'; | |
import { Link } from 'react-router'; | |
class ShowTodo extends Component { | |
static contextTypes = { |
This file contains hidden or 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
import React, { Component, PropTypes } from 'react'; | |
import { reduxForm } from 'redux-form'; | |
import { connect } from 'react-redux'; | |
import LogoutHeader from 'LogoutHeader'; | |
import { fetchTodo, updateTodo, deleteTodo } from 'Actions'; | |
import { Link } from 'react-router'; | |
class ShowTodo extends Component { | |
static contextTypes = { |
This file contains hidden or 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
// First handleSaveClick gets called from the ShowTodo Component | |
handleSaveClick: function () { | |
console.log("Handle Save Click Called!"); | |
var props = { | |
title: this.state.todoTitle, | |
description: this.state.todoDescription | |
}; |
This file contains hidden or 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 is from the login page submit handler, you can see I have success and error handlers | |
//Despite throwing an error, the page will still push onward to '/todos_index' | |
onSubmit(props) { | |
this.props.loginUser(props).then(() => { | |
this.context.router.push('/todos_index'); | |
}, (response) => { | |
This file contains hidden or 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
{ | |
"name": "practice-todo-api", | |
"version": "1.0.0", | |
"description": "", | |
"main": "index.js", | |
"scripts": { | |
"start": "node server.js" | |
}, | |
"author": "", | |
"license": "ISC", |
This file contains hidden or 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
var Sequelize = require('sequelize'); | |
var env = process.env.NODE_ENV || 'development'; | |
var sequelize; | |
if (env === 'production') { | |
sequelize = new Sequelize(process.env.DATABASE_URL, { | |
dialect: 'postgres' | |
}); // This if statement should execute if the app is run on Heroku | |
} else { | |
sequelize = new Sequelize(undefined, undefined, undefined, { |
This file contains hidden or 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
{ | |
"name": "practice-todo-api", | |
"version": "1.0.0", | |
"description": "", | |
"main": "index.js", | |
"scripts": { | |
"start": "node server.js" | |
}, | |
"author": "", | |
"license": "ISC", |
This file contains hidden or 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
import React, { Component } from 'react'; | |
import { connect } from 'react-redux'; | |
var Checkout = React.createClass({ | |
render: function() { | |
return ( | |
<div onClick={this.handleClick}> | |
<h1>{this.props.cart.length}</h1> | |
</div> |
OlderNewer