updated codegen, fixed tsconfig, added prisma
added login, registration and session check
This commit is contained in:
parent
9518787206
commit
04b606b7fa
24 changed files with 740 additions and 1747 deletions
|
|
@ -1,7 +1,7 @@
|
|||
"use client";
|
||||
'use client';
|
||||
|
||||
import { Theme, ChakraProvider, defaultSystem } from "@chakra-ui/react";
|
||||
import { ColorModeProvider, type ColorModeProviderProps } from "./color-mode";
|
||||
import { ChakraProvider, defaultSystem, Theme } from '@chakra-ui/react';
|
||||
import { ColorModeProvider, type ColorModeProviderProps } from './color-mode';
|
||||
|
||||
export function Provider(props: ColorModeProviderProps) {
|
||||
return (
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
import { ApolloClient, ApolloProvider, InMemoryCache } from '@apollo/client';
|
||||
import '@client/assets/styles/index.css';
|
||||
import '@client/assets/styles/nerd-fonts-icons.css';
|
||||
import { StrictMode } from 'react';
|
||||
import ReactDOM from 'react-dom/client';
|
||||
import { Provider } from '@client/components/ui/provider';
|
||||
import { RouterProvider, createRouter } from '@tanstack/react-router';
|
||||
import { ApolloClient, InMemoryCache, ApolloProvider } from '@apollo/client';
|
||||
import { StrictMode } from 'react';
|
||||
import ReactDOM from 'react-dom/client';
|
||||
|
||||
// TanStackRouter - Import the generated route tree
|
||||
import { routeTree } from './routeTree.gen';
|
||||
|
|
|
|||
|
|
@ -1,28 +1,28 @@
|
|||
import { Button, Stack } from "@chakra-ui/react";
|
||||
import { createRootRoute, Link, Outlet } from "@tanstack/react-router";
|
||||
import React from "react";
|
||||
import { Button, Stack } from '@chakra-ui/react';
|
||||
import { createRootRoute, Link, Outlet } from '@tanstack/react-router';
|
||||
import React from 'react';
|
||||
|
||||
const TanStackRouterDevtools =
|
||||
process.env.NODE_ENV === "production"
|
||||
process.env.NODE_ENV === 'production'
|
||||
? () => null // Render nothing in production
|
||||
: React.lazy(() =>
|
||||
// Lazy load in development
|
||||
import("@tanstack/router-devtools").then((res) => ({
|
||||
default: res.TanStackRouterDevtools,
|
||||
import('@tanstack/router-devtools').then(res => ({
|
||||
default: res.TanStackRouterDevtools
|
||||
// For Embedded Mode
|
||||
// default: res.TanStackRouterDevtoolsPanel
|
||||
})),
|
||||
}))
|
||||
);
|
||||
|
||||
export const Route = createRootRoute({
|
||||
component: () => (
|
||||
<Stack padding={3}>
|
||||
<Stack flexDirection={"row"} justifyContent={"space-between"}>
|
||||
<Stack flexDirection={'row'} justifyContent={'space-between'}>
|
||||
<Link to="/">
|
||||
<Button>Home</Button>
|
||||
</Link>
|
||||
|
||||
<Stack flexDirection={"row"}>
|
||||
<Stack flexDirection={'row'}>
|
||||
<Link to="/login">
|
||||
<Button>Sign in</Button>
|
||||
</Link>
|
||||
|
|
@ -31,9 +31,9 @@ export const Route = createRootRoute({
|
|||
</Link>
|
||||
</Stack>
|
||||
</Stack>
|
||||
<hr style={{ padding: "4px" }} />
|
||||
<hr style={{ padding: '4px' }} />
|
||||
<Outlet />
|
||||
<TanStackRouterDevtools />
|
||||
</Stack>
|
||||
),
|
||||
)
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,20 +1,20 @@
|
|||
import { createLazyFileRoute } from "@tanstack/react-router";
|
||||
import { gql, useQuery } from "@apollo/client";
|
||||
// import { gql } from '@apollo/client';
|
||||
import { createLazyFileRoute } from '@tanstack/react-router';
|
||||
|
||||
export const Route = createLazyFileRoute("/book")({
|
||||
component: RouteComponent,
|
||||
export const Route = createLazyFileRoute('/book')({
|
||||
component: RouteComponent
|
||||
});
|
||||
|
||||
function RouteComponent() {
|
||||
return <div>"/book"</div>;
|
||||
}
|
||||
|
||||
const getBookQuery = gql`
|
||||
query BookOne {
|
||||
booksMany {
|
||||
id
|
||||
author
|
||||
title
|
||||
}
|
||||
}
|
||||
`;
|
||||
// const getBookQuery = gql`
|
||||
// query BookOne {
|
||||
// booksMany {
|
||||
// id
|
||||
// author
|
||||
// title
|
||||
// }
|
||||
// }
|
||||
// `;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { Text, Stack } from '@chakra-ui/react';
|
||||
import { Stack, Text } from '@chakra-ui/react';
|
||||
import { createFileRoute } from '@tanstack/react-router';
|
||||
|
||||
import { gql, useQuery } from '@apollo/client';
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
import { gql, useQuery } from '@apollo/client';
|
||||
// import { gql, useQuery } from '@apollo/client';
|
||||
import { Heading, Input, Stack } from '@chakra-ui/react';
|
||||
import { Button } from '@client/components/ui/button';
|
||||
import { Field } from '@client/components/ui/field';
|
||||
import { valibotResolver } from '@hookform/resolvers/valibot';
|
||||
import { createFileRoute } from '@tanstack/react-router';
|
||||
import { useForm } from 'react-hook-form';
|
||||
import { valibotResolver } from '@hookform/resolvers/valibot';
|
||||
import * as v from 'valibot';
|
||||
|
||||
export const Route = createFileRoute('/login')({
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
import { gql, useQuery } from '@apollo/client';
|
||||
// import { gql, useQuery } from '@apollo/client';
|
||||
import { Heading, Input, Stack } from '@chakra-ui/react';
|
||||
import { Button } from '@client/components/ui/button';
|
||||
import { Field } from '@client/components/ui/field';
|
||||
import { valibotResolver } from '@hookform/resolvers/valibot';
|
||||
import { createFileRoute } from '@tanstack/react-router';
|
||||
import { useForm } from 'react-hook-form';
|
||||
import { valibotResolver } from '@hookform/resolvers/valibot';
|
||||
import * as v from 'valibot';
|
||||
|
||||
export const Route = createFileRoute('/register')({
|
||||
|
|
@ -53,7 +53,7 @@ function Register() {
|
|||
formState: { errors }
|
||||
} = useForm<FormValues>({ resolver: valibotResolver(schema) });
|
||||
|
||||
const onSubmit = handleSubmit(data => console.log(data));
|
||||
const onSubmit = handleSubmit(data => alert(data));
|
||||
|
||||
return (
|
||||
<form onSubmit={onSubmit}>
|
||||
|
|
|
|||
|
|
@ -8,130 +8,130 @@
|
|||
// You should NOT make any changes in this file as it will be overwritten.
|
||||
// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified.
|
||||
|
||||
import { createFileRoute } from '@tanstack/react-router'
|
||||
import { createFileRoute } from '@tanstack/react-router';
|
||||
|
||||
// Import Routes
|
||||
|
||||
import { Route as rootRoute } from './pages/__root'
|
||||
import { Route as RegisterImport } from './pages/register'
|
||||
import { Route as LoginImport } from './pages/login'
|
||||
import { Route as IndexImport } from './pages/index'
|
||||
import { Route as rootRoute } from './pages/__root';
|
||||
import { Route as RegisterImport } from './pages/register';
|
||||
import { Route as LoginImport } from './pages/login';
|
||||
import { Route as IndexImport } from './pages/index';
|
||||
|
||||
// Create Virtual Routes
|
||||
|
||||
const BookLazyImport = createFileRoute('/book')()
|
||||
const BookLazyImport = createFileRoute('/book')();
|
||||
|
||||
// Create/Update Routes
|
||||
|
||||
const BookLazyRoute = BookLazyImport.update({
|
||||
id: '/book',
|
||||
path: '/book',
|
||||
getParentRoute: () => rootRoute,
|
||||
} as any).lazy(() => import('./pages/book.lazy').then((d) => d.Route))
|
||||
getParentRoute: () => rootRoute
|
||||
} as any).lazy(() => import('./pages/book.lazy').then(d => d.Route));
|
||||
|
||||
const RegisterRoute = RegisterImport.update({
|
||||
id: '/register',
|
||||
path: '/register',
|
||||
getParentRoute: () => rootRoute,
|
||||
} as any)
|
||||
getParentRoute: () => rootRoute
|
||||
} as any);
|
||||
|
||||
const LoginRoute = LoginImport.update({
|
||||
id: '/login',
|
||||
path: '/login',
|
||||
getParentRoute: () => rootRoute,
|
||||
} as any)
|
||||
getParentRoute: () => rootRoute
|
||||
} as any);
|
||||
|
||||
const IndexRoute = IndexImport.update({
|
||||
id: '/',
|
||||
path: '/',
|
||||
getParentRoute: () => rootRoute,
|
||||
} as any)
|
||||
getParentRoute: () => rootRoute
|
||||
} as any);
|
||||
|
||||
// Populate the FileRoutesByPath interface
|
||||
|
||||
declare module '@tanstack/react-router' {
|
||||
interface FileRoutesByPath {
|
||||
'/': {
|
||||
id: '/'
|
||||
path: '/'
|
||||
fullPath: '/'
|
||||
preLoaderRoute: typeof IndexImport
|
||||
parentRoute: typeof rootRoute
|
||||
}
|
||||
id: '/';
|
||||
path: '/';
|
||||
fullPath: '/';
|
||||
preLoaderRoute: typeof IndexImport;
|
||||
parentRoute: typeof rootRoute;
|
||||
};
|
||||
'/login': {
|
||||
id: '/login'
|
||||
path: '/login'
|
||||
fullPath: '/login'
|
||||
preLoaderRoute: typeof LoginImport
|
||||
parentRoute: typeof rootRoute
|
||||
}
|
||||
id: '/login';
|
||||
path: '/login';
|
||||
fullPath: '/login';
|
||||
preLoaderRoute: typeof LoginImport;
|
||||
parentRoute: typeof rootRoute;
|
||||
};
|
||||
'/register': {
|
||||
id: '/register'
|
||||
path: '/register'
|
||||
fullPath: '/register'
|
||||
preLoaderRoute: typeof RegisterImport
|
||||
parentRoute: typeof rootRoute
|
||||
}
|
||||
id: '/register';
|
||||
path: '/register';
|
||||
fullPath: '/register';
|
||||
preLoaderRoute: typeof RegisterImport;
|
||||
parentRoute: typeof rootRoute;
|
||||
};
|
||||
'/book': {
|
||||
id: '/book'
|
||||
path: '/book'
|
||||
fullPath: '/book'
|
||||
preLoaderRoute: typeof BookLazyImport
|
||||
parentRoute: typeof rootRoute
|
||||
}
|
||||
id: '/book';
|
||||
path: '/book';
|
||||
fullPath: '/book';
|
||||
preLoaderRoute: typeof BookLazyImport;
|
||||
parentRoute: typeof rootRoute;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// Create and export the route tree
|
||||
|
||||
export interface FileRoutesByFullPath {
|
||||
'/': typeof IndexRoute
|
||||
'/login': typeof LoginRoute
|
||||
'/register': typeof RegisterRoute
|
||||
'/book': typeof BookLazyRoute
|
||||
'/': typeof IndexRoute;
|
||||
'/login': typeof LoginRoute;
|
||||
'/register': typeof RegisterRoute;
|
||||
'/book': typeof BookLazyRoute;
|
||||
}
|
||||
|
||||
export interface FileRoutesByTo {
|
||||
'/': typeof IndexRoute
|
||||
'/login': typeof LoginRoute
|
||||
'/register': typeof RegisterRoute
|
||||
'/book': typeof BookLazyRoute
|
||||
'/': typeof IndexRoute;
|
||||
'/login': typeof LoginRoute;
|
||||
'/register': typeof RegisterRoute;
|
||||
'/book': typeof BookLazyRoute;
|
||||
}
|
||||
|
||||
export interface FileRoutesById {
|
||||
__root__: typeof rootRoute
|
||||
'/': typeof IndexRoute
|
||||
'/login': typeof LoginRoute
|
||||
'/register': typeof RegisterRoute
|
||||
'/book': typeof BookLazyRoute
|
||||
__root__: typeof rootRoute;
|
||||
'/': typeof IndexRoute;
|
||||
'/login': typeof LoginRoute;
|
||||
'/register': typeof RegisterRoute;
|
||||
'/book': typeof BookLazyRoute;
|
||||
}
|
||||
|
||||
export interface FileRouteTypes {
|
||||
fileRoutesByFullPath: FileRoutesByFullPath
|
||||
fullPaths: '/' | '/login' | '/register' | '/book'
|
||||
fileRoutesByTo: FileRoutesByTo
|
||||
to: '/' | '/login' | '/register' | '/book'
|
||||
id: '__root__' | '/' | '/login' | '/register' | '/book'
|
||||
fileRoutesById: FileRoutesById
|
||||
fileRoutesByFullPath: FileRoutesByFullPath;
|
||||
fullPaths: '/' | '/login' | '/register' | '/book';
|
||||
fileRoutesByTo: FileRoutesByTo;
|
||||
to: '/' | '/login' | '/register' | '/book';
|
||||
id: '__root__' | '/' | '/login' | '/register' | '/book';
|
||||
fileRoutesById: FileRoutesById;
|
||||
}
|
||||
|
||||
export interface RootRouteChildren {
|
||||
IndexRoute: typeof IndexRoute
|
||||
LoginRoute: typeof LoginRoute
|
||||
RegisterRoute: typeof RegisterRoute
|
||||
BookLazyRoute: typeof BookLazyRoute
|
||||
IndexRoute: typeof IndexRoute;
|
||||
LoginRoute: typeof LoginRoute;
|
||||
RegisterRoute: typeof RegisterRoute;
|
||||
BookLazyRoute: typeof BookLazyRoute;
|
||||
}
|
||||
|
||||
const rootRouteChildren: RootRouteChildren = {
|
||||
IndexRoute: IndexRoute,
|
||||
LoginRoute: LoginRoute,
|
||||
RegisterRoute: RegisterRoute,
|
||||
BookLazyRoute: BookLazyRoute,
|
||||
}
|
||||
BookLazyRoute: BookLazyRoute
|
||||
};
|
||||
|
||||
export const routeTree = rootRoute
|
||||
._addFileChildren(rootRouteChildren)
|
||||
._addFileTypes<FileRouteTypes>()
|
||||
._addFileTypes<FileRouteTypes>();
|
||||
|
||||
/* ROUTE_MANIFEST_START
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue