aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Mo Tarbin <mhed.t91@gmail.com>2024-07-09 21:21:00 -0400
committerLibravatar Mo Tarbin <mhed.t91@gmail.com>2024-07-09 21:21:00 -0400
commite25a6d3be9b9ae443dd3e1cd57a8c5912cc088b2 (patch)
tree8900f75514f0b2b3b9a1b44d28f436ec10cf8393
parent8da220e990b5ab15509848d4d7a57298eb6e808e (diff)
downloaddonetick-frontend-e25a6d3be9b9ae443dd3e1cd57a8c5912cc088b2.tar.gz
donetick-frontend-e25a6d3be9b9ae443dd3e1cd57a8c5912cc088b2.tar.bz2
donetick-frontend-e25a6d3be9b9ae443dd3e1cd57a8c5912cc088b2.zip
Add VITE_IS_LANDING_DEFAULT flag for conditional rendering of landing page
-rw-r--r--.env3
-rw-r--r--src/contexts/RouterContext.jsx8
-rw-r--r--src/views/Landing/HomeHero.jsx11
-rw-r--r--src/views/Landing/Landing.jsx7
-rw-r--r--src/views/components/NavBar.jsx19
5 files changed, 39 insertions, 9 deletions
diff --git a/.env b/.env
index 633f2c7..b7e8b90 100644
--- a/.env
+++ b/.env
@@ -1 +1,2 @@
-VITE_APP_API_URL=http://localhost:2021 \ No newline at end of file
+VITE_APP_API_URL=http://localhost:2021
+VITE_IS_LANDING_DEFAULT=false \ No newline at end of file
diff --git a/src/contexts/RouterContext.jsx b/src/contexts/RouterContext.jsx
index 02df35f..4fea83d 100644
--- a/src/contexts/RouterContext.jsx
+++ b/src/contexts/RouterContext.jsx
@@ -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',
diff --git a/src/views/Landing/HomeHero.jsx b/src/views/Landing/HomeHero.jsx
index f01d335..644c9cc 100644
--- a/src/views/Landing/HomeHero.jsx
+++ b/src/views/Landing/HomeHero.jsx
@@ -61,6 +61,17 @@ const HomeHero = () => {
>
tick
</span>
+ <span
+ style={{
+ fontSize: 20,
+ fontWeight: 700,
+ position: 'relative',
+ top: 12,
+ right: 45,
+ }}
+ >
+ Beta
+ </span>
</Typography>
</Box>
)
diff --git a/src/views/Landing/Landing.jsx b/src/views/Landing/Landing.jsx
index fbdefed..a8b650d 100644
--- a/src/views/Landing/Landing.jsx
+++ b/src/views/Landing/Landing.jsx
@@ -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
diff --git a/src/views/components/NavBar.jsx b/src/views/components/NavBar.jsx
index 939c9fd..2da09f5 100644
--- a/src/views/components/NavBar.jsx
+++ b/src/views/components/NavBar.jsx
@@ -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}