diff --git a/src/components/Sidebar/Sidebar.jsx b/src/components/Sidebar/Sidebar.jsx index 0c78fef..daf4446 100644 --- a/src/components/Sidebar/Sidebar.jsx +++ b/src/components/Sidebar/Sidebar.jsx @@ -1,15 +1,78 @@ import { useEffect } from 'react'; -import { Divider, List, ListItem, ListItemText ,ListSubheader, ListItemIcon, Box, CircularProgress} from "@mui/material"; +import { Divider, List, ListItem, ListItemText, ListSubheader, ListItemIcon, Box, CircularProgress } from '@mui/material'; import { Link } from 'react-router-dom'; -import { useTheme} from "@mui/styles"; -import { useDispatch, useSelector} from "react-redux"; +import { useTheme } from '@mui/styles'; +import { useDispatch, useSelector } from 'react-redux'; import useStyles from './styles'; +import { useGetGenresQuery } from '../../services/TMDB'; +import { selectGenreOrCategory } from '../../features/currentGenreOrCategory'; +import genreIcons from '../../assets/genres'; + +const redLogo = 'https://fontmeme.com/permalink/210930/8531c658a743debe1e1aa1a2fc82006e.png'; +const blueLogo = 'https://fontmeme.com/permalink/210930/6854ae5c7f76597cf8680e48a2c8a50a.png'; + +const categories = [ + { label: 'Popular', value: 'popular' }, + { label: 'Top Rated', value: 'top_rated' }, + { label: 'Upcoming', value: 'upcoming' }, +]; + +function Sidebar({ setMobileOpen }) { + const theme = useTheme(); + const classes = useStyles(); + const dispatch = useDispatch(); + const { data, isFetching } = useGetGenresQuery(); + const { genreIdOrCategoryName } = useSelector((state) => state.currentGenreOrCategory); + + useEffect(() => { + setMobileOpen(false); + }, [genreIdOrCategoryName]); -function Sidebar() { return ( - <> - ) + <> + + Filmpire Logo + + + + Categories + {categories.map(({ label, value }) => ( + + dispatch(selectGenreOrCategory(value))}> + + + + + + + ))} + + + + Genres + {isFetching ? ( + + + + ) + : data?.genres?.map(({ name, id }) => ( + + dispatch(selectGenreOrCategory(id))}> + + + + + + + ))} + + + ); } -export default Sidebar; \ No newline at end of file +export default Sidebar;