- Implemented Supabase authentication context in `supabase.tsx` for managing user login and logout. - Created a new SVG logo file for branding. - Set up main application entry point in `main.tsx` with router integration. - Added web vitals reporting in `reportWebVitals.ts`. - Generated route tree in `routeTree.gen.ts` for application routing. - Established root route in `__root.tsx` with TanStack Router Devtools integration. - Created authenticated route in `_authenticated.tsx` to protect routes. - Developed planes route under authenticated section in `planes.tsx`. - Implemented login route with form handling in `login.tsx`. - Added index route with welcome message in `index.tsx`. - Included basic styles in `styles.css`. - Configured TypeScript settings in `tsconfig.json`. - Set up Vite configuration with React and TanStack Router plugins in `vite.config.ts`.
61 lines
1.5 KiB
TypeScript
61 lines
1.5 KiB
TypeScript
import { StrictMode } from 'react'
|
|
import ReactDOM from 'react-dom/client'
|
|
import { RouterProvider, createRouter } from '@tanstack/react-router'
|
|
|
|
// Import the generated route tree
|
|
import { routeTree } from './routeTree.gen'
|
|
|
|
import './styles.css'
|
|
import reportWebVitals from './reportWebVitals.ts'
|
|
import { SupabaseAuthProvider, useSupabaseAuth } from './auth/supabase.tsx'
|
|
|
|
const router = createRouter({
|
|
routeTree,
|
|
defaultPreload: 'intent',
|
|
scrollRestoration: true,
|
|
defaultStructuralSharing: true,
|
|
defaultPreloadStaleTime: 0,
|
|
context:{
|
|
auth: undefined!,
|
|
}
|
|
})
|
|
|
|
// Register the router instance for type safety
|
|
declare module '@tanstack/react-router' {
|
|
interface Register {
|
|
router: typeof router
|
|
}
|
|
}
|
|
|
|
function InnerApp() {
|
|
const auth = useSupabaseAuth()
|
|
|
|
if (auth.isLoading) {
|
|
return (
|
|
<div className="flex items-center justify-center min-h-screen">
|
|
Loading...
|
|
</div>
|
|
)
|
|
}
|
|
|
|
return <RouterProvider router={router} context={{ auth }} />
|
|
}
|
|
|
|
// Render the app
|
|
const rootElement = document.getElementById('app')
|
|
if (rootElement && !rootElement.innerHTML) {
|
|
const root = ReactDOM.createRoot(rootElement)
|
|
root.render(
|
|
<StrictMode>
|
|
<SupabaseAuthProvider>
|
|
<InnerApp />
|
|
</SupabaseAuthProvider>
|
|
</StrictMode>,
|
|
)
|
|
}
|
|
|
|
// If you want to start measuring performance in your app, pass a function
|
|
// to log results (for example: reportWebVitals(console.log))
|
|
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
|
|
reportWebVitals()
|