Loads campaigns in the index.
This commit is contained in:
@@ -15,7 +15,6 @@ import { Route as LoginImport } from './routes/login'
|
|||||||
import { Route as AboutImport } from './routes/about'
|
import { Route as AboutImport } from './routes/about'
|
||||||
import { Route as AuthenticatedImport } from './routes/_authenticated'
|
import { Route as AuthenticatedImport } from './routes/_authenticated'
|
||||||
import { Route as IndexImport } from './routes/index'
|
import { Route as IndexImport } from './routes/index'
|
||||||
import { Route as AuthenticatedSessionsIndexImport } from './routes/_authenticated/sessions.index'
|
|
||||||
import { Route as AuthenticatedCampaignsIndexImport } from './routes/_authenticated/campaigns.index'
|
import { Route as AuthenticatedCampaignsIndexImport } from './routes/_authenticated/campaigns.index'
|
||||||
import { Route as AuthenticatedCampaignsCampaignIdImport } from './routes/_authenticated/campaigns.$campaignId'
|
import { Route as AuthenticatedCampaignsCampaignIdImport } from './routes/_authenticated/campaigns.$campaignId'
|
||||||
|
|
||||||
@@ -44,14 +43,6 @@ const IndexRoute = IndexImport.update({
|
|||||||
getParentRoute: () => rootRoute,
|
getParentRoute: () => rootRoute,
|
||||||
} as any)
|
} as any)
|
||||||
|
|
||||||
const AuthenticatedSessionsIndexRoute = AuthenticatedSessionsIndexImport.update(
|
|
||||||
{
|
|
||||||
id: '/sessions/',
|
|
||||||
path: '/sessions/',
|
|
||||||
getParentRoute: () => AuthenticatedRoute,
|
|
||||||
} as any,
|
|
||||||
)
|
|
||||||
|
|
||||||
const AuthenticatedCampaignsIndexRoute =
|
const AuthenticatedCampaignsIndexRoute =
|
||||||
AuthenticatedCampaignsIndexImport.update({
|
AuthenticatedCampaignsIndexImport.update({
|
||||||
id: '/campaigns/',
|
id: '/campaigns/',
|
||||||
@@ -112,13 +103,6 @@ declare module '@tanstack/react-router' {
|
|||||||
preLoaderRoute: typeof AuthenticatedCampaignsIndexImport
|
preLoaderRoute: typeof AuthenticatedCampaignsIndexImport
|
||||||
parentRoute: typeof AuthenticatedImport
|
parentRoute: typeof AuthenticatedImport
|
||||||
}
|
}
|
||||||
'/_authenticated/sessions/': {
|
|
||||||
id: '/_authenticated/sessions/'
|
|
||||||
path: '/sessions'
|
|
||||||
fullPath: '/sessions'
|
|
||||||
preLoaderRoute: typeof AuthenticatedSessionsIndexImport
|
|
||||||
parentRoute: typeof AuthenticatedImport
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -127,13 +111,11 @@ declare module '@tanstack/react-router' {
|
|||||||
interface AuthenticatedRouteChildren {
|
interface AuthenticatedRouteChildren {
|
||||||
AuthenticatedCampaignsCampaignIdRoute: typeof AuthenticatedCampaignsCampaignIdRoute
|
AuthenticatedCampaignsCampaignIdRoute: typeof AuthenticatedCampaignsCampaignIdRoute
|
||||||
AuthenticatedCampaignsIndexRoute: typeof AuthenticatedCampaignsIndexRoute
|
AuthenticatedCampaignsIndexRoute: typeof AuthenticatedCampaignsIndexRoute
|
||||||
AuthenticatedSessionsIndexRoute: typeof AuthenticatedSessionsIndexRoute
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const AuthenticatedRouteChildren: AuthenticatedRouteChildren = {
|
const AuthenticatedRouteChildren: AuthenticatedRouteChildren = {
|
||||||
AuthenticatedCampaignsCampaignIdRoute: AuthenticatedCampaignsCampaignIdRoute,
|
AuthenticatedCampaignsCampaignIdRoute: AuthenticatedCampaignsCampaignIdRoute,
|
||||||
AuthenticatedCampaignsIndexRoute: AuthenticatedCampaignsIndexRoute,
|
AuthenticatedCampaignsIndexRoute: AuthenticatedCampaignsIndexRoute,
|
||||||
AuthenticatedSessionsIndexRoute: AuthenticatedSessionsIndexRoute,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const AuthenticatedRouteWithChildren = AuthenticatedRoute._addFileChildren(
|
const AuthenticatedRouteWithChildren = AuthenticatedRoute._addFileChildren(
|
||||||
@@ -147,7 +129,6 @@ export interface FileRoutesByFullPath {
|
|||||||
'/login': typeof LoginRoute
|
'/login': typeof LoginRoute
|
||||||
'/campaigns/$campaignId': typeof AuthenticatedCampaignsCampaignIdRoute
|
'/campaigns/$campaignId': typeof AuthenticatedCampaignsCampaignIdRoute
|
||||||
'/campaigns': typeof AuthenticatedCampaignsIndexRoute
|
'/campaigns': typeof AuthenticatedCampaignsIndexRoute
|
||||||
'/sessions': typeof AuthenticatedSessionsIndexRoute
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface FileRoutesByTo {
|
export interface FileRoutesByTo {
|
||||||
@@ -157,7 +138,6 @@ export interface FileRoutesByTo {
|
|||||||
'/login': typeof LoginRoute
|
'/login': typeof LoginRoute
|
||||||
'/campaigns/$campaignId': typeof AuthenticatedCampaignsCampaignIdRoute
|
'/campaigns/$campaignId': typeof AuthenticatedCampaignsCampaignIdRoute
|
||||||
'/campaigns': typeof AuthenticatedCampaignsIndexRoute
|
'/campaigns': typeof AuthenticatedCampaignsIndexRoute
|
||||||
'/sessions': typeof AuthenticatedSessionsIndexRoute
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface FileRoutesById {
|
export interface FileRoutesById {
|
||||||
@@ -168,7 +148,6 @@ export interface FileRoutesById {
|
|||||||
'/login': typeof LoginRoute
|
'/login': typeof LoginRoute
|
||||||
'/_authenticated/campaigns/$campaignId': typeof AuthenticatedCampaignsCampaignIdRoute
|
'/_authenticated/campaigns/$campaignId': typeof AuthenticatedCampaignsCampaignIdRoute
|
||||||
'/_authenticated/campaigns/': typeof AuthenticatedCampaignsIndexRoute
|
'/_authenticated/campaigns/': typeof AuthenticatedCampaignsIndexRoute
|
||||||
'/_authenticated/sessions/': typeof AuthenticatedSessionsIndexRoute
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface FileRouteTypes {
|
export interface FileRouteTypes {
|
||||||
@@ -180,16 +159,8 @@ export interface FileRouteTypes {
|
|||||||
| '/login'
|
| '/login'
|
||||||
| '/campaigns/$campaignId'
|
| '/campaigns/$campaignId'
|
||||||
| '/campaigns'
|
| '/campaigns'
|
||||||
| '/sessions'
|
|
||||||
fileRoutesByTo: FileRoutesByTo
|
fileRoutesByTo: FileRoutesByTo
|
||||||
to:
|
to: '/' | '' | '/about' | '/login' | '/campaigns/$campaignId' | '/campaigns'
|
||||||
| '/'
|
|
||||||
| ''
|
|
||||||
| '/about'
|
|
||||||
| '/login'
|
|
||||||
| '/campaigns/$campaignId'
|
|
||||||
| '/campaigns'
|
|
||||||
| '/sessions'
|
|
||||||
id:
|
id:
|
||||||
| '__root__'
|
| '__root__'
|
||||||
| '/'
|
| '/'
|
||||||
@@ -198,7 +169,6 @@ export interface FileRouteTypes {
|
|||||||
| '/login'
|
| '/login'
|
||||||
| '/_authenticated/campaigns/$campaignId'
|
| '/_authenticated/campaigns/$campaignId'
|
||||||
| '/_authenticated/campaigns/'
|
| '/_authenticated/campaigns/'
|
||||||
| '/_authenticated/sessions/'
|
|
||||||
fileRoutesById: FileRoutesById
|
fileRoutesById: FileRoutesById
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -239,8 +209,7 @@ export const routeTree = rootRoute
|
|||||||
"filePath": "_authenticated.tsx",
|
"filePath": "_authenticated.tsx",
|
||||||
"children": [
|
"children": [
|
||||||
"/_authenticated/campaigns/$campaignId",
|
"/_authenticated/campaigns/$campaignId",
|
||||||
"/_authenticated/campaigns/",
|
"/_authenticated/campaigns/"
|
||||||
"/_authenticated/sessions/"
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"/about": {
|
"/about": {
|
||||||
@@ -256,10 +225,6 @@ export const routeTree = rootRoute
|
|||||||
"/_authenticated/campaigns/": {
|
"/_authenticated/campaigns/": {
|
||||||
"filePath": "_authenticated/campaigns.index.tsx",
|
"filePath": "_authenticated/campaigns.index.tsx",
|
||||||
"parent": "/_authenticated"
|
"parent": "/_authenticated"
|
||||||
},
|
|
||||||
"/_authenticated/sessions/": {
|
|
||||||
"filePath": "_authenticated/sessions.index.tsx",
|
|
||||||
"parent": "/_authenticated"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,37 @@
|
|||||||
import { createFileRoute } from "@tanstack/react-router";
|
import { createFileRoute } from "@tanstack/react-router";
|
||||||
|
import { pb } from "@/lib/pocketbase";
|
||||||
|
import type { Campaign } from "@/lib/types";
|
||||||
|
import { Link } from "@tanstack/react-router";
|
||||||
|
|
||||||
export const Route = createFileRoute("/_authenticated/campaigns/")({
|
export const Route = createFileRoute("/_authenticated/campaigns/")({
|
||||||
|
loader: async () => {
|
||||||
|
const records = await pb.collection("campaigns").getFullList();
|
||||||
|
return { campaigns: records.map((rec: any) => ({ id: rec.id, name: rec.name })) as Campaign[] };
|
||||||
|
},
|
||||||
component: RouteComponent,
|
component: RouteComponent,
|
||||||
});
|
});
|
||||||
|
|
||||||
function RouteComponent() {
|
function RouteComponent() {
|
||||||
return <div>Hello "/campaigns/"!</div>;
|
const { campaigns } = Route.useLoaderData();
|
||||||
|
|
||||||
|
if (!campaigns || campaigns.length === 0) return <div>No campaigns found.</div>;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="max-w-xl mx-auto py-8">
|
||||||
|
<h2 className="text-xl font-bold mb-4 text-slate-100">Your Campaigns</h2>
|
||||||
|
<ul className="space-y-2">
|
||||||
|
{campaigns.map((c) => (
|
||||||
|
<li key={c.id}>
|
||||||
|
<Link
|
||||||
|
to="/campaigns/$campaignId"
|
||||||
|
params={{ campaignId: c.id }}
|
||||||
|
className="block px-4 py-2 rounded bg-slate-800 hover:bg-violet-700 text-slate-100 transition-colors"
|
||||||
|
>
|
||||||
|
{c.name}
|
||||||
|
</Link>
|
||||||
|
</li>
|
||||||
|
))}
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +0,0 @@
|
|||||||
import { createFileRoute } from '@tanstack/react-router'
|
|
||||||
|
|
||||||
export const Route = createFileRoute('/_authenticated/sessions/')({
|
|
||||||
component: RouteComponent,
|
|
||||||
})
|
|
||||||
|
|
||||||
function RouteComponent() {
|
|
||||||
return <div>Hello "/sessions/"!</div>
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user