Skip to content
This repository was archived by the owner on Mar 3, 2020. It is now read-only.

Commit a6392d0

Browse files
committed
Creates components and redux codes for user series listing
1 parent f1ecb64 commit a6392d0

File tree

13 files changed

+113
-2
lines changed

13 files changed

+113
-2
lines changed

velog-frontend/src/components/App.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const App = () => (
3131
<Route path="/write" component={Write} />
3232
<Route exact path="/@:username/" component={User} />
3333
<Route exact path="/@:username/tags/:tag" component={User} />
34-
<Route exact path="/@:username/:tab(history|about)" component={User} />
34+
<Route exact path="/@:username/:tab(history|about|series)" component={User} />
3535
<Route path="/@:username/:urlSlug" component={Post} />
3636
<Route path="/posts/preview/:id" component={Post} />
3737
<Route path="/saves" component={Saves} />

velog-frontend/src/components/user/UserContent/UserContent.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ const UserContent = ({ type, children, side, username }: Props) => (
1717
<Link className={cx({ active: type === 'posts' })} to={`/@${username}`}>
1818
1919
</Link>
20+
<Link className={cx({ active: type === 'series' })} to={`/@${username}/series`}>
21+
시리즈
22+
</Link>
2023
<Link className={cx({ active: type === 'history' })} to={`/@${username}/history`}>
2124
활동
2225
</Link>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// @flow
2+
import React from 'react';
3+
import './UserSeriesList.scss';
4+
import UserSeriesListItem from '../UserSeriesListItem';
5+
6+
type Props = {};
7+
const UserSeriesList = (props: Props) => {
8+
return (
9+
<div>
10+
<UserSeriesListItem />
11+
<UserSeriesListItem />
12+
<UserSeriesListItem />
13+
<UserSeriesListItem />
14+
<UserSeriesListItem />
15+
<UserSeriesListItem />
16+
</div>
17+
);
18+
};
19+
20+
export default UserSeriesList;

velog-frontend/src/components/user/UserSeriesList/UserSeriesList.scss

Whitespace-only changes.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// @flow
2+
export { default } from './UserSeriesList';
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// @flow
2+
import React from 'react';
3+
import './UserSeriesListItem.scss';
4+
5+
type Props = {};
6+
const UserSeriesListItem = (props: Props) => {
7+
return <div>wat</div>;
8+
};
9+
10+
export default UserSeriesListItem;

velog-frontend/src/components/user/UserSeriesListItem/UserSeriesListItem.scss

Whitespace-only changes.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// @flow
2+
export { default } from './UserSeriesListItem';

velog-frontend/src/containers/post/PostViewer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ class PostViewer extends Component<Props> {
182182
url={this.props.match.url}
183183
informCopy={this.informCopy}
184184
/>
185-
{post.series && <PostSeriesInfo series={post.series} username={username} />}
185+
{post.series && <PostSeriesInfo series={post.series} username={username || ''} />}
186186
<PostContent
187187
thumbnail={post.thumbnail}
188188
body={post.body}

velog-frontend/src/containers/user/UserContentContainer.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { compose } from 'redux';
1111
import UserPostsSubpage from 'pages/user/UserPostsSubpage';
1212
import UserHistorySubpage from '../../pages/user/UserHistorySubpage';
1313
import UserAboutSubpage from '../../pages/user/UserAboutSubpage';
14+
import UserSeriesSubpage from '../../pages/user/UserSeriesSubpage';
1415

1516
type Props = {
1617
match: Match,
@@ -62,6 +63,7 @@ class UserContentContainer extends Component<Props> {
6263
}
6364
>
6465
<Route exact path="/@:username" component={UserPostsSubpage} />
66+
<Route path="/@:username/series" component={UserSeriesSubpage} />
6567
<Route path="/@:username/history" component={UserHistorySubpage} />
6668
<Route path="/@:username/tags/:tag" component={UserPostsSubpage} />
6769
<Route path="/@:username/about" component={UserAboutSubpage} />
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// @flow
2+
import React, { Component } from 'react';
3+
import { ProfileActions } from 'store/actionCreators';
4+
import { withRouter, type ContextRouter } from 'react-router-dom';
5+
import UserSeriesList from 'components/user/UserSeriesList/UserSeriesList';
6+
7+
type Props = {} & ContextRouter;
8+
class UserSeriesContainer extends Component<Props> {
9+
initialize = async () => {
10+
const { username } = this.props.match.params;
11+
try {
12+
if (!username) return;
13+
await ProfileActions.getSeriesList(username);
14+
} catch (e) {
15+
console.log(e);
16+
}
17+
};
18+
componentDidMount() {
19+
ProfileActions.setSideVisibility(false);
20+
this.initialize();
21+
}
22+
23+
componentWillUnmount() {
24+
ProfileActions.setSideVisibility(true);
25+
}
26+
27+
render() {
28+
return <UserSeriesList />;
29+
}
30+
}
31+
32+
export default withRouter(UserSeriesContainer);
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// @flow
2+
import React from 'react';
3+
import UserSeriesContainer from '../../containers/user/UserSeriesContainer';
4+
5+
type Props = {};
6+
const UserSeriesSubpage = (props: Props) => {
7+
return <UserSeriesContainer />;
8+
};
9+
10+
export default UserSeriesSubpage;

velog-frontend/src/store/modules/profile.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import * as UsersAPI from 'lib/api/users';
66
import * as CommonAPI from 'lib/api/common';
77
import type { ProfileLinks } from 'store/modules/settings';
88
import * as MeAPI from 'lib/api/me';
9+
import * as SeriesAPI from 'lib/api/series';
910

1011
const GET_USER_TAGS = 'profile/GET_USER_TAGS';
1112
const GET_PROFILE = 'profile/GET_PROFILE';
@@ -17,6 +18,7 @@ const GET_USER_HISTORY = 'profile/GET_USER_HISTORY';
1718
const REVEAL_PREFETCHED_HISTORY = 'profile/REVEAL_PREFETCHED_HISTORY';
1819
const PREFETCH_USER_HISTORY = 'profile/PREFETCH_USER_HISTORY';
1920
const UPDATE_ABOUT = 'profile/UPDATE_ABOUT';
21+
const GET_SERIES_LIST = 'profile/GET_SERIES_LIST';
2022

2123
export const actionCreators = {
2224
initialize: createAction(INITIALIZE),
@@ -29,6 +31,7 @@ export const actionCreators = {
2931
revealPrefetchedHistory: createAction(REVEAL_PREFETCHED_HISTORY),
3032
prefetchUserHistory: createAction(PREFETCH_USER_HISTORY, UsersAPI.getHistory),
3133
updateAbout: createAction(UPDATE_ABOUT, MeAPI.updateAbout, (meta: string) => meta),
34+
getSeriesList: createAction(GET_SERIES_LIST, SeriesAPI.getSeriesList),
3235
};
3336

3437
export type TagCountInfo = {
@@ -83,11 +86,27 @@ export type UserHistoryItem = {
8386
},
8487
};
8588

89+
export type SeriesItemData = {
90+
id: string,
91+
name: string,
92+
description: string,
93+
thumbnail: string,
94+
url_slug: string,
95+
created_at: string,
96+
updated_at: string,
97+
user: {
98+
username: string,
99+
thumbnail: string,
100+
},
101+
};
102+
86103
type SetRawTagNameAction = ActionType<typeof actionCreators.setRawTagName>;
87104
type GetTagInfoResponseAction = GenericResponseAction<TagData, string>;
88105
type SetSideVisibilityAction = ActionType<typeof actionCreators.setSideVisibility>;
89106
type GetUserHistoryResponseAction = GenericResponseAction<UserHistoryItem[], any>;
90107
type UpdateAboutResponseAction = GenericResponseAction<{ about: string }, string>;
108+
type GetSeriesListResponseAction = GenericResponseAction<SeriesItemData, any>;
109+
91110

92111
export type ProfileState = {
93112
tagCounts: ?(TagCountInfo[]),
@@ -98,6 +117,7 @@ export type ProfileState = {
98117
side: boolean,
99118
historyEnd: false,
100119
prevAbout: string,
120+
seriesList: ?(SeriesItemData[]),
101121
};
102122

103123
const initialState = {
@@ -109,6 +129,7 @@ const initialState = {
109129
side: true,
110130
historyEnd: false,
111131
prevAbout: '',
132+
seriesList: null,
112133
};
113134

114135
const reducer = handleActions(
@@ -221,4 +242,13 @@ export default applyPenders(reducer, [
221242
});
222243
},
223244
},
245+
{
246+
type: GET_SERIES_LIST,
247+
onSuccess: (state: ProfileState, { payload }: GetSeriesListResponseAction) => {
248+
return {
249+
...state,
250+
seriesList: payload.data,
251+
};
252+
},
253+
},
224254
]);

0 commit comments

Comments
 (0)