mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-07 04:20:12 +02:00
Fix names
This commit is contained in:
@@ -5,13 +5,15 @@ interface PrivateOutletProps {
|
||||
redirectTo: string;
|
||||
}
|
||||
|
||||
export const PrivateOutlet = ({ redirectTo }: PrivateOutletProps) => {
|
||||
export const AppOutlet = ({ redirectTo }: PrivateOutletProps) => {
|
||||
const location = useLocation();
|
||||
const isAuthenticated = useAuthStore((state) => !!state.accessToken);
|
||||
const logout = useAuthStore((state) => state.logout);
|
||||
|
||||
if (isAuthenticated) {
|
||||
return <Outlet />;
|
||||
}
|
||||
|
||||
logout();
|
||||
return <Navigate replace state={{ from: location }} to={redirectTo} />;
|
||||
};
|
||||
@@ -1,12 +1,12 @@
|
||||
/* eslint-disable sort-keys-fix/sort-keys-fix */
|
||||
import { Routes, Route } from 'react-router-dom';
|
||||
import { Routes, Route, Link } from 'react-router-dom';
|
||||
import { AlbumListRoute } from '@/renderer/features/albums';
|
||||
import { LoginRoute } from '@/renderer/features/auth';
|
||||
import { DashboardRoute } from '@/renderer/features/dashboard';
|
||||
import { NowPlayingRoute } from '@/renderer/features/now-playing';
|
||||
import { AuthLayout, DefaultLayout } from '@/renderer/layouts';
|
||||
import { AppOutlet } from '@/renderer/router/app-outlet';
|
||||
import { AuthOutlet } from '@/renderer/router/auth-outlet';
|
||||
import { PrivateOutlet } from '@/renderer/router/private-outlet';
|
||||
import { AppRoute } from './routes';
|
||||
|
||||
export const AppRouter = () => {
|
||||
@@ -17,15 +17,14 @@ export const AppRouter = () => {
|
||||
<Route element={<LoginRoute />} path={AppRoute.LOGIN} />
|
||||
</Route>
|
||||
</Route>
|
||||
<Route
|
||||
element={<PrivateOutlet redirectTo={AppRoute.LOGIN} />}
|
||||
path={AppRoute.HOME}
|
||||
>
|
||||
<Route element={<AppOutlet redirectTo={AppRoute.LOGIN} />}>
|
||||
<Route element={<DefaultLayout />}>
|
||||
<Route index element={<DashboardRoute />} />
|
||||
<Route element={<DashboardRoute />} path={AppRoute.HOME} />
|
||||
<Route element={<NowPlayingRoute />} path={AppRoute.NOW_PLAYING} />
|
||||
<Route element={<AlbumListRoute />} path={AppRoute.LIBRARY_ALBUMS} />
|
||||
<Route element={<></>} path={AppRoute.LIBRARY_ARTISTS} />
|
||||
<Route element={<Link to={AppRoute.HOME}>Go home</Link>} path="*" />
|
||||
</Route>
|
||||
<Route element={<></>} path={AppRoute.PLAYING} />
|
||||
</Route>
|
||||
|
||||
Reference in New Issue
Block a user