@@ -2,9 +2,12 @@ import { Button } from 'components/atoms/Button'
2
2
import { Li , Ol , Ul } from 'components/atoms/ContentWrappers'
3
3
import { Empty } from 'components/atoms/Empty'
4
4
import { Loading } from 'components/atoms/Loading'
5
- import { isFuture , isPast } from 'date-fns'
6
- import { talkProposal } from 'dates'
5
+ import CFPEdit from 'components/organisms/CFPForm/CFPEdit'
6
+ import CFSEdit from 'components/organisms/SponsorForm/CFSEdit'
7
+ import { isFuture } from 'date-fns'
8
+ import { callForSponsors , talkProposal } from 'dates'
7
9
import { DurationNode , LanguageNode } from 'lib/apollo_graphql/__generated__/globalTypes'
10
+ import _ from 'lodash'
8
11
import marksy from 'marksy'
9
12
import { toJS } from 'mobx'
10
13
import { inject , observer } from 'mobx-react'
@@ -13,80 +16,139 @@ import { StoresType } from 'pages/_app'
13
16
import React from 'react'
14
17
import { paths } from 'routes/paths'
15
18
import { TEAL } from 'styles/colors'
16
- import CFPEdit from 'components/organisms/CFPForm/CFPEdit' ;
19
+
20
+ type PropsType = {
21
+ stores : StoresType ;
22
+ router : RouterProps ;
23
+ }
24
+
25
+ enum storeTypesEnum {
26
+ CFP = 'cfpStore' ,
27
+ CFS = 'sponsorStore'
28
+
29
+ }
17
30
18
31
@inject ( 'stores' )
19
32
@withRouter
20
33
@observer
21
- class MyContribution extends React . Component < {
22
- stores : StoresType ;
23
- router : RouterProps ;
24
- } > {
34
+ class MyContribution extends React . Component < PropsType > {
25
35
state = {
26
- edit : false
36
+ cfpEdit : false ,
37
+ cfsEdit : false
38
+ }
39
+
40
+ onCFSEdit = ( ) => this . setState ( { cfsEdit : true } )
41
+ onCFPEdit = ( ) => this . setState ( { cfpEdit : true } )
42
+ onCancelCFPEdit = ( ) => this . setState ( { cfpEdit : false } )
43
+ onCancelCFSEdit = ( ) => this . setState ( { cfsEdit : false } )
44
+
45
+ renderEditButton ( storeType : storeTypesEnum ) {
46
+ const { stores } = this . props
47
+ const proposal = stores && stores [ storeType ] && stores [ storeType ] . proposal
48
+ const isSumitted = proposal && proposal . submitted
49
+ const onEdit = storeType === storeTypesEnum . CFP
50
+ ? this . onCFPEdit
51
+ : this . onCFSEdit
52
+ const linkPath = storeType === storeTypesEnum . CFP
53
+ ? paths . contribute . proposingATalk
54
+ : paths . sponsor . applicationForm
55
+
56
+ return (
57
+ isSumitted
58
+ ? < Button
59
+ intlKey = 'asdfsd'
60
+ tag = 'button'
61
+ color = { TEAL }
62
+ primary = { false }
63
+ size = 'small'
64
+ style = { { marginBottom : 20 } }
65
+ onClick = { onEdit }
66
+ > μμ μ μΆνκΈ°</ Button >
67
+ : < Button
68
+ intlKey = 'asdfsd'
69
+ to = { linkPath }
70
+ color = { TEAL }
71
+ primary = { false }
72
+ size = 'small'
73
+ style = { { marginBottom : 20 } }
74
+ > μ΄μ΄μ μμ±νλ¬ κ°κΈ°</ Button >
75
+ )
27
76
}
28
77
29
78
render ( ) {
30
79
const { stores } = this . props
31
- const { proposal } = toJS ( stores . cfpStore )
80
+ const { sponsorStore, cfpStore } = stores
81
+ const { cfsEdit, cfpEdit } = this . state
82
+ const { proposal : cfpProposal } = toJS ( cfpStore )
83
+ const { proposal : sponsorProposal } = toJS ( sponsorStore )
32
84
33
- if ( ! stores . cfpStore . isInitialized ) {
85
+ if ( ! stores . cfpStore . isInitialized || ! stores . sponsorStore . isInitialized ) {
34
86
return < Loading width = { 50 } height = { 50 } />
35
87
}
36
88
37
- if ( proposal === null ) {
89
+ if ( _ . isNil ( cfpProposal ) && _ . isNil ( sponsorProposal ) ) {
38
90
return < Empty />
39
91
}
40
92
41
- return < Ol >
42
- < Li > λ°νμ μ μ: < span style = { { fontWeight : 700 } } > { proposal . submitted ? 'μ μΆ μλ£λ¨.' : 'μμ μ μ₯λ¨.' } </ span > < br />
43
- { isFuture ( talkProposal . close )
44
- ? proposal . submitted
45
- ? < Button
46
- intlKey = 'asdfsd'
47
- tag = 'button'
48
- color = { TEAL }
49
- primary = { false }
50
- size = 'small'
51
- style = { { marginBottom : 20 } }
52
- onClick = { ( ) => this . setState ( { edit : true } ) }
53
- > μμ μ μΆνκΈ°</ Button >
54
- : < Button
55
- intlKey = 'asdfsd'
56
- link = { paths . contribute . proposingATalk }
57
- color = { TEAL }
58
- primary = { false }
59
- size = 'small'
60
- style = { { marginBottom : 20 } }
61
- > μ΄μ΄μ μμ±νλ¬ κ°κΈ°</ Button >
62
- : 'μ μΆ κΈ°νμ΄ λ§κ°λμμ΅λλ€.'
93
+ const isCFPClosed = isFuture ( talkProposal . close )
94
+ const isCFSClosed = isFuture ( callForSponsors . close )
95
+
96
+ return (
97
+ < Ol >
98
+ { cfpProposal &&
99
+ < Li >
100
+ λ°νμ μ μ: < span style = { { fontWeight : 700 } } > { cfpProposal . submitted ? 'μ μΆ μλ£λ¨.' : 'μμ μ μ₯λ¨.' } </ span > < br />
101
+ { isCFPClosed
102
+ ? this . renderEditButton ( storeTypesEnum . CFP )
103
+ : 'μ μΆ κΈ°νμ΄ λ§κ°λμμ΅λλ€.'
104
+ }
105
+ { cfpEdit
106
+ ? < CFPEdit
107
+ stores = { stores }
108
+ onCancel = { this . onCancelCFPEdit }
109
+ />
110
+ : < Ul >
111
+ < Li > μ£Όμ : { cfpProposal . name } </ Li >
112
+ < Li > μΉ΄ν
κ³ λ¦¬: { cfpProposal . category ? cfpProposal . category ! . name : '' } </ Li >
113
+ < Li > μΈμ
κΈΈμ΄: { cfpProposal . duration === DurationNode . LONG ? '45λΆ' : '25λΆ' } </ Li >
114
+ < Li > μΈμ΄: { cfpProposal . language === LanguageNode . ENGLISH ? 'English' : 'νκ΅μ΄' } </ Li >
115
+ < Li > λμ΄λ: { cfpProposal . difficulty ? cfpProposal . difficulty ! . name : '' } </ Li >
116
+ < Li > μ μμ μμΈν λ΄μ©: {
117
+ marksy ( { createElement : React . createElement } ) (
118
+ cfpProposal . detailDesc
119
+ ) . tree
120
+ } </ Li >
121
+ < Li > μ΄λ―Έ λ€λ₯Έ κ³³μ λ°νν λ΄μ©μΈκ°μ?: { cfpProposal . isPresentedBefore ? 'μ' : 'μλμ€' } </ Li >
122
+ < Li > λ°νν νμ¬: { cfpProposal . placePresentedBefore || '-' } </ Li >
123
+ < Li > λ°ν μλ£ λ§ν¬: { cfpProposal . presentedSlideUrlBefore
124
+ ? < a href = { cfpProposal . presentedSlideUrlBefore } > { cfpProposal . presentedSlideUrlBefore } </ a >
125
+ : '-'
126
+ } </ Li >
127
+ < Li > μ°Έκ³ λ° μ§λ¬Έ μ¬ν: { cfpProposal . comment || '-' } </ Li >
128
+ </ Ul >
129
+ }
130
+ </ Li >
63
131
}
64
- { this . state . edit
65
- ? < CFPEdit onCancel = { ( ) => this . setState ( {
66
- edit : false
67
- } ) } />
68
- : < Ul >
69
- < Li > μ£Όμ : { proposal . name } </ Li >
70
- < Li > μΉ΄ν
κ³ λ¦¬: { proposal . category ? proposal . category ! . name : '' } </ Li >
71
- < Li > μΈμ
κΈΈμ΄: { proposal . duration === DurationNode . LONG ? '45λΆ' : '25λΆ' } </ Li >
72
- < Li > μΈμ΄: { proposal . language === LanguageNode . ENGLISH ? 'English' : 'νκ΅μ΄' } </ Li >
73
- < Li > λμ΄λ: { proposal . difficulty ? proposal . difficulty ! . name : '' } </ Li >
74
- < Li > μ μμ μμΈν λ΄μ©: {
75
- marksy ( { createElement : React . createElement } ) (
76
- proposal . detailDesc
77
- ) . tree
78
- } </ Li >
79
- < Li > μ΄λ―Έ λ€λ₯Έ κ³³μ λ°νν λ΄μ©μΈκ°μ?: { proposal . isPresentedBefore ? 'μ' : 'μλμ€' } </ Li >
80
- < Li > λ°νν νμ¬: { proposal . placePresentedBefore || '-' } </ Li >
81
- < Li > λ°ν μλ£ λ§ν¬: { proposal . presentedSlideUrlBefore
82
- ? < a href = { proposal . presentedSlideUrlBefore } > { proposal . presentedSlideUrlBefore } </ a >
83
- : '-'
84
- } </ Li >
85
- < Li > μ°Έκ³ λ° μ§λ¬Έ μ¬ν: { proposal . comment || '-' } </ Li >
86
- </ Ul >
132
+ { sponsorProposal &&
133
+ < Li >
134
+ μ€ν°μ μ μ: < span style = { { fontWeight : 700 } } > { sponsorProposal . submitted ? 'μ μΆ μλ£λ¨.' : 'μμ μ μ₯λ¨.' } </ span > < br />
135
+ { isCFSClosed
136
+ ? this . renderEditButton ( storeTypesEnum . CFS )
137
+ : 'μ μΆ κΈ°νμ΄ λ§κ°λμμ΅λλ€.'
138
+ }
139
+ { cfsEdit
140
+ ? < CFSEdit
141
+ sponsorStore = { sponsorStore }
142
+ onCancel = { this . onCancelCFSEdit }
143
+ />
144
+ : < Ul >
145
+ < Li > μ£Όμ : { sponsorProposal . nameKo } </ Li >
146
+ </ Ul >
147
+ }
148
+ </ Li >
87
149
}
88
- </ Li >
89
- </ Ol >
150
+ </ Ol >
151
+ )
90
152
}
91
153
}
92
154
0 commit comments