This repository has been archived by the owner on Nov 12, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
201 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
import * as React from 'react'; | ||
import { Formik, Field, Form, FormikActions } from 'formik'; | ||
import { Lt } from 'domain/Lt'; | ||
import { match } from 'react-router'; | ||
import FormWrapper from 'components/FormWrapper'; | ||
import { Event, Events } from 'domain/Event'; | ||
import Loading from 'components/Loading'; | ||
import * as H from 'history'; | ||
|
||
interface Params { | ||
eventId: string; | ||
index: string; | ||
} | ||
|
||
export interface EditLtProps { | ||
events: Events; | ||
firestore: Firestore; | ||
match: match<Params>; | ||
history: H.History; | ||
} | ||
|
||
const editLt: React.SFC<EditLtProps> = ({ | ||
events, | ||
match, | ||
firestore, | ||
history | ||
}) => { | ||
if (!events) return <Loading />; | ||
const event: Event = events[0]; | ||
const { index } = match.params; | ||
const lt = event.lts.find((lt, i) => { | ||
return i === parseInt(index, 10) - 1; | ||
}); | ||
|
||
const updateLt = (values: Lt) => { | ||
const ltsForUpdate = [...event.lts]; | ||
ltsForUpdate[parseInt(index, 10) - 1] = values; | ||
firestore.update( | ||
{ collection: 'events', doc: event.id }, | ||
{ | ||
lts: ltsForUpdate | ||
} | ||
); | ||
}; | ||
|
||
return ( | ||
<div> | ||
<Formik | ||
initialValues={lt} | ||
onSubmit={(values: Lt, { setSubmitting }: FormikActions<Lt>) => { | ||
setSubmitting(false); | ||
updateLt(values); | ||
alert('Saved!️'); | ||
}} | ||
render={({ values, setFieldValue }) => ( | ||
<Form> | ||
<FormWrapper labelName="登壇者情報"> | ||
<span /> | ||
</FormWrapper> | ||
<FormWrapper labelName="タイトル"> | ||
<Field | ||
className="input" | ||
name={`title`} | ||
placeholder="Kubernetes に向いてるサービス向いてないサービス" | ||
/> | ||
</FormWrapper> | ||
<FormWrapper labelName="登壇者"> | ||
<Field | ||
className="input" | ||
name={`speakerName`} | ||
placeholder="@nkgrnkgr" | ||
/> | ||
</FormWrapper> | ||
<FormWrapper labelName="リンク1"> | ||
<Field | ||
className="input" | ||
name={`documentUrl1`} | ||
placeholder="https://twitter.com/nkgrnkgr?lang=ja" | ||
/> | ||
</FormWrapper> | ||
<FormWrapper labelName="リンク2"> | ||
<Field | ||
className="input" | ||
name={`documentUrl2`} | ||
placeholder="https://speakerdeck.com/..." | ||
/> | ||
</FormWrapper> | ||
<FormWrapper labelName="リンク3"> | ||
<Field | ||
className="input" | ||
name={`documentUrl3`} | ||
placeholder="https://speaker.portfolio.github.io/" | ||
/> | ||
</FormWrapper> | ||
<hr /> | ||
<div className="field is-grouped is-grouped-centered"> | ||
<p className="control"> | ||
<button type="submit" className="button is-info"> | ||
保存 | ||
</button> | ||
</p> | ||
</div> | ||
</Form> | ||
)} | ||
/> | ||
</div> | ||
); | ||
}; | ||
|
||
export default editLt; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { connect } from 'react-redux'; | ||
import { compose, pure, setDisplayName, lifecycle } from 'recompose'; | ||
import EditLt, { EditLtProps } from 'components/Organizer/EditLt'; | ||
import { CombinedState as State } from 'reducers/root'; | ||
import { withFirestore } from 'react-redux-firebase'; | ||
import { RouteComponentProps } from 'react-router'; | ||
import { Events } from 'domain/Event'; | ||
|
||
interface StateProps { | ||
events: Events; | ||
} | ||
|
||
interface Params { | ||
eventId: string; | ||
index: string; | ||
} | ||
|
||
interface ReactRouterProps extends RouteComponentProps<Params> {} | ||
|
||
interface FirebaseProps { | ||
firestore: Firestore; | ||
} | ||
|
||
type EnhancedProps = StateProps & FirebaseProps; | ||
|
||
type FirestoreEvents = Firestore & { ordered: { events: Events } }; | ||
|
||
const mapStateToProps = (state: State) => ({ | ||
events: (state.firestore as FirestoreEvents).ordered.events | ||
}); | ||
|
||
const enhance = compose<EnhancedProps, ReactRouterProps>( | ||
setDisplayName('EnhancedEdit'), | ||
withFirestore, | ||
connect<StateProps, {}, EditLtProps>(mapStateToProps), | ||
lifecycle<EnhancedProps & ReactRouterProps, {}, {}>({ | ||
componentDidMount() { | ||
this.props.firestore.get({ | ||
collection: 'events', | ||
where: [['id', '==', this.props.match.params.eventId]] | ||
}); | ||
} | ||
}), | ||
pure | ||
); | ||
|
||
export default enhance(EditLt); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
const BASE_URL = `${location.protocol}//${location.host}`; | ||
|
||
export const eventsUrl = (id: string): string => { | ||
export const generateEventsUrl = (id: string): string => { | ||
return `${BASE_URL}/events/${id}/`; | ||
}; | ||
|
||
export const generateEditLtUrl = (id: string, index: number): string => { | ||
return `${BASE_URL}/editlt/${id}/${index}`; | ||
}; |