{
display: 'flex',
justifyContent: 'flex-start',
alignItems: 'center',
- // flexDirection: "column",
}}
>
-
+
history.push('/')}>
{isBackButtonRequired && (
diff --git a/src/constants/logoConstant.js b/src/constants/logoConstant.js
index 7b2c99a..a741fc9 100644
--- a/src/constants/logoConstant.js
+++ b/src/constants/logoConstant.js
@@ -2,12 +2,13 @@ export const logoStyleObject = {
width: 110,
height: 70,
zIndex: 100,
- margin: "1rem",
+ margin: '1rem',
+ cursor: 'pointer',
};
export const logoStyleMobileView = {
width: 70,
height: 50,
zIndex: 100,
- margin: "1rem",
+ margin: '1rem',
};
diff --git a/src/containers/AnimeStatisticsGraph/AnimeStatisticsGraphContainer.js b/src/containers/AnimeStatisticsGraph/AnimeStatisticsGraphContainer.js
new file mode 100644
index 0000000..5839d93
--- /dev/null
+++ b/src/containers/AnimeStatisticsGraph/AnimeStatisticsGraphContainer.js
@@ -0,0 +1,23 @@
+import React from 'react';
+import { Redirect } from 'react-router-dom';
+import Header from 'components/Header/Header';
+import { useAuthentication } from 'custom-hooks/authHook';
+
+const AnimeStatisticsGraphContainer = () => {
+ const { isAuthenticated } = useAuthentication();
+
+ if (!isAuthenticated) {
+ return
;
+ }
+ return (
+ <>
+
+ >
+ );
+};
+
+export default AnimeStatisticsGraphContainer;
diff --git a/src/containers/CustomDrawerContainer/DrawerContainer.js b/src/containers/CustomDrawerContainer/DrawerContainer.js
index 173dd9f..af3e818 100644
--- a/src/containers/CustomDrawerContainer/DrawerContainer.js
+++ b/src/containers/CustomDrawerContainer/DrawerContainer.js
@@ -5,6 +5,7 @@ import { useLogOut } from '../../custom-hooks/authHook';
import { useDarkMode } from '../../custom-hooks/darkModeHook';
import { drawerClose } from '../../actions/drawerAction';
import {} from '../../actions/dialogAction';
+import { useDrawer } from 'custom-hooks/drawerHook';
const DrawerContainer = () => {
const { handleLogoutButtonClick } = useLogOut();
@@ -12,6 +13,7 @@ const DrawerContainer = () => {
const isDrawerOpen = useSelector(selectIsDrawerOpen);
const dispatch = useDispatch();
const { handleDarkModeClick } = useDarkMode();
+ const { handleIconClick, screenName } = useDrawer();
const handleDrawerClose = () => {
dispatch(drawerClose());
@@ -23,6 +25,8 @@ const DrawerContainer = () => {
open={isDrawerOpen}
onClose={handleDrawerClose}
handleDarkModeClick={handleDarkModeClick}
+ onIconClick={handleIconClick}
+ screenName={screenName}
/>
);
};
diff --git a/src/custom-hooks/animeHook.js b/src/custom-hooks/animeHook.js
index 3098853..f606d6d 100644
--- a/src/custom-hooks/animeHook.js
+++ b/src/custom-hooks/animeHook.js
@@ -1,5 +1,6 @@
import { useCallback, useEffect, useState } from 'react';
import { useDispatch, useSelector } from 'react-redux';
+import { isEmpty } from 'lodash';
import {
openAnimeDeleteDialog,
closeAnimeDeleteDialog,
@@ -69,7 +70,7 @@ export const useAnime = () => {
};
const fetchAnimes = useCallback(() => {
- dispatch(getAnimeWatchlistStart());
+ if (isEmpty(animeWatchlist)) dispatch(getAnimeWatchlistStart());
}, [dispatch]);
return {
diff --git a/src/custom-hooks/authHook.js b/src/custom-hooks/authHook.js
index e238715..1a5bfc4 100644
--- a/src/custom-hooks/authHook.js
+++ b/src/custom-hooks/authHook.js
@@ -2,6 +2,7 @@
import { useState, useCallback, useEffect } from 'react';
import { useDispatch, useSelector } from 'react-redux';
import qs from 'query-string';
+import { isEmpty } from 'lodash';
import {
loginAPIStart,
getMeAPIStart,
@@ -95,7 +96,9 @@ export const useGetMe = () => {
const userDetails = useSelector((state) => state.auth.user);
const getCurrentUser = useCallback(() => {
- dispatch(getMeAPIStart());
+ if (isEmpty(userDetails)) {
+ dispatch(getMeAPIStart());
+ }
}, [dispatch]);
return {
@@ -117,8 +120,6 @@ export const useVerifyAccount = (props) => {
}
}, [email, token]);
- console.log({ isUserVerifying, isUserVerified });
-
return {
isUserVerifying,
isUserVerified,
diff --git a/src/custom-hooks/drawerHook.js b/src/custom-hooks/drawerHook.js
new file mode 100644
index 0000000..9763ae7
--- /dev/null
+++ b/src/custom-hooks/drawerHook.js
@@ -0,0 +1,57 @@
+import { useEffect } from 'react';
+import { useHistory } from 'react-router-dom';
+import { useSelector, useDispatch } from 'react-redux';
+import { setScreenNameAction } from 'actions/drawerAction';
+
+export const screenNames = {
+ Dashboard: 'dashboard',
+ Statistics: 'statistics',
+ Profile: 'profile',
+};
+
+const selectScreenName = ({ drawer: { screenName = '' } = {} }) => screenName;
+
+export const useDrawer = () => {
+ const history = useHistory();
+ const dispatch = useDispatch();
+ const screenName = useSelector(selectScreenName);
+
+ useEffect(() => {
+ if (window.location.pathname) {
+ switch (window.location.pathname) {
+ case '/dashboard':
+ dispatch(setScreenNameAction({ screenName: screenNames.Dashboard }));
+ break;
+ case '/profile':
+ dispatch(setScreenNameAction({ screenName: screenNames.Profile }));
+ break;
+ case '/statistics':
+ dispatch(setScreenNameAction({ screenName: screenNames.Statistics }));
+ break;
+ default:
+ dispatch(setScreenNameAction({ screenName: screenNames.Dashboard }));
+ }
+ }
+ }, [window.location.pathname]);
+
+ const handleIconClick = (screenID) => {
+ switch (screenID) {
+ case 1:
+ history.push(screenNames.Dashboard);
+ break;
+ case 2:
+ history.push(screenNames.Profile);
+ break;
+ case 3:
+ history.push(screenNames.Statistics);
+ break;
+ default:
+ history.push(screenNames.Dashboard);
+ }
+ };
+
+ return {
+ screenName,
+ handleIconClick,
+ };
+};
diff --git a/src/reducers/drawerReducer.js b/src/reducers/drawerReducer.js
index 81210ce..c782dd8 100644
--- a/src/reducers/drawerReducer.js
+++ b/src/reducers/drawerReducer.js
@@ -1,12 +1,14 @@
-import { DRAWER_CLOSE, DRAWER_OPEN } from "../constants/drawerConstant";
-import { AUTH } from "../constants/authConstant";
+import { DRAWER_CLOSE, DRAWER_OPEN } from 'constants/drawerConstant';
+import { AUTH } from 'constants/authConstant';
+import { screenNames } from 'custom-hooks/drawerHook';
const initialState = {
isDrawerOpen: false,
+ screenName: screenNames.Dashboard,
};
export const drawerReducer = (state = initialState, action) => {
- const { type } = action;
+ const { type, payload } = action;
switch (type) {
case DRAWER_OPEN:
return {
@@ -18,6 +20,11 @@ export const drawerReducer = (state = initialState, action) => {
...state,
isDrawerOpen: false,
};
+ case 'SET_SCREEN_NAME':
+ return {
+ ...state,
+ screenName: payload.screenName,
+ };
case AUTH.RESET_ALL:
return initialState;
default:
diff --git a/src/views/AnimeWatchlistStats/AnimeWatchlistStatsView.js b/src/views/AnimeWatchlistStats/AnimeWatchlistStatsView.js
index 9a8b0c1..8830554 100644
--- a/src/views/AnimeWatchlistStats/AnimeWatchlistStatsView.js
+++ b/src/views/AnimeWatchlistStats/AnimeWatchlistStatsView.js
@@ -2,6 +2,7 @@ import React from 'react';
import { makeStyles, Grid } from '@material-ui/core/';
import DrawerContainer from 'containers/CustomDrawerContainer/DrawerContainer';
import { useResizeScreen } from 'custom-hooks/useResizeHook';
+import AnimeStatisticsGraphContainer from 'containers/AnimeStatisticsGraph/AnimeStatisticsGraphContainer';
const useStyles = makeStyles((theme) => ({
'@global': {
'*::-webkit-scrollbar': {
@@ -32,7 +33,7 @@ const AnimeWatchlistStatsView = (props) => {
const { isMobile } = useResizeScreen();
return (
<>
-
+
@@ -41,7 +42,7 @@ const AnimeWatchlistStatsView = (props) => {
xs={isMobile ? 12 : 11}
className={isMobile ? classes.noGridStyle : classes.rightGridStyle}
>
- Here are rest
+
>
diff --git a/src/views/Auth/AuthView.js b/src/views/Auth/AuthView.js
index 3236f0d..2fc4277 100644
--- a/src/views/Auth/AuthView.js
+++ b/src/views/Auth/AuthView.js
@@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
import { makeStyles } from '@material-ui/core';
import Logo from '../../components/utilityComponents/Logo';
import AuthContainer from '../../containers/Auth/AuthContainer';
-import LoginImg from '../../assets/test.jpg';
+import LoginImg from '../../assets/login-image.jpg';
const useStyles = makeStyles((theme) => ({
backgroundCover: {
diff --git a/src/views/HomeView/404View.js b/src/views/HomeView/404View.js
new file mode 100644
index 0000000..47b3eab
--- /dev/null
+++ b/src/views/HomeView/404View.js
@@ -0,0 +1,119 @@
+import React from 'react';
+import { useHistory } from 'react-router-dom';
+import { makeStyles, Typography, Button } from '@material-ui/core';
+import Lottie from 'react-lottie';
+import notFound404Animation from 'assets/animation/not-found-404.json';
+import Logo from 'components/utilityComponents/Logo';
+
+const useStyles = makeStyles((theme) => ({
+ errorContainer: {
+ width: '100vw',
+ height: '100vh',
+ background: theme.palette.background.default,
+ overflow: 'auto',
+ },
+ errorContainerInner: {
+ display: 'flex',
+ justifyContent: 'center',
+ alignItems: 'center',
+ },
+ errorTextContainer: {
+ padding: '1rem',
+ },
+ heading: {
+ color: theme.palette.primary.main,
+ fontSize: '6rem',
+ },
+ subHeadingOne: {
+ fontSize: '2rem',
+ color: theme.palette.text.primary,
+ },
+ subHeadingTwo: {
+ fontSize: '1rem',
+ color: theme.palette.text.primary,
+ },
+ homeButton: {
+ padding: '0.4rem 0.8rem',
+ color: '#fff',
+ background: theme.button.background.light,
+ border: 'none',
+ outline: 'none',
+ cursor: 'pointer',
+ borderRadius: '20px',
+ fontSize: '0.7rem',
+ fontWeight: 'bold',
+ marginTop: '1rem',
+ boxShadow: `10px 13px 45px rgba(0, 0, 0, 0.1)`,
+ '&:hover': {
+ opacity: 0.9,
+ },
+ '&:disabled': {
+ background: theme.button.background.light,
+ cursor: 'no-drop',
+ opacity: '0.5',
+ },
+ },
+ '@media screen and (max-width: 600px)': {
+ errorContainer: {
+ padding: '1rem',
+ },
+ errorContainerInner: {
+ flexDirection: 'column',
+ },
+ heading: {
+ fontSize: '3rem',
+ },
+ subHeadingOne: {
+ fontSize: '1.2rem',
+ },
+ subHeadingTwo: {
+ fontSize: '0.8rem',
+ },
+ },
+}));
+
+const NotFound404 = () => {
+ const classes = useStyles();
+ const history = useHistory();
+ const defaultOptions = {
+ loop: true,
+ autoplay: true,
+ animationData: notFound404Animation,
+ rendererSettings: {
+ preserveAspectRatio: 'xMidYMid slice',
+ },
+ };
+
+ const handleHomeClick = () => {
+ history.push('/');
+ };
+
+ return (
+ <>
+
+
+
+
+
+ 404
+
+ UH OH! You are lost.
+
+
+ The page you are looking for is not found. Maybe it has been
+ removed or your in the wrong path.
+
+ handleHomeClick()}
+ >
+ Take me to Home
+
+
+
+
+ >
+ );
+};
+
+export default NotFound404;
diff --git a/src/views/HomeView/HomeView.js b/src/views/HomeView/HomeView.js
index eabba57..8234228 100644
--- a/src/views/HomeView/HomeView.js
+++ b/src/views/HomeView/HomeView.js
@@ -2,6 +2,7 @@ import React from 'react';
import PropTypes from 'prop-types';
import { makeStyles, Typography, Button } from '@material-ui/core';
import { Link } from 'react-router-dom';
+import { useAuthentication } from 'custom-hooks/authHook';
import AwesomeSlider from 'react-awesome-slider';
import withAutoplay from 'react-awesome-slider/dist/autoplay';
import 'react-awesome-slider/dist/styles.css';
@@ -102,6 +103,7 @@ const useStyles = makeStyles((theme) => ({
const SlideContent = (props) => {
const { classes } = props;
+ const { isAuthenticated } = useAuthentication();
return (
@@ -109,18 +111,26 @@ const SlideContent = (props) => {
place to manage all your favourite animes.
-
- Login
-
-
- Sign Up
-
+ {!isAuthenticated ? (
+ <>
+
+ Login
+
+
+ Sign Up
+
+ >
+ ) : (
+
+ Go to Dashboard
+
+ )}
);
diff --git a/src/views/index.js b/src/views/index.js
index 9f32860..2e04e1c 100644
--- a/src/views/index.js
+++ b/src/views/index.js
@@ -4,3 +4,4 @@ export { default as AuthView } from './Auth/AuthView';
export { default as VerifyAccountView } from './Auth/VerifyAccountView';
export { default as Dashboard } from './Dashboard/Dashboard';
export { default as AnimeDetailsView } from './AnimeDetailsView/AnimeDetailsView';
+export { default as PageNotFoundView } from './HomeView/404View';