From 4e39b5bff2348b3ee74b801f51a153384d1ff27c Mon Sep 17 00:00:00 2001 From: Kartik Gupta <84975264+kartik-gupta-ij@users.noreply.github.com> Date: Mon, 7 Oct 2024 00:04:17 +0530 Subject: [PATCH] [WebUI] Homepage to master (#240) --- src/pages/Homepage.jsx | 31 +++++++++++++++++ src/pages/Welcome.jsx | 79 ++++++++++++++++++++++++++++++++++++++++++ src/routes.jsx | 5 ++- 3 files changed, 114 insertions(+), 1 deletion(-) create mode 100644 src/pages/Homepage.jsx create mode 100644 src/pages/Welcome.jsx diff --git a/src/pages/Homepage.jsx b/src/pages/Homepage.jsx new file mode 100644 index 00000000..77704bfb --- /dev/null +++ b/src/pages/Homepage.jsx @@ -0,0 +1,31 @@ +import React, { useState, useEffect } from 'react'; +import { useNavigate } from 'react-router-dom'; +import LinearProgress from '@mui/material/LinearProgress'; +import { useClient } from '../context/client-context'; + +const Homepage = () => { + const { client } = useClient(); + const navigate = useNavigate(); + const [loading, setLoading] = useState(false); + + useEffect(() => { + setLoading(true); + client + .getCollections() + .then((data) => { + setLoading(false); + if (data.collections.length > 0) { + navigate('/collections'); + } else { + navigate('/welcome'); + } + }) + .catch((error) => { + console.error(error); + }); + }, [client]); + + return <>{loading ? : null}; +}; + +export default Homepage; diff --git a/src/pages/Welcome.jsx b/src/pages/Welcome.jsx new file mode 100644 index 00000000..06a4df33 --- /dev/null +++ b/src/pages/Welcome.jsx @@ -0,0 +1,79 @@ +import React from 'react'; +import { Link } from 'react-router-dom'; +import { Box, Button, Typography } from '@mui/material'; +import { styled } from '@mui/material/styles'; + +const ButtonsContainer = styled(Box)` + display: flex; + justify-content: flex-start; + gap: 1rem; + margin: 2rem 0; +`; + +const StyledButton = styled((props) =>