Skip to content

Commit

Permalink
chore: remove extra logic in routes
Browse files Browse the repository at this point in the history
  • Loading branch information
devceline committed Feb 29, 2024
1 parent 7504239 commit bf20fb7
Showing 1 changed file with 1 addition and 22 deletions.
23 changes: 1 addition & 22 deletions src/routes.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
/* eslint-disable no-nested-ternary */
import { useContext } from 'react'

import { Navigate, Route, Routes } from 'react-router-dom'

import App from '@/App'
Expand All @@ -11,21 +9,11 @@ import AppearanceSettings from '@/components/settings/AppearanceSettings'
import NotificationsSettings from '@/components/settings/NotificationsSettings'
import SettingsLayout from '@/components/settings/SettingsLayout'
import SupportSettings from '@/components/settings/SupportSettings'
import W3iContext from '@/contexts/W3iContext/context'
import Login from '@/pages/Login'
import ScanQrCode from '@/pages/ScanQrCode'
import WidgetConnect from '@/pages/widget/Connect'
import WidgetSubscribe from '@/pages/widget/Subscribe'

const ConfiguredRoutes: React.FC = () => {
const { uiEnabled } = useContext(W3iContext)

const defaultPage =
Object.entries({
'/messages': uiEnabled.chat,
'/notifications': uiEnabled.notify,
'/settings': uiEnabled.settings
}).find(([_, enabled]) => enabled)?.[0] ?? '/login'
const defaultPage = '/notifications'

return (
<Routes>
Expand All @@ -34,28 +22,19 @@ const ConfiguredRoutes: React.FC = () => {
<Route path="/qrcode-scan" element={<ScanQrCode />} />

<Route path="/" element={<App />}>
{uiEnabled.notify ? (
<Route path="/notifications" element={<NotificationsLayout />}>
<Route path="/notifications/new-app" element={<AppExplorer />} />
<Route path="/notifications/:topic" element={<AppNotifications />} />
</Route>
) : null}
{uiEnabled.settings ? (
<Route path="settings" element={<SettingsLayout />}>
<Route path="/settings/appearance" element={<AppearanceSettings />} />
<Route path="/settings/notification" element={<NotificationsSettings />} />
<Route path="/settings/support" element={<SupportSettings />} />
</Route>
) : null}
</Route>

<Route index element={<Navigate to={defaultPage} />} />

<Route path="widget">
<Route path="/widget/subscribe" element={<WidgetSubscribe />} />
<Route path="/widget/connect" element={<WidgetConnect />} />
</Route>

<Route path="*" element={<Navigate to="/" />} />
</Routes>
)
Expand Down

0 comments on commit bf20fb7

Please sign in to comment.