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