mirror of
https://github.com/spacedriveapp/spacedrive
synced 2024-07-08 08:22:53 +00:00
* beginnings of app directory * settings mostly good * colocate way more components * flatten components folder * reexport QueryClientProvider from client * move CodeBlock back to interface * colocate Explorer, KeyManager + more * goddamn captialisation * get toasts out of components * please eslint * no more src directory * $ instead of : * added back RowHeader component * fix settings modal padding * more spacing, less margin * fix sidebar locations button * fix tags sidebar link * clean up back button * added margin to explorer context menu to prevent contact with edge of viewport * don't export QueryClientProvider from @sd/client * basic guidelines * import interface correctly * remove old demo data * fix onboarding layout * fix onboarding navigation * fix key manager settings button --------- Co-authored-by: Jamie Pine <ijamespine@me.com>
46 lines
1.2 KiB
TypeScript
46 lines
1.2 KiB
TypeScript
import { Navigate, RouteObject, useRoutes } from 'react-router-dom';
|
|
import { currentLibraryCache, useCachedLibraries, useInvalidateQuery } from '@sd/client';
|
|
import { useKeybindHandler } from '~/hooks/useKeyboardHandler';
|
|
import { lazyEl } from '~/util';
|
|
import libraryRoutes from './$libraryId';
|
|
import onboardingRoutes from './onboarding';
|
|
import './style.scss';
|
|
|
|
const Index = () => {
|
|
const libraries = useCachedLibraries();
|
|
|
|
if (libraries.status !== 'success') return null;
|
|
|
|
if (libraries.data.length === 0) return <Navigate to="onboarding" />;
|
|
|
|
const currentLibrary = libraries.data.find((l) => l.uuid === currentLibraryCache.id);
|
|
|
|
const libraryId = currentLibrary ? currentLibrary.uuid : libraries.data[0]?.uuid;
|
|
|
|
return <Navigate to={`${libraryId}/overview`} />;
|
|
};
|
|
|
|
const routes = [
|
|
{
|
|
index: true,
|
|
element: <Index />
|
|
},
|
|
{
|
|
path: 'onboarding',
|
|
element: lazyEl(() => import('./onboarding/Layout')),
|
|
children: onboardingRoutes
|
|
},
|
|
{
|
|
path: ':libraryId',
|
|
element: lazyEl(() => import('./$libraryId/Layout')),
|
|
children: libraryRoutes
|
|
}
|
|
] satisfies RouteObject[];
|
|
|
|
export default () => {
|
|
useKeybindHandler();
|
|
useInvalidateQuery();
|
|
|
|
return useRoutes(routes);
|
|
};
|