Skip to content

Commit 46a1cec

Browse files
committed
feat: 내 비디오 불러오는 로직
MyPage에서 비디오 불러오기
1 parent afa633a commit 46a1cec

File tree

5 files changed

+117
-22
lines changed

5 files changed

+117
-22
lines changed

.gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.mp4 filter=lfs diff=lfs merge=lfs -text

src/lib/api/media.js

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
export const load = (user) => {
2+
return {
3+
data: [
4+
{
5+
src: "",
6+
userId: "",
7+
videoName: "제목제목",
8+
videoUrl: "",
9+
videoType: "",
10+
videoLanguage: "",
11+
},
12+
{
13+
src: "",
14+
userId: "",
15+
videoName: "제목제목",
16+
videoUrl: "",
17+
videoType: "",
18+
videoLanguage: "",
19+
},
20+
{
21+
src: "",
22+
userId: "",
23+
videoName: "제목제목",
24+
videoUrl: "",
25+
videoType: "",
26+
videoLanguage: "",
27+
},
28+
{
29+
src: "",
30+
userId: "",
31+
videoName: "제목제목",
32+
videoUrl: "",
33+
videoType: "",
34+
videoLanguage: "",
35+
},
36+
{
37+
src: "",
38+
userId: "",
39+
videoName: "제목제목",
40+
videoUrl: "",
41+
videoType: "",
42+
videoLanguage: "",
43+
},
44+
{
45+
src: "",
46+
userId: "",
47+
videoName: "제목제목",
48+
videoUrl: "",
49+
videoType: "",
50+
videoLanguage: "",
51+
},
52+
{
53+
src: "",
54+
userId: "",
55+
videoName: "제목제목",
56+
videoUrl: "",
57+
videoType: "",
58+
videoLanguage: "",
59+
},
60+
],
61+
};
62+
};

src/modules/index.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import { combineReducers } from "redux";
22
import user from "./user";
3+
import media from "./media";
34

45
const rootReducer = combineReducers({
56
user,
7+
media,
68
});
79

810
export default rootReducer;

src/modules/media.js

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { handleActions } from "redux-actions";
2+
import * as mediaAPI from "../lib/api/media";
3+
import createRequestThunk, {
4+
createRequestActionTypes,
5+
} from "../lib/createRequestThunk";
6+
7+
const [LOAD, LOAD_SUCCESS, LOAD_FAILURE] =
8+
createRequestActionTypes("media/LOAD");
9+
10+
export const load = createRequestThunk(LOAD, mediaAPI.load);
11+
12+
const initialState = {
13+
media: null,
14+
};
15+
16+
export default handleActions(
17+
{
18+
[LOAD_SUCCESS]: (state, { payload: media }) => ({
19+
...state,
20+
media,
21+
error: null,
22+
}),
23+
[LOAD_FAILURE]: (state, { payload: error }) => ({
24+
...state,
25+
media: null,
26+
error,
27+
}),
28+
},
29+
initialState,
30+
);

src/pages/Mypage.js

+22-22
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { Col, Row } from "antd";
22
import { useState, useEffect } from "react";
33
import { Link } from "react-router-dom";
4+
import { useDispatch, useSelector } from "react-redux";
5+
import { load } from "../modules/media";
46
import styled from "styled-components";
57

68
const Container = styled.div`
@@ -19,35 +21,33 @@ const StyledLink = styled(Link)`
1921
`;
2022

2123
function Mypage() {
22-
const [videos, setVideos] = useState([]);
24+
const dispatch = useDispatch();
25+
const { media, user } = useSelector(({ media, user }) => ({
26+
media: media.media,
27+
user: user.user,
28+
}));
2329

2430
useEffect(() => {
25-
setVideos([
26-
{ id: 1, title: "Video1", thumbnail: "" },
27-
{ id: 2, title: "Video2", thumbnail: "" },
28-
{ id: 3, title: "Video3", thumbnail: "" },
29-
{ id: 4, title: "Video4", thumbnail: "" },
30-
{ id: 5, title: "Video5", thumbnail: "" },
31-
{ id: 6, title: "Video6", thumbnail: "" },
32-
]);
33-
}, []);
31+
dispatch(load(user));
32+
}, [dispatch, user]);
3433

3534
return (
3635
<Container>
3736
<h2 style={{ fontWeight: "bold" }}>자막이 생성된 미디어</h2>
3837
<Row gutter={[16, 16]} style={{ marginTop: "30px" }}>
39-
{videos.map((video) => (
40-
<StyledLink to="/result">
41-
<Col id={video.id} style={{ display: "flex", width: 460 }}>
42-
<img
43-
alt={video.id}
44-
height="160"
45-
src="https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2Fvckff%2FbtqCjeJmBHM%2FtMVpe4aUIMfH4nKS4aO3tK%2Fimg.jpg"
46-
/>
47-
<VideoTitle>{video.title}</VideoTitle>
48-
</Col>
49-
</StyledLink>
50-
))}
38+
{media &&
39+
media.map((video) => (
40+
<StyledLink to="/result">
41+
<Col id={video.id} style={{ display: "flex", width: 460 }}>
42+
<img
43+
alt={video.id}
44+
height="160"
45+
src="https://img1.daumcdn.net/thumb/R1280x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2Fvckff%2FbtqCjeJmBHM%2FtMVpe4aUIMfH4nKS4aO3tK%2Fimg.jpg"
46+
/>
47+
<VideoTitle>{video.videoName}</VideoTitle>
48+
</Col>
49+
</StyledLink>
50+
))}
5151
</Row>
5252
</Container>
5353
);

0 commit comments

Comments
 (0)