Skip to content

Commit 217f238

Browse files
author
jslee
committed
Add call-for-sponsors edit page
1 parent b6da59f commit 217f238

File tree

10 files changed

+646
-112
lines changed

10 files changed

+646
-112
lines changed

β€Žcomponents/organisms/CFPForm/CFPEdit.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { FormWrapper, SelectWrapper } from 'components/atoms/ContentWrappers'
33
import { FlexSpaceBetweenWrapper } from 'components/atoms/FlexWrapper'
44
import { IntlText } from 'components/atoms/IntlText'
55
import { DurationNode, LanguageNode } from 'lib/apollo_graphql/__generated__/globalTypes'
6-
import { inject, observer } from 'mobx-react'
6+
import { observer } from 'mobx-react'
77
import { StoresType } from 'pages/_app'
88
import React from 'react'
99
import intl from 'react-intl-universal'
@@ -25,9 +25,8 @@ interface State {
2525
comment: string
2626
}
2727

28-
@inject('stores')
2928
@observer
30-
export default class CFPEdit extends React.Component<{stores: StoresType; onCancel: VoidFunction}, State> {
29+
export default class CFPEdit extends React.Component<{stores: StoresType; onCancel(): void }, State> {
3130
state = {
3231
name: '',
3332
categoryId: '1',
@@ -43,7 +42,8 @@ export default class CFPEdit extends React.Component<{stores: StoresType; onCanc
4342
}
4443

4544
async componentDidMount() {
46-
const { proposal } = this.props.stores.cfpStore
45+
const { stores } = this.props
46+
const { proposal } = stores.cfpStore
4747

4848
if (!proposal) {
4949
return

β€Žcomponents/organisms/MyContribution/index.tsx

Lines changed: 120 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@ import { Button } from 'components/atoms/Button'
22
import { Li, Ol, Ul } from 'components/atoms/ContentWrappers'
33
import { Empty } from 'components/atoms/Empty'
44
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'
79
import { DurationNode, LanguageNode } from 'lib/apollo_graphql/__generated__/globalTypes'
10+
import _ from 'lodash'
811
import marksy from 'marksy'
912
import { toJS } from 'mobx'
1013
import { inject, observer } from 'mobx-react'
@@ -13,80 +16,139 @@ import { StoresType } from 'pages/_app'
1316
import React from 'react'
1417
import { paths } from 'routes/paths'
1518
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+
}
1730

1831
@inject('stores')
1932
@withRouter
2033
@observer
21-
class MyContribution extends React.Component<{
22-
stores: StoresType;
23-
router: RouterProps;
24-
}> {
34+
class MyContribution extends React.Component<PropsType> {
2535
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+
)
2776
}
2877

2978
render() {
3079
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)
3284

33-
if (!stores.cfpStore.isInitialized) {
85+
if (!stores.cfpStore.isInitialized || !stores.sponsorStore.isInitialized) {
3486
return <Loading width={50} height={50}/>
3587
}
3688

37-
if (proposal === null) {
89+
if (_.isNil(cfpProposal) && _.isNil(sponsorProposal)) {
3890
return <Empty />
3991
}
4092

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>
63131
}
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>
87149
}
88-
</Li>
89-
</Ol>
150+
</Ol>
151+
)
90152
}
91153
}
92154

0 commit comments

Comments
Β (0)