diff --git a/src/components/App/index.tsx b/src/components/App/index.tsx
index 7860ad1..f61ab82 100644
--- a/src/components/App/index.tsx
+++ b/src/components/App/index.tsx
@@ -1,9 +1,11 @@
import { useState } from 'react'
-import { Routes, Route, Navigate, Outlet, useLocation } from 'react-router-dom'
+import {
+ Routes, Route, Navigate, Outlet, useLocation
+} from 'react-router-dom'
import { useAuth } from '../../auth'
import { useSelector } from 'react-redux'
import { selectors } from '../../store'
-import routes, { hasNavigation } from '../../routes'
+import routes, { hasNavigation, getRouteBy } from '../../routes'
import BirthdayPage from '../BirthdayPage'
import BirthtimePage from '../BirthtimePage'
import CreateProfilePage from '../CreateProfilePage'
@@ -31,7 +33,7 @@ function App(): JSX.Element {
}>
} />
} />
- } />
+ } />
} />
@@ -65,13 +67,12 @@ function SkipStep(): JSX.Element {
function MainPage(): JSX.Element {
const status = useSelector(selectors.selectStatus)
- const pageMapper = {
- 'lead': routes.client.birthday(),
- 'registred': routes.client.subscription(),
- 'subscribed': routes.client.wallpaper(),
- 'unsubscribed': routes.client.subscription(),
- }
- return
+ return
+}
+
+function ProtectWallpaperPage(): JSX.Element {
+ const status = useSelector(selectors.selectStatus)
+ return status === 'subscribed' ? :
}
export default App
diff --git a/src/routes.ts b/src/routes.ts
index fb70e6b..4f46ea5 100644
--- a/src/routes.ts
+++ b/src/routes.ts
@@ -1,3 +1,5 @@
+import type { UserStatus } from "./types"
+
const host = ''
const apiHost = 'https://aura.wit.life'
const prefix = 'api/v1'
@@ -45,4 +47,18 @@ export const withNavigationRoutes = [routes.client.wallpaper()]
export const hasNavigation = (path: string) => withNavigationRoutes.includes(path)
export const hasNoNavigation = (path: string) => !hasNavigation(path)
+export const getRouteBy = (status: UserStatus): string => {
+ switch (status) {
+ case 'lead':
+ return routes.client.birthday()
+ case 'registred':
+ case 'unsubscribed':
+ return routes.client.subscription()
+ case 'subscribed':
+ return routes.client.wallpaper()
+ default:
+ throw new Error(`Unknown user status, received status is "${status}"`)
+ }
+}
+
export default routes
diff --git a/src/store/status.ts b/src/store/status.ts
index 42d9805..5af1e12 100644
--- a/src/store/status.ts
+++ b/src/store/status.ts
@@ -1,7 +1,6 @@
import { createSlice, createSelector } from '@reduxjs/toolkit'
import type { PayloadAction } from '@reduxjs/toolkit'
-
-type UserStatus = 'lead' | 'registred' | 'subscribed' | 'unsubscribed'
+import type { UserStatus } from '../types'
const initialState = 'lead' as UserStatus
diff --git a/src/types.ts b/src/types.ts
index 646334a..ff3ceb6 100644
--- a/src/types.ts
+++ b/src/types.ts
@@ -23,3 +23,4 @@ export interface SignupForm {
}
export type AppConfig = typeof config
+export type UserStatus = 'lead' | 'registred' | 'subscribed' | 'unsubscribed'