@@ -10,43 +10,36 @@ import Prism from 'mastani-codehighlight'
1010
1111import { Wrapper } from './styles'
1212
13- // import { NotFound , CheatSheetLoading } from '../../components'
13+ import { EmptyThread , CheatSheetLoading } from '../../components'
1414
1515import Cheatsheet from './Cheatsheet'
1616import Note from './Note'
1717
18- import { makeDebugger , storePlug } from '../../utils'
18+ import { makeDebugger , storePlug , TYPE } from '../../utils'
1919import * as logic from './logic'
2020/* eslint-disable no-unused-vars */
2121const debug = makeDebugger ( 'C:CheatsheetThread' )
2222/* eslint-enable no-unused-vars */
2323
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 : {
3127 return < CheatSheetLoading />
3228 }
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" />
3831 }
39- case 'loaded': {
40- return <Cheatsheet source={source} />
32+ default : {
33+ return (
34+ < Cheatsheet
35+ source = { cheatsheetData . readme }
36+ communityRaw = { communityRaw }
37+ />
38+ )
4139 }
42- case 'parse_error': {
43- return <h3>parse error</h3>
44- }
45- default:
46- return <div>default</div>
4740 }
4841}
49- */
42+ // TODO: NOT_FOUND, parse_error
5043
5144class CheatsheetThreadContainer extends React . Component {
5245 componentWillMount ( ) {
@@ -60,17 +53,19 @@ class CheatsheetThreadContainer extends React.Component {
6053
6154 render ( ) {
6255 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
6958
7059 return (
7160 < 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+ />
7469 </ Wrapper >
7570 )
7671 }
0 commit comments