mirror of
https://github.com/FranP-code/create-better-t-stack.git
synced 2025-10-12 23:52:15 +00:00
fix: backend none templates (#241)
This commit is contained in:
@@ -2,8 +2,10 @@ import { RouterProvider, createRouter } from "@tanstack/solid-router";
|
||||
import { render } from "solid-js/web";
|
||||
import { routeTree } from "./routeTree.gen";
|
||||
import "./styles.css";
|
||||
{{#if (eq api "orpc")}}
|
||||
import { QueryClientProvider } from "@tanstack/solid-query";
|
||||
import { queryClient } from "./utils/orpc";
|
||||
{{/if}}
|
||||
|
||||
const router = createRouter({
|
||||
routeTree,
|
||||
@@ -20,9 +22,13 @@ declare module "@tanstack/solid-router" {
|
||||
|
||||
function App() {
|
||||
return (
|
||||
{{#if (eq api "orpc")}}
|
||||
<QueryClientProvider client={queryClient}>
|
||||
{{/if}}
|
||||
<RouterProvider router={router} />
|
||||
{{#if (eq api "orpc")}}
|
||||
</QueryClientProvider>
|
||||
{{/if}}
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,20 @@
|
||||
import Header from "@/components/header";
|
||||
import { Outlet, createRootRouteWithContext } from "@tanstack/solid-router";
|
||||
import { TanStackRouterDevtools } from "@tanstack/solid-router-devtools";
|
||||
{{#if (eq api "orpc")}}
|
||||
import { SolidQueryDevtools } from "@tanstack/solid-query-devtools";
|
||||
import type { QueryClient } from "@tanstack/solid-query";
|
||||
import type { orpc } from "../utils/orpc";
|
||||
|
||||
export const Route = createRootRouteWithContext()({
|
||||
export interface RouterContext {
|
||||
orpc: typeof orpc;
|
||||
queryClient: QueryClient;
|
||||
}
|
||||
{{else}}
|
||||
export interface RouterContext {}
|
||||
{{/if}}
|
||||
|
||||
export const Route = createRootRouteWithContext<RouterContext>()({
|
||||
component: RootComponent,
|
||||
});
|
||||
|
||||
@@ -14,7 +25,9 @@ function RootComponent() {
|
||||
<Header />
|
||||
<Outlet />
|
||||
</div>
|
||||
{{#if (eq api "orpc")}}
|
||||
<SolidQueryDevtools />
|
||||
{{/if}}
|
||||
<TanStackRouterDevtools />
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
import { createFileRoute } from "@tanstack/solid-router";
|
||||
{{#if (eq api "orpc")}}
|
||||
import { useQuery } from "@tanstack/solid-query";
|
||||
import { orpc } from "../utils/orpc";
|
||||
import { Match, Switch } from "solid-js";
|
||||
{{else}}
|
||||
{{/if}}
|
||||
|
||||
export const Route = createFileRoute("/")({
|
||||
component: App,
|
||||
@@ -24,12 +27,15 @@ const TITLE_TEXT = `
|
||||
`;
|
||||
|
||||
function App() {
|
||||
{{#if (eq api "orpc")}}
|
||||
const healthCheck = useQuery(() => orpc.healthCheck.queryOptions());
|
||||
{{/if}}
|
||||
|
||||
return (
|
||||
<div class="container mx-auto max-w-3xl px-4 py-2">
|
||||
<pre class="overflow-x-auto font-mono text-sm">{TITLE_TEXT}</pre>
|
||||
<div class="grid gap-6">
|
||||
{{#if (eq api "orpc")}}
|
||||
<section class="rounded-lg border p-4">
|
||||
<h2 class="mb-2 font-medium">API Status</h2>
|
||||
<Switch>
|
||||
@@ -53,12 +59,13 @@ function App() {
|
||||
<span class="text-sm text-muted-foreground">
|
||||
{healthCheck.data
|
||||
? "Connected"
|
||||
: "Disconnected (Success but no data)"}
|
||||
: "Disconnected"}
|
||||
</span>
|
||||
</div>
|
||||
</Match>
|
||||
</Switch>
|
||||
</section>
|
||||
{{/if}}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user