@@ -10,43 +10,36 @@ import Prism from 'mastani-codehighlight'
10
10
11
11
import { Wrapper } from './styles'
12
12
13
- // import {NotFound , CheatSheetLoading } from '../../components'
13
+ import { EmptyThread , CheatSheetLoading } from '../../components'
14
14
15
15
import Cheatsheet from './Cheatsheet'
16
16
import Note from './Note'
17
17
18
- import { makeDebugger , storePlug } from '../../utils'
18
+ import { makeDebugger , storePlug , TYPE } from '../../utils'
19
19
import * as logic from './logic'
20
20
/* eslint-disable no-unused-vars */
21
21
const debug = makeDebugger ( 'C:CheatsheetThread' )
22
22
/* eslint-enable no-unused-vars */
23
23
24
- /*
25
- const renderContent = (source, state, errMsg) => {
26
- switch (state) {
27
- case 'init': {
28
- return <div>init la</div>
29
- }
30
- case 'loading': {
24
+ const renderView = ( cheatsheetData , type , communityRaw ) => {
25
+ switch ( type ) {
26
+ case TYPE . LOADING :{
31
27
return < CheatSheetLoading />
32
28
}
33
- case '404': {
34
- return <NotFound />
35
- }
36
- case 'empty': {
37
- return <div>isEmpty</div>
29
+ case TYPE . NOT_FOUND :{
30
+ return < EmptyThread community = { communityRaw } thread = "cheatsheet" />
38
31
}
39
- case 'loaded': {
40
- return <Cheatsheet source={source} />
32
+ default :{
33
+ return (
34
+ < Cheatsheet
35
+ source = { cheatsheetData . readme }
36
+ communityRaw = { communityRaw }
37
+ />
38
+ )
41
39
}
42
- case 'parse_error': {
43
- return <h3>parse error</h3>
44
- }
45
- default:
46
- return <div>default</div>
47
40
}
48
41
}
49
- */
42
+ // TODO: NOT_FOUND, parse_error
50
43
51
44
class CheatsheetThreadContainer extends React . Component {
52
45
componentWillMount ( ) {
@@ -60,17 +53,19 @@ class CheatsheetThreadContainer extends React.Component {
60
53
61
54
render ( ) {
62
55
const { cheatsheetThread} = this . props
63
- const { sourceData/* state, errMsg */ } = cheatsheetThread
64
-
65
- // console.log('sourceData --> ', sourceData)
66
- // <div>{renderContent(source, state, errMsg)}</div>
67
-
68
- // <div>{renderContent(sourceData, state, errMsg)}</div>
56
+ const { cheatsheetData, curView, curCommunity} = cheatsheetThread
57
+ const communityRaw = curCommunity . raw
69
58
70
59
return (
71
60
< Wrapper >
72
- < Cheatsheet source = { sourceData } />
73
- < Note />
61
+ { renderView ( cheatsheetData , curView , communityRaw ) }
62
+ < Note
63
+ onSync = { logic . syncCheetsheetFromGithub }
64
+ contributors = { cheatsheetData . contributors }
65
+ views = { cheatsheetData . views }
66
+ addContributor = { logic . addContributor }
67
+ curView = { curView }
68
+ />
74
69
</ Wrapper >
75
70
)
76
71
}