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

Sharlene #2

Open
wants to merge 19 commits into
base: developer
Choose a base branch
from
Open
Show file tree
Hide file tree
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
Binary file added .DS_Store
Binary file not shown.
66 changes: 58 additions & 8 deletions client/actions/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import request from 'superagent'

export const SHOW_ERROR = 'SHOW_ERROR'
export const RECEIVE_POSTS = 'RECEIVE_POSTS'
// export const RECEIVE_POSTS = 'RECEIVE_POSTS'
export const RECEIVE_TRONALDDUMP = 'RECEIVE_TRONALDDUMP'
export const RECEIVE_NUCKCHORRIS = 'RECIEVE_NUCKCHORRIS'
export const RECEIVE_DADJOKE = 'RECIEVE_DADJOKE'
export const REQUEST_POSTS = 'REQUEST_POSTS'

export const requestPosts = () => {
Expand All @@ -10,27 +13,74 @@ export const requestPosts = () => {
}
}

export const receivePosts = (posts) => {
export const receiveTronaldDump = (quote) => {
return {
type: RECEIVE_POSTS,
posts: posts.map(post => post.data)
type: RECEIVE_TRONALDDUMP,
tronaldDump: quote.value
}
}

export const receiveNuckChorris = (value) => {
return {
type: RECEIVE_NUCKCHORRIS,
nuckChorris: value
}
}

export const receiveDadJoke = (joke) => {
return {
type: RECEIVE_DADJOKE,
dadJoke: joke.joke
}
}



export const showError = (errorMessage) => {
return {
type: SHOW_ERROR,
errorMessage: errorMessage
errorMessage: errorMessage,
}
}


export function fetchTronaldDump () {
return (dispatch) => {
dispatch(requestPosts())
return request
.get(`/api/v1/tronalddump`)

.then(res => {
dispatch(receiveTronaldDump(res.body))
})
.catch(err => {
dispatch(showError(err.message))
})
}
}

export function fetchNuckChorris() {
return (dispatch) => {
dispatch(requestPosts())
return request
.get(`/api/v1/nuckchorris`)
.then(res => {
dispatch(receiveNuckChorris(res.body))
})
.catch(err => {
dispatch(showError(err.message))
})
}
}

export function fetchPosts (subreddit) {
export function fetchDadJoke() {
return (dispatch) => {
dispatch(requestPosts())
return request
.get(`/api/v1/reddit/subreddit/${subreddit}`)
.get(`/api/v1/dadjoke`)
.set('Accept', 'application/json')
.then(res => {
dispatch(receivePosts(res.body))
dispatch(receiveDadJoke(res.body))
})
.catch(err => {
dispatch(showError(err.message))
Expand Down
37 changes: 37 additions & 0 deletions client/api.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import request from "superagent";

const randomQuote = 'https://api.tronalddump.io/random/quote';
const nuckChorris = 'https://geek-jokes.sameerkumar.website/api'
const dadJoke = 'https://icanhazdadjoke.com/search'

export function getQuotes(callback) {
request
.get(randomQuote)
.end((err, res) => {
callback(err, res.body);
});
}

export function getNuck(callback) {
request
.get(nuckChorris)
.end((err, res) => {
callback(err, res.body);
});
}

export function getJoke(callback) {
request
.get(dadJoke)
.end((err, res) => {
callback(err, res.body);
});
}

export function getPictures(callback) {
request
.get(randomQuote)
.end((err, res) => {
callback(err, res.body);
});
}
35 changes: 30 additions & 5 deletions client/components/App.jsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,42 @@
import React from 'react'



import ErrorMessage from './ErrorMessage'
import LoadSubreddit from './LoadSubreddit'
import SubredditList from './SubredditList'
import WaitIndicator from './WaitIndicator'
import LoadTrump from './LoadTrump'
import LoadChuck from './LoadChuck'
import LoadJoke from './LoadJoke'
import Trump from './Trump'
import Chuck from './Chuck'
import Sounds from './Random-Sound'
import Joke from './Joke'
import Header from './Header'
// import Button from './Button'
import Video from './video'
// import Nav from './Nav'

const App = () => (
<div className='app'>
{/* <Nav /> */}
<Header />
{/* <Button /> */}
<button><Sounds />Yeet</button>
<ErrorMessage />
<LoadSubreddit>
<LoadTrump >
<WaitIndicator />
</LoadTrump>
<LoadChuck >
<WaitIndicator />
</LoadChuck>
<LoadJoke >
<WaitIndicator />
</LoadSubreddit>
<SubredditList />
</LoadJoke>
<Trump />
<Chuck />
<Joke />
<Video />

</div>
)

Expand Down
29 changes: 29 additions & 0 deletions client/components/Button.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import React from 'react'
import Zoom from "react-reveal/Zoom";
import {connect} from 'react-redux'
import {fetchTronaldDump} from '../actions'

function Button (){
return (


<div className = "button">
<Zoom>
<button onClick={() => dispatch(fetchTronaldDump())}>Click For Intelligence</button>
</Zoom>






</div>


)

}


export default Button
// export default connect (LoardTrump) (Button)
19 changes: 19 additions & 0 deletions client/components/Chuck.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import React from 'react'
import {connect} from 'react-redux'




const Chuck = ({nuckChorris}) => (
<div>{nuckChorris}</div>
)

const mapStateToProps = (state) => {
return {
nuckChorris: state.nuckChorris
}
}

export default connect(
mapStateToProps
)(Chuck)
24 changes: 24 additions & 0 deletions client/components/Header.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import React from 'react'
import Zoom from 'react-reveal/Zoom'

import {connect} from 'react-redux'





const Header = ()=> {
return(
<div>
<Zoom>

<h1>Aprils Rules</h1>

</Zoom>

</div>
)
}


export default Header
21 changes: 21 additions & 0 deletions client/components/Joke.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import React from 'react'
import {connect} from 'react-redux'




const Joke = ({dadJoke}) => (

<div>{dadJoke}</div>
)

const mapStateToProps = (state) => {

return {
dadJoke: state.dadJoke
}
}

export default connect(
mapStateToProps
)(Joke)
14 changes: 14 additions & 0 deletions client/components/LoadChuck.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import React from 'react'
import {connect} from 'react-redux'
import {fetchNuckChorris} from '../actions'

const LoadChuck = ({children, dispatch}) => (
<div>
<button onClick={() => dispatch(fetchNuckChorris())}>
Information
</button>
{children}
</div>
)

export default connect()(LoadChuck)
14 changes: 14 additions & 0 deletions client/components/LoadJoke.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import React from 'react'
import {connect} from 'react-redux'
import {fetchDadJoke} from '../actions'

const LoadJoke = ({children, dispatch}) => (
<div>
<button onClick={() => dispatch(fetchDadJoke())}>
Contact us
</button>
{children}
</div>
)

export default connect()(LoadJoke)
14 changes: 0 additions & 14 deletions client/components/LoadSubreddit.jsx

This file was deleted.

14 changes: 14 additions & 0 deletions client/components/LoadTrump.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import React from 'react'
import {connect} from 'react-redux'
import {fetchTronaldDump} from '../actions'

const LoadTrump = ({children, dispatch}) => (
<div>
<button onClick={() => dispatch(fetchTronaldDump())}>
Click for Intelligence
</button>
{children}
</div>
)

export default connect()(LoadTrump)
45 changes: 45 additions & 0 deletions client/components/Nav.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import React from 'react'
import {connect} from 'react-redux'
import Zoom from 'react-reveal/Zoom'
import Roll from 'react-reveal/Roll'

import LoadJoke from './LoadJoke';
import Sounds from './Random-Sound'

import {fetchNuckChorris} from '../actions'
import {fetchDadJoke} from '../actions'


const Nav = ()=>{
return (

<div>
<Roll/>
<div className="navbar">
<Zoom>
<button href="">Contact us</button>
</Zoom>
<Zoom>
<button href="https://www.youtube.com/watch?v=djV11Xbc914">Take on Me</button>
</Zoom>
<Zoom>
<button onClick={() => dispatch(fetchNuckChorris())}>Information</button>
</Zoom>
<Zoom>
<button onClick={() => dispatch(fetchNuckChorris())}></button>
</Zoom>

<Roll/>

</div>

</div>
)
}





export default connect()(Nav)

7 changes: 0 additions & 7 deletions client/components/Post.jsx

This file was deleted.

Loading