forked from trifrix/Mtech-Dissertation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFeed.jsx
39 lines (30 loc) · 1.29 KB
/
Feed.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import React, { useEffect, useState } from "react";
import { Box, Stack, Typography } from "@mui/material";
import { fetchFromAPI } from "../utils/fetchFromAPI";
import { Videos, Sidebar } from "./";
const Feed = () => {
const [selectedCategory, setSelectedCategory] = useState("New");
const [videos, setVideos] = useState(null);
useEffect(() => {
setVideos(null);
fetchFromAPI(`search?part=snippet&q=${selectedCategory}`)
.then((data) => setVideos(data.items))
}, [selectedCategory]);
return (
<Stack sx={{ flexDirection: { sx: "column", md: "row" } }}>
<Box sx={{ height: { sx: "auto", md: "92vh" }, borderRight: "1px solid #3d3d3d", px: { sx: 0, md: 2 } }}>
<Sidebar selectedCategory={selectedCategory} setSelectedCategory={setSelectedCategory} />
<Typography className="copyright" variant="body2" sx={{ mt: 1.5, color: "#fff", }}>
Copyright © 2022 JSM Media
</Typography>
</Box>
<Box p={2} sx={{ overflowY: "auto", height: "90vh", flex: 2 }}>
<Typography variant="h4" fontWeight="bold" mb={2} sx={{ color: "white" }}>
{selectedCategory} <span style={{ color: "#FC1503" }}>videos</span>
</Typography>
<Videos videos={videos} />
</Box>
</Stack>
);
};
export default Feed;