Skip to content
This repository has been archived by the owner on Nov 12, 2020. It is now read-only.

Commit

Permalink
登壇者が自分で登壇情報を編集できるように修正
Browse files Browse the repository at this point in the history
  • Loading branch information
nkgrnkgr committed Mar 16, 2019
1 parent 6a733e8 commit 869c2df
Show file tree
Hide file tree
Showing 8 changed files with 201 additions and 7 deletions.
18 changes: 18 additions & 0 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import FloatButton from 'containers/FloatButton';
import OrganizerPage from 'containers/Organizer/OrganizerPage';
import List from 'containers/Organizer/List';
import Edit from 'containers/Organizer/Edit';
import EditLt from 'containers/Organizer/EditLt';
import Create from 'containers/Organizer/Create';
import LandingPage from 'components/LandingPage';
import Footer from 'components/Footer';
Expand Down Expand Up @@ -50,6 +51,23 @@ const app: React.SFC = () => (
</section>
)}
/>
<Route
path={'/editlt/:eventId/:index'}
render={props => (
<div>
<Navbar isShownSignInButtons={false} hasTabs={false} />
<div style={{ height: '50px' }} />
<section className="section cover">
<div className="container">
<AuthWrapper>
<EditLt {...props} />
</AuthWrapper>
</div>
<div style={{ height: '200px' }} />
</section>
</div>
)}
/>
<Route
path={'/events/:eventurl'}
render={props => (
Expand Down
5 changes: 4 additions & 1 deletion src/components/AnchorLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export interface AnchorLinkProps {
isExternal?: boolean;
handleOnClick?: (e: React.MouseEvent<HTMLAnchorElement>) => void;
key?: number;
style?: {};
}

const anchorLink: React.SFC<AnchorLinkProps> = ({
Expand All @@ -17,7 +18,8 @@ const anchorLink: React.SFC<AnchorLinkProps> = ({
iconClassName = '',
isExternal = false,
handleOnClick = () => {},
key = 0
key = 0,
style = {}
}) => {
const rel = isExternal ? 'noopener noreferrer' : '';
const target = isExternal ? '_blank' : '';
Expand All @@ -29,6 +31,7 @@ const anchorLink: React.SFC<AnchorLinkProps> = ({
target={target}
onClick={handleOnClick}
key={key}
style={style}
>
{iconClassName ? (
<span className="icon is-small">
Expand Down
6 changes: 3 additions & 3 deletions src/components/Organizer/Box.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react';
import { Event } from 'domain/Event';
import { getFullDate } from 'utils/DateTime';
import { eventsUrl } from 'utils/Url';
import { generateEventsUrl } from 'utils/Url';

export interface BoxProps {
event: Event;
Expand Down Expand Up @@ -33,11 +33,11 @@ const box: React.SFC<BoxProps> = ({
<p>
URL :{' '}
<a
href={eventsUrl(event.url)}
href={generateEventsUrl(event.url)}
rel="noopener noreferrer"
target="_blank"
>
{eventsUrl(event.url)}
{generateEventsUrl(event.url)}
</a>
</p>
<p>登壇タイトル</p>
Expand Down
110 changes: 110 additions & 0 deletions src/components/Organizer/EditLt.tsx
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;
14 changes: 13 additions & 1 deletion src/components/Organizer/InputForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import * as H from 'history';
import { createRandomId } from 'utils/Id';
import { Lt, createInitialValue } from 'domain/Lt';
import FormWrapper from 'components/FormWrapper';
import AnchorLink from 'components/AnchorLink';
import { generateEditLtUrl } from 'utils/Url';
export interface InputFormProps {
auth: Auth;
event?: Event;
Expand Down Expand Up @@ -148,6 +150,16 @@ const inputForm: React.SFC<InputFormProps> = ({
placeholder="https://speaker.portfolio.github.io/"
/>
</FormWrapper>
<FormWrapper labelName="直接編集用URL">
<AnchorLink
className=""
iconClassName="fas fa-external-link-square-alt"
title={`${generateEditLtUrl(values.id, index + 1)}`}
href={`${generateEditLtUrl(values.id, index + 1)}`}
isExternal={true}
style={{ display: 'block', marginTop: '5px' }}
/>
</FormWrapper>
<FormWrapper
labelName=""
classNames="is-grouped is-grouped-centered buttons"
Expand Down Expand Up @@ -264,7 +276,7 @@ const inputForm: React.SFC<InputFormProps> = ({
<hr />
<div className="field is-grouped is-grouped-centered">
<p className="control">
<button type="submit" className="button is-info is-outlined">
<button type="submit" className="button is-info">
保存
</button>
</p>
Expand Down
2 changes: 1 addition & 1 deletion src/components/UserSetting/Base.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ const base: React.SFC<BaseProps> = ({
<hr />
<div className="field is-grouped is-grouped-centered">
<p className="control">
<button type="submit" className="button is-info is-outlined">
<button type="submit" className="button is-info">
保存
</button>
</p>
Expand Down
47 changes: 47 additions & 0 deletions src/containers/Organizer/EditLt.tsx
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);
6 changes: 5 additions & 1 deletion src/utils/Url.ts
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}`;
};

0 comments on commit 869c2df

Please sign in to comment.