Skip to content

Commit

Permalink
axios conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
jordanchristie committed Sep 6, 2018
1 parent 6411c1c commit 2cf1280
Show file tree
Hide file tree
Showing 45 changed files with 15 additions and 20 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
20 changes: 7 additions & 13 deletions server/client/src/actions/index.js → client/src/actions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,40 +7,34 @@ import { FETCH_USER,

export const fetchUser = (user) => {
return dispatch => {
fetch('/api/user', {credentials: 'include'})
.then(res => res.json())
axios.get('/api/user', {withCredentials: 'include'})
.then(res => res.data)
.then(user => dispatch({ type: FETCH_USER, payload: user}))
.catch(err => console.log(err))
}
}

export const fetchExploreQuotes = () => {
return dispatch => {
fetch(QUOTE_URL)
.then(res => res.json())
axios.get(QUOTE_URL, {headers: {'Access-Control-Allow-Origin': '*'}})
.then(res => res.data)
.then(data => dispatch({type: FETCH_EXPLORE_QUOTES, payload: data}))
.catch(err => console.log(err))
}
}

export const saveQuoteToProfile = (quote) => {
return dispatch => {
fetch('/api/saved', {
headers: {
'Content-Type': 'application/json'
},
method: 'post',
body: JSON.stringify(quote)
})
.then(data => dispatch({type: SAVE_QUOTE_TO_PROFILE, payload: data}))
axios.post('/api/saved', quote)
.then(data => dispatch({ type: SAVE_QUOTE_TO_PROFILE, payload: data }))
.catch(err => console.log(err))
}
}

export const removeQuoteFromProfile = (id) => {
return dispatch => {
axios.delete(`/api/saved/${id}`)
.then(data => dispatch({ type: REMOVE_QUOTE_FROM_PROFILE, payload: data}))
.then(data => dispatch({ type: REMOVE_QUOTE_FROM_PROFILE, payload: data }))
.catch(err => console.log(err))
}
}
File renamed without changes
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { Component } from 'react';
import { connect } from 'react-redux';
import { FacebookShareButton, TwitterShareButton } from 'react-share';
// import { FacebookShareButton, TwitterShareButton } from 'react-share';

import { saveQuoteToProfile, removeQuoteFromProfile } from '../actions/index';

Expand Down Expand Up @@ -45,8 +45,7 @@ class Card extends Component {
Save Quote
</a>
}
<FacebookShareButton />
<TwitterShareButton />

<a href=""><i className="fa fa-facebook right"></i></a>
<a href=""><i className="fa fa-twitter right"></i></a>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class Dashboard extends Component {
}

render() {
console.log(this.props)
const { user } = this.props;
return (
<div id="dashboard-page">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class ExplorePage extends Component {
}

render() {
console.log(this.props)
return (
<div>
<h1>Explore</h1>
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { FETCH_USER } from '../constants/constants';
export const authReducer = (state = {}, action) => {
switch (action.type) {
case FETCH_USER:
console.log(action.payload)
return action.payload || null;
default:
return state;
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@ import { FETCH_EXPLORE_QUOTES,
REMOVE_QUOTE_FROM_PROFILE } from '../constants/constants';



export const quotesReducer = (state = [], action) => {
switch (action.type) {
case FETCH_EXPLORE_QUOTES:
return action.payload;
case SAVE_QUOTE_TO_PROFILE:
return [...state, action.payload ];
case SAVE_QUOTE_TO_PROFILE:
case REMOVE_QUOTE_FROM_PROFILE:
return [...state, action.payload];
return action.payload;
default:
return state
}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Binary file added server/.DS_Store
Binary file not shown.
File renamed without changes.

0 comments on commit 2cf1280

Please sign in to comment.