[rewrite] Added first steps for authentication
This commit is contained in:
parent
073f01d070
commit
a9c85cefe1
100
frontend/src/pages/home/index.tsx
Normal file
100
frontend/src/pages/home/index.tsx
Normal file
@ -0,0 +1,100 @@
|
||||
import { useState } from "react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
||||
import { Label } from "@/components/ui/label";
|
||||
|
||||
export default function MainPage() {
|
||||
const [email, setEmail] = useState("");
|
||||
const [password, setPassword] = useState("");
|
||||
const [username, setUsername] = useState("");
|
||||
|
||||
return (
|
||||
<div className="flex min-h-screen flex-col items-center justify-center bg-gray-100 p-6">
|
||||
{/* Showcase Section */}
|
||||
<section className="mb-8 w-full max-w-4xl text-center">
|
||||
<h1 className="mb-4 text-4xl font-bold">Welcome to Our Platform</h1>
|
||||
<p className="mb-6 text-gray-600">
|
||||
A place where you can explore, connect, and engage. Sign up or log in
|
||||
to get started.
|
||||
</p>
|
||||
<Button className="px-6 py-2">Learn More</Button>
|
||||
</section>
|
||||
|
||||
{/* Authentication Section */}
|
||||
<Card className="w-full max-w-md">
|
||||
<CardHeader>
|
||||
<CardTitle>Join Us</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<Tabs defaultValue="login" className="w-full">
|
||||
<TabsList className="grid w-full grid-cols-2">
|
||||
<TabsTrigger value="login">Login</TabsTrigger>
|
||||
<TabsTrigger value="register">Register</TabsTrigger>
|
||||
</TabsList>
|
||||
|
||||
{/* Login Tab */}
|
||||
<TabsContent value="login">
|
||||
<form className="space-y-4">
|
||||
<div>
|
||||
<Label>Email</Label>
|
||||
<Input
|
||||
type="email"
|
||||
value={email}
|
||||
onChange={(e) => setEmail(e.target.value)}
|
||||
placeholder="Enter your email"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<Label>Password</Label>
|
||||
<Input
|
||||
type="password"
|
||||
value={password}
|
||||
onChange={(e) => setPassword(e.target.value)}
|
||||
placeholder="Enter your password"
|
||||
/>
|
||||
</div>
|
||||
<Button className="w-full">Login</Button>
|
||||
</form>
|
||||
</TabsContent>
|
||||
|
||||
{/* Register Tab */}
|
||||
<TabsContent value="register">
|
||||
<form className="space-y-4">
|
||||
<div>
|
||||
<Label>Username</Label>
|
||||
<Input
|
||||
type="text"
|
||||
value={username}
|
||||
onChange={(e) => setUsername(e.target.value)}
|
||||
placeholder="Choose a username"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<Label>Email</Label>
|
||||
<Input
|
||||
type="email"
|
||||
value={email}
|
||||
onChange={(e) => setEmail(e.target.value)}
|
||||
placeholder="Enter your email"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<Label>Password</Label>
|
||||
<Input
|
||||
type="password"
|
||||
value={password}
|
||||
onChange={(e) => setPassword(e.target.value)}
|
||||
placeholder="Create a password"
|
||||
/>
|
||||
</div>
|
||||
<Button className="w-full">Register</Button>
|
||||
</form>
|
||||
</TabsContent>
|
||||
</Tabs>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
);
|
||||
}
|
@ -14,10 +14,11 @@ import { createFileRoute } from '@tanstack/react-router'
|
||||
|
||||
import { Route as rootRoute } from './routes/__root'
|
||||
import { Route as AuthenticatedRouteImport } from './routes/_authenticated/route'
|
||||
import { Route as AuthenticatedIndexImport } from './routes/_authenticated/index'
|
||||
import { Route as IndexImport } from './routes/index'
|
||||
import { Route as authSignInImport } from './routes/(auth)/sign-in'
|
||||
import { Route as authOtpImport } from './routes/(auth)/otp'
|
||||
import { Route as auth500Import } from './routes/(auth)/500'
|
||||
import { Route as AuthenticatedDashboardIndexImport } from './routes/_authenticated/dashboard/index'
|
||||
|
||||
// Create Virtual Routes
|
||||
|
||||
@ -75,10 +76,10 @@ const AuthenticatedRouteRoute = AuthenticatedRouteImport.update({
|
||||
getParentRoute: () => rootRoute,
|
||||
} as any)
|
||||
|
||||
const AuthenticatedIndexRoute = AuthenticatedIndexImport.update({
|
||||
const IndexRoute = IndexImport.update({
|
||||
id: '/',
|
||||
path: '/',
|
||||
getParentRoute: () => AuthenticatedRouteRoute,
|
||||
getParentRoute: () => rootRoute,
|
||||
} as any)
|
||||
|
||||
const errors503LazyRoute = errors503LazyImport
|
||||
@ -239,6 +240,13 @@ const AuthenticatedAppsIndexLazyRoute = AuthenticatedAppsIndexLazyImport.update(
|
||||
import('./routes/_authenticated/apps/index.lazy').then((d) => d.Route),
|
||||
)
|
||||
|
||||
const AuthenticatedDashboardIndexRoute =
|
||||
AuthenticatedDashboardIndexImport.update({
|
||||
id: '/dashboard/',
|
||||
path: '/dashboard/',
|
||||
getParentRoute: () => AuthenticatedRouteRoute,
|
||||
} as any)
|
||||
|
||||
const AuthenticatedSettingsNotificationsLazyRoute =
|
||||
AuthenticatedSettingsNotificationsLazyImport.update({
|
||||
id: '/notifications',
|
||||
@ -287,6 +295,13 @@ const AuthenticatedSettingsAccountLazyRoute =
|
||||
|
||||
declare module '@tanstack/react-router' {
|
||||
interface FileRoutesByPath {
|
||||
'/': {
|
||||
id: '/'
|
||||
path: '/'
|
||||
fullPath: '/'
|
||||
preLoaderRoute: typeof IndexImport
|
||||
parentRoute: typeof rootRoute
|
||||
}
|
||||
'/_authenticated': {
|
||||
id: '/_authenticated'
|
||||
path: ''
|
||||
@ -378,13 +393,6 @@ declare module '@tanstack/react-router' {
|
||||
preLoaderRoute: typeof errors503LazyImport
|
||||
parentRoute: typeof rootRoute
|
||||
}
|
||||
'/_authenticated/': {
|
||||
id: '/_authenticated/'
|
||||
path: '/'
|
||||
fullPath: '/'
|
||||
preLoaderRoute: typeof AuthenticatedIndexImport
|
||||
parentRoute: typeof AuthenticatedRouteImport
|
||||
}
|
||||
'/_authenticated/settings/account': {
|
||||
id: '/_authenticated/settings/account'
|
||||
path: '/account'
|
||||
@ -413,6 +421,13 @@ declare module '@tanstack/react-router' {
|
||||
preLoaderRoute: typeof AuthenticatedSettingsNotificationsLazyImport
|
||||
parentRoute: typeof AuthenticatedSettingsRouteLazyImport
|
||||
}
|
||||
'/_authenticated/dashboard/': {
|
||||
id: '/_authenticated/dashboard/'
|
||||
path: '/dashboard'
|
||||
fullPath: '/dashboard'
|
||||
preLoaderRoute: typeof AuthenticatedDashboardIndexImport
|
||||
parentRoute: typeof AuthenticatedRouteImport
|
||||
}
|
||||
'/_authenticated/apps/': {
|
||||
id: '/_authenticated/apps/'
|
||||
path: '/apps'
|
||||
@ -495,7 +510,7 @@ const AuthenticatedSettingsRouteLazyRouteWithChildren =
|
||||
|
||||
interface AuthenticatedRouteRouteChildren {
|
||||
AuthenticatedSettingsRouteLazyRoute: typeof AuthenticatedSettingsRouteLazyRouteWithChildren
|
||||
AuthenticatedIndexRoute: typeof AuthenticatedIndexRoute
|
||||
AuthenticatedDashboardIndexRoute: typeof AuthenticatedDashboardIndexRoute
|
||||
AuthenticatedAppsIndexLazyRoute: typeof AuthenticatedAppsIndexLazyRoute
|
||||
AuthenticatedChatsIndexLazyRoute: typeof AuthenticatedChatsIndexLazyRoute
|
||||
AuthenticatedHelpCenterIndexLazyRoute: typeof AuthenticatedHelpCenterIndexLazyRoute
|
||||
@ -507,7 +522,7 @@ interface AuthenticatedRouteRouteChildren {
|
||||
const AuthenticatedRouteRouteChildren: AuthenticatedRouteRouteChildren = {
|
||||
AuthenticatedSettingsRouteLazyRoute:
|
||||
AuthenticatedSettingsRouteLazyRouteWithChildren,
|
||||
AuthenticatedIndexRoute: AuthenticatedIndexRoute,
|
||||
AuthenticatedDashboardIndexRoute: AuthenticatedDashboardIndexRoute,
|
||||
AuthenticatedAppsIndexLazyRoute: AuthenticatedAppsIndexLazyRoute,
|
||||
AuthenticatedChatsIndexLazyRoute: AuthenticatedChatsIndexLazyRoute,
|
||||
AuthenticatedHelpCenterIndexLazyRoute: AuthenticatedHelpCenterIndexLazyRoute,
|
||||
@ -520,6 +535,7 @@ const AuthenticatedRouteRouteWithChildren =
|
||||
AuthenticatedRouteRoute._addFileChildren(AuthenticatedRouteRouteChildren)
|
||||
|
||||
export interface FileRoutesByFullPath {
|
||||
'/': typeof IndexRoute
|
||||
'': typeof AuthenticatedRouteRouteWithChildren
|
||||
'/500': typeof errors500LazyRoute
|
||||
'/otp': typeof authOtpRoute
|
||||
@ -532,11 +548,11 @@ export interface FileRoutesByFullPath {
|
||||
'/403': typeof errors403LazyRoute
|
||||
'/404': typeof errors404LazyRoute
|
||||
'/503': typeof errors503LazyRoute
|
||||
'/': typeof AuthenticatedIndexRoute
|
||||
'/settings/account': typeof AuthenticatedSettingsAccountLazyRoute
|
||||
'/settings/appearance': typeof AuthenticatedSettingsAppearanceLazyRoute
|
||||
'/settings/display': typeof AuthenticatedSettingsDisplayLazyRoute
|
||||
'/settings/notifications': typeof AuthenticatedSettingsNotificationsLazyRoute
|
||||
'/dashboard': typeof AuthenticatedDashboardIndexRoute
|
||||
'/apps': typeof AuthenticatedAppsIndexLazyRoute
|
||||
'/chats': typeof AuthenticatedChatsIndexLazyRoute
|
||||
'/help-center': typeof AuthenticatedHelpCenterIndexLazyRoute
|
||||
@ -547,6 +563,8 @@ export interface FileRoutesByFullPath {
|
||||
}
|
||||
|
||||
export interface FileRoutesByTo {
|
||||
'/': typeof IndexRoute
|
||||
'': typeof AuthenticatedRouteRouteWithChildren
|
||||
'/500': typeof errors500LazyRoute
|
||||
'/otp': typeof authOtpRoute
|
||||
'/sign-in': typeof authSignInRoute
|
||||
@ -557,11 +575,11 @@ export interface FileRoutesByTo {
|
||||
'/403': typeof errors403LazyRoute
|
||||
'/404': typeof errors404LazyRoute
|
||||
'/503': typeof errors503LazyRoute
|
||||
'/': typeof AuthenticatedIndexRoute
|
||||
'/settings/account': typeof AuthenticatedSettingsAccountLazyRoute
|
||||
'/settings/appearance': typeof AuthenticatedSettingsAppearanceLazyRoute
|
||||
'/settings/display': typeof AuthenticatedSettingsDisplayLazyRoute
|
||||
'/settings/notifications': typeof AuthenticatedSettingsNotificationsLazyRoute
|
||||
'/dashboard': typeof AuthenticatedDashboardIndexRoute
|
||||
'/apps': typeof AuthenticatedAppsIndexLazyRoute
|
||||
'/chats': typeof AuthenticatedChatsIndexLazyRoute
|
||||
'/help-center': typeof AuthenticatedHelpCenterIndexLazyRoute
|
||||
@ -573,6 +591,7 @@ export interface FileRoutesByTo {
|
||||
|
||||
export interface FileRoutesById {
|
||||
__root__: typeof rootRoute
|
||||
'/': typeof IndexRoute
|
||||
'/_authenticated': typeof AuthenticatedRouteRouteWithChildren
|
||||
'/(auth)/500': typeof auth500Route
|
||||
'/(auth)/otp': typeof authOtpRoute
|
||||
@ -586,11 +605,11 @@ export interface FileRoutesById {
|
||||
'/(errors)/404': typeof errors404LazyRoute
|
||||
'/(errors)/500': typeof errors500LazyRoute
|
||||
'/(errors)/503': typeof errors503LazyRoute
|
||||
'/_authenticated/': typeof AuthenticatedIndexRoute
|
||||
'/_authenticated/settings/account': typeof AuthenticatedSettingsAccountLazyRoute
|
||||
'/_authenticated/settings/appearance': typeof AuthenticatedSettingsAppearanceLazyRoute
|
||||
'/_authenticated/settings/display': typeof AuthenticatedSettingsDisplayLazyRoute
|
||||
'/_authenticated/settings/notifications': typeof AuthenticatedSettingsNotificationsLazyRoute
|
||||
'/_authenticated/dashboard/': typeof AuthenticatedDashboardIndexRoute
|
||||
'/_authenticated/apps/': typeof AuthenticatedAppsIndexLazyRoute
|
||||
'/_authenticated/chats/': typeof AuthenticatedChatsIndexLazyRoute
|
||||
'/_authenticated/help-center/': typeof AuthenticatedHelpCenterIndexLazyRoute
|
||||
@ -603,6 +622,7 @@ export interface FileRoutesById {
|
||||
export interface FileRouteTypes {
|
||||
fileRoutesByFullPath: FileRoutesByFullPath
|
||||
fullPaths:
|
||||
| '/'
|
||||
| ''
|
||||
| '/500'
|
||||
| '/otp'
|
||||
@ -615,11 +635,11 @@ export interface FileRouteTypes {
|
||||
| '/403'
|
||||
| '/404'
|
||||
| '/503'
|
||||
| '/'
|
||||
| '/settings/account'
|
||||
| '/settings/appearance'
|
||||
| '/settings/display'
|
||||
| '/settings/notifications'
|
||||
| '/dashboard'
|
||||
| '/apps'
|
||||
| '/chats'
|
||||
| '/help-center'
|
||||
@ -629,6 +649,8 @@ export interface FileRouteTypes {
|
||||
| '/users'
|
||||
fileRoutesByTo: FileRoutesByTo
|
||||
to:
|
||||
| '/'
|
||||
| ''
|
||||
| '/500'
|
||||
| '/otp'
|
||||
| '/sign-in'
|
||||
@ -639,11 +661,11 @@ export interface FileRouteTypes {
|
||||
| '/403'
|
||||
| '/404'
|
||||
| '/503'
|
||||
| '/'
|
||||
| '/settings/account'
|
||||
| '/settings/appearance'
|
||||
| '/settings/display'
|
||||
| '/settings/notifications'
|
||||
| '/dashboard'
|
||||
| '/apps'
|
||||
| '/chats'
|
||||
| '/help-center'
|
||||
@ -653,6 +675,7 @@ export interface FileRouteTypes {
|
||||
| '/users'
|
||||
id:
|
||||
| '__root__'
|
||||
| '/'
|
||||
| '/_authenticated'
|
||||
| '/(auth)/500'
|
||||
| '/(auth)/otp'
|
||||
@ -666,11 +689,11 @@ export interface FileRouteTypes {
|
||||
| '/(errors)/404'
|
||||
| '/(errors)/500'
|
||||
| '/(errors)/503'
|
||||
| '/_authenticated/'
|
||||
| '/_authenticated/settings/account'
|
||||
| '/_authenticated/settings/appearance'
|
||||
| '/_authenticated/settings/display'
|
||||
| '/_authenticated/settings/notifications'
|
||||
| '/_authenticated/dashboard/'
|
||||
| '/_authenticated/apps/'
|
||||
| '/_authenticated/chats/'
|
||||
| '/_authenticated/help-center/'
|
||||
@ -682,6 +705,7 @@ export interface FileRouteTypes {
|
||||
}
|
||||
|
||||
export interface RootRouteChildren {
|
||||
IndexRoute: typeof IndexRoute
|
||||
AuthenticatedRouteRoute: typeof AuthenticatedRouteRouteWithChildren
|
||||
auth500Route: typeof auth500Route
|
||||
authOtpRoute: typeof authOtpRoute
|
||||
@ -697,6 +721,7 @@ export interface RootRouteChildren {
|
||||
}
|
||||
|
||||
const rootRouteChildren: RootRouteChildren = {
|
||||
IndexRoute: IndexRoute,
|
||||
AuthenticatedRouteRoute: AuthenticatedRouteRouteWithChildren,
|
||||
auth500Route: auth500Route,
|
||||
authOtpRoute: authOtpRoute,
|
||||
@ -721,6 +746,7 @@ export const routeTree = rootRoute
|
||||
"__root__": {
|
||||
"filePath": "__root.tsx",
|
||||
"children": [
|
||||
"/",
|
||||
"/_authenticated",
|
||||
"/(auth)/500",
|
||||
"/(auth)/otp",
|
||||
@ -735,11 +761,14 @@ export const routeTree = rootRoute
|
||||
"/(errors)/503"
|
||||
]
|
||||
},
|
||||
"/": {
|
||||
"filePath": "index.tsx"
|
||||
},
|
||||
"/_authenticated": {
|
||||
"filePath": "_authenticated/route.tsx",
|
||||
"children": [
|
||||
"/_authenticated/settings",
|
||||
"/_authenticated/",
|
||||
"/_authenticated/dashboard/",
|
||||
"/_authenticated/apps/",
|
||||
"/_authenticated/chats/",
|
||||
"/_authenticated/help-center/",
|
||||
@ -792,10 +821,6 @@ export const routeTree = rootRoute
|
||||
"/(errors)/503": {
|
||||
"filePath": "(errors)/503.lazy.tsx"
|
||||
},
|
||||
"/_authenticated/": {
|
||||
"filePath": "_authenticated/index.tsx",
|
||||
"parent": "/_authenticated"
|
||||
},
|
||||
"/_authenticated/settings/account": {
|
||||
"filePath": "_authenticated/settings/account.lazy.tsx",
|
||||
"parent": "/_authenticated/settings"
|
||||
@ -812,6 +837,10 @@ export const routeTree = rootRoute
|
||||
"filePath": "_authenticated/settings/notifications.lazy.tsx",
|
||||
"parent": "/_authenticated/settings"
|
||||
},
|
||||
"/_authenticated/dashboard/": {
|
||||
"filePath": "_authenticated/dashboard/index.tsx",
|
||||
"parent": "/_authenticated"
|
||||
},
|
||||
"/_authenticated/apps/": {
|
||||
"filePath": "_authenticated/apps/index.lazy.tsx",
|
||||
"parent": "/_authenticated"
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { createFileRoute } from "@tanstack/react-router";
|
||||
import Dashboard from "@/pages/dashboard";
|
||||
|
||||
export const Route = createFileRoute("/_authenticated/")({
|
||||
export const Route = createFileRoute("/_authenticated/dashboard/")({
|
||||
component: Dashboard
|
||||
});
|
@ -1,5 +1,5 @@
|
||||
import Cookies from "js-cookie";
|
||||
import { createFileRoute, Outlet } from "@tanstack/react-router";
|
||||
import { createFileRoute, Outlet, redirect } from "@tanstack/react-router";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { SearchProvider } from "@/context/search-context";
|
||||
import { SidebarProvider } from "@/components/ui/sidebar";
|
||||
@ -7,6 +7,16 @@ import { AppSidebar } from "@/components/layout/app-sidebar";
|
||||
import SkipToMain from "@/components/skip-to-main";
|
||||
|
||||
export const Route = createFileRoute("/_authenticated")({
|
||||
beforeLoad: async ({ location }) => {
|
||||
if (true) {
|
||||
throw redirect({
|
||||
to: "/sign-in",
|
||||
search: {
|
||||
redirect: location.href
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
component: RouteComponent
|
||||
});
|
||||
|
||||
|
6
frontend/src/routes/index.tsx
Normal file
6
frontend/src/routes/index.tsx
Normal file
@ -0,0 +1,6 @@
|
||||
import { createFileRoute } from "@tanstack/react-router";
|
||||
import MainPage from "@/pages/home";
|
||||
|
||||
export const Route = createFileRoute("/")({
|
||||
component: MainPage
|
||||
});
|
Loading…
x
Reference in New Issue
Block a user