Add VITE_IS_LANDING_DEFAULT flag for conditional rendering of landing page
This commit is contained in:
parent
8da220e990
commit
e25a6d3be9
5 changed files with 39 additions and 9 deletions
1
.env
1
.env
|
@ -1 +1,2 @@
|
|||
VITE_APP_API_URL=http://localhost:2021
|
||||
VITE_IS_LANDING_DEFAULT=false
|
|
@ -20,6 +20,12 @@ import TermsView from '../views/Terms/TermsView'
|
|||
import TestView from '../views/TestView/Test'
|
||||
import ThingsHistory from '../views/Things/ThingsHistory'
|
||||
import ThingsView from '../views/Things/ThingsView'
|
||||
const getMainRoute = () => {
|
||||
if (import.meta.env.VITE_IS_LANDING_DEFAULT === 'true') {
|
||||
return <Landing />
|
||||
}
|
||||
return <MyChores />
|
||||
}
|
||||
const Router = createBrowserRouter([
|
||||
{
|
||||
path: '/',
|
||||
|
@ -28,7 +34,7 @@ const Router = createBrowserRouter([
|
|||
children: [
|
||||
{
|
||||
path: '/',
|
||||
element: <Landing />,
|
||||
element: getMainRoute(),
|
||||
},
|
||||
{
|
||||
path: '/settings',
|
||||
|
|
|
@ -61,6 +61,17 @@ const HomeHero = () => {
|
|||
>
|
||||
tick
|
||||
</span>
|
||||
<span
|
||||
style={{
|
||||
fontSize: 20,
|
||||
fontWeight: 700,
|
||||
position: 'relative',
|
||||
top: 12,
|
||||
right: 45,
|
||||
}}
|
||||
>
|
||||
Beta
|
||||
</span>
|
||||
</Typography>
|
||||
</Box>
|
||||
)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { Container, Grid } from '@mui/joy'
|
||||
import AOS from 'aos'
|
||||
import 'aos/dist/aos.css'
|
||||
import { useEffect, useState } from 'react'
|
||||
import { useEffect } from 'react'
|
||||
import { useNavigate } from 'react-router-dom'
|
||||
import DemoAssignee from './DemoAssignee'
|
||||
import DemoHistory from './DemoHistory'
|
||||
|
@ -11,11 +11,6 @@ import FeaturesSection from './FeaturesSection'
|
|||
import HomeHero from './HomeHero'
|
||||
const Landing = () => {
|
||||
const Navigate = useNavigate()
|
||||
const getCurrentUser = () => {
|
||||
return JSON.parse(localStorage.getItem('user'))
|
||||
}
|
||||
const [currentUser, setCurrentUser] = useState(getCurrentUser())
|
||||
|
||||
useEffect(() => {
|
||||
AOS.init({
|
||||
once: false, // whether animation should happen only once - while scrolling down
|
||||
|
|
|
@ -71,12 +71,18 @@ const NavBar = () => {
|
|||
const location = useLocation()
|
||||
// if url has /landing then remove the navbar:
|
||||
if (
|
||||
['/', '/signup', '/login', '/landing', '/forgot-password'].includes(
|
||||
['/signup', '/login', '/landing', '/forgot-password'].includes(
|
||||
location.pathname,
|
||||
)
|
||||
) {
|
||||
return null
|
||||
}
|
||||
if (
|
||||
location.pathname === '/' &&
|
||||
import.meta.env.VITE_IS_LANDING_DEFAULT === 'true'
|
||||
) {
|
||||
return null
|
||||
}
|
||||
|
||||
return (
|
||||
<nav className='flex gap-2 p-3'>
|
||||
|
@ -102,6 +108,17 @@ const NavBar = () => {
|
|||
tick✓
|
||||
</span>
|
||||
</Typography>
|
||||
<span
|
||||
style={{
|
||||
fontSize: 12,
|
||||
fontWeight: 700,
|
||||
position: 'relative',
|
||||
top: 12,
|
||||
right: 45,
|
||||
}}
|
||||
>
|
||||
Beta
|
||||
</span>
|
||||
</Box>
|
||||
<Drawer
|
||||
open={drawerOpen}
|
||||
|
|
Loading…
Add table
Reference in a new issue