forked from notnull/waveform
updated episode and captions view components
This commit is contained in:
parent
b21d6695a7
commit
26a0833671
@ -1,16 +1,15 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
|
|
||||||
const CaptionList = props => {
|
const CaptionList = props => {
|
||||||
console.log('CAPTION LIST MOTHERFUCKER!!!!!', props)
|
const { captions } = props
|
||||||
const { handleClick, captions } = props
|
|
||||||
return (
|
return (
|
||||||
<tbody>
|
<tbody>
|
||||||
{Object.keys(captions).map(key => {
|
{Object.keys(captions).map(key => {
|
||||||
return captions[key].map(caption => {
|
return captions[key].map(caption => {
|
||||||
return (
|
return (
|
||||||
<tr key = {key}
|
<tr key = {key+caption.text}
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
handleClick({ nick: caption.nick, text: caption.text })
|
console.log({ nick: caption.nick, text: caption.text })
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<td>{caption.nick}</td>
|
<td>{caption.nick}</td>
|
||||||
|
@ -1,19 +1,31 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import CaptionList from './CaptionList'
|
import CaptionList from './CaptionList'
|
||||||
import Table from 'react-bootstrap/Table'
|
import Table from 'react-bootstrap/Table'
|
||||||
|
import {connect} from 'react-redux'
|
||||||
const Captions = props => {
|
const Captions = props => {
|
||||||
const { handleClick, captions } = props
|
|
||||||
|
const captions = props.captions.all.find(captionSet=>captionSet.slug===props.match.params.slug)
|
||||||
|
|
||||||
|
if(!captions) return <div>No show with that id.</div>
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Table striped bordered hover>
|
<Table striped bordered hover>
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Episodes</th>
|
<th>Nick</th>
|
||||||
|
<th>Comment</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<CaptionList handleClick={handleClick} captions={captions} />
|
<CaptionList captions={captions.captions} />
|
||||||
</Table>
|
</Table>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Captions
|
const mapState = state => {
|
||||||
|
return {
|
||||||
|
episodes: state.episodes,
|
||||||
|
captions: state.captions
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default connect(mapState)(Captions)
|
||||||
|
@ -1,13 +1,18 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
|
import {NavLink} from 'react-router-dom'
|
||||||
|
|
||||||
const EpisodeList = props => {
|
const EpisodeList = props => {
|
||||||
const { episodes, fetchEpisodeComments } = props
|
const { episodes } = props
|
||||||
console.log('EPISODELIST', episodes)
|
|
||||||
return (
|
return (
|
||||||
<tbody>
|
<tbody>
|
||||||
{episodes.map(episode => (
|
{episodes.map(episode => (
|
||||||
<tr onClick={() => fetchEpisodeComments(episode.slug)}>
|
<tr key={episode.slug}>
|
||||||
<td>{episode.title}</td>
|
<td>
|
||||||
|
<NavLink to={`/captions/${episode.slug}`}>
|
||||||
|
{episode.title}
|
||||||
|
</NavLink>
|
||||||
|
</td>
|
||||||
|
|
||||||
</tr>
|
</tr>
|
||||||
))}
|
))}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import EpisodeList from './EpisodeList'
|
import EpisodeList from './EpisodeList'
|
||||||
import Table from 'react-bootstrap/Table'
|
import Table from 'react-bootstrap/Table'
|
||||||
|
import {connect} from 'react-redux'
|
||||||
|
|
||||||
const Episodes = props => {
|
const Episodes = props => {
|
||||||
const { episodes, fetchEpisodeComments } = props
|
const { episodes } = props
|
||||||
console.log(props)
|
console.log(props)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -12,9 +14,14 @@ const Episodes = props => {
|
|||||||
<th>Episodes</th>
|
<th>Episodes</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<EpisodeList fetchEpisodeComments={fetchEpisodeComments} episodes={episodes} />
|
<EpisodeList episodes={episodes} />
|
||||||
</Table>
|
</Table>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Episodes
|
const mapState = state => {
|
||||||
|
return {
|
||||||
|
episodes: state.episodes
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export default connect(mapState)(Episodes)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user