diff --git a/apps/web/src/app/app/app-dashboard.tsx b/apps/web/src/app/app/app-dashboard.tsx new file mode 100644 index 00000000..cb21c218 --- /dev/null +++ b/apps/web/src/app/app/app-dashboard.tsx @@ -0,0 +1,23 @@ +import { AppConsumersList } from '@/components/app-consumers-list' +import { AppProjectsList } from '@/components/app-projects-list' + +export function AppDashboard() { + return ( + <> +
+

+ Dashboard +

+ +
+ + + +
+
+ + ) +} diff --git a/apps/web/src/app/app/app-index.tsx b/apps/web/src/app/app/app-index.tsx deleted file mode 100644 index d3b40804..00000000 --- a/apps/web/src/app/app/app-index.tsx +++ /dev/null @@ -1,111 +0,0 @@ -'use client' - -import Link from 'next/link' -import useInfiniteScroll from 'react-infinite-scroll-hook' - -import { useAuthenticatedAgentic } from '@/components/agentic-provider' -import { LoadingIndicator } from '@/components/loading-indicator' -import { useInfiniteQuery } from '@/lib/query-client' - -export function AppIndex() { - const ctx = useAuthenticatedAgentic() - const limit = 10 - const { - data, - isLoading, - isError, - hasNextPage, - fetchNextPage, - isFetchingNextPage - } = useInfiniteQuery({ - queryKey: ['projects', ctx?.api.authSession?.user?.id], - queryFn: ({ pageParam = 0 }) => - ctx!.api - .listProjects({ - populate: ['lastPublishedDeployment'], - offset: pageParam, - limit - }) - .then(async (projects) => { - return { - projects, - offset: pageParam, - limit, - nextOffset: - projects.length >= limit ? pageParam + projects.length : undefined - } - }), - getNextPageParam: (lastGroup) => lastGroup?.nextOffset, - enabled: !!ctx, - initialPageParam: 0 - }) - - const [sentryRef] = useInfiniteScroll({ - loading: isLoading || isFetchingNextPage, - hasNextPage, - onLoadMore: fetchNextPage, - disabled: !ctx || isError, - rootMargin: '0px 0px 200px 0px' - }) - - const projects = data ? data.pages.flatMap((p) => p.projects) : [] - - return ( - <> -
-

- Dashboard -

- - {!ctx || isLoading ? ( - - ) : ( -
-

Your Projects

- - {isError ? ( -

Error fetching projects

- ) : !projects.length ? ( -

- No projects found. Create your first project to get started! -

- ) : ( -
- {projects.map((project) => ( - -

{project.name}

- -

- {project.identifier} -

- - {project.lastPublishedDeployment && ( -

- Last published:{' '} - {project.lastPublishedDeployment.version || - project.lastPublishedDeployment.hash} -

- )} - - ))} - - {hasNextPage && ( -
- {isLoading || (isFetchingNextPage && )} -
- )} -
- )} -
- )} -
- - ) -} diff --git a/apps/web/src/app/app/consumers/app-consumers-index.tsx b/apps/web/src/app/app/consumers/app-consumers-index.tsx index 2b1e8d03..b9a0ee8b 100644 --- a/apps/web/src/app/app/consumers/app-consumers-index.tsx +++ b/apps/web/src/app/app/consumers/app-consumers-index.tsx @@ -1,57 +1,6 @@ -'use client' - -import Link from 'next/link' -import useInfiniteScroll from 'react-infinite-scroll-hook' - -import { useAuthenticatedAgentic } from '@/components/agentic-provider' -import { LoadingIndicator } from '@/components/loading-indicator' -import { useInfiniteQuery } from '@/lib/query-client' +import { AppConsumersList } from '@/components/app-consumers-list' export function AppConsumersIndex() { - const ctx = useAuthenticatedAgentic() - const limit = 10 - const { - data, - isLoading, - isError, - hasNextPage, - fetchNextPage, - isFetchingNextPage - } = useInfiniteQuery({ - queryKey: ['consumers', ctx?.api.authSession?.user?.id], - queryFn: ({ pageParam = 0 }) => - ctx!.api - .listConsumers({ - populate: ['project'], - offset: pageParam, - limit - }) - .then(async (consumers) => { - return { - consumers, - offset: pageParam, - limit, - nextOffset: - consumers.length >= limit - ? pageParam + consumers.length - : undefined - } - }), - getNextPageParam: (lastGroup) => lastGroup?.nextOffset, - enabled: !!ctx, - initialPageParam: 0 - }) - - const [sentryRef] = useInfiniteScroll({ - loading: isLoading || isFetchingNextPage, - hasNextPage, - onLoadMore: fetchNextPage, - disabled: !ctx || isError, - rootMargin: '0px 0px 200px 0px' - }) - - const consumers = data ? data.pages.flatMap((p) => p.consumers) : [] - return ( <>
@@ -62,46 +11,7 @@ export function AppConsumersIndex() { Your Subscriptions - {!ctx || isLoading ? ( - - ) : ( -
- {isError ? ( -

Error fetching customer subscriptions

- ) : !consumers.length ? ( -

- No subscriptions found. Subscribe to your first project to get - started! -

- ) : ( -
- {consumers.map((consumer) => ( - -

{consumer.project.name}

- -

- {consumer.project.identifier} -

- -
-                      {JSON.stringify(consumer, null, 2)}
-                    
- - ))} - - {hasNextPage && ( -
- {isLoading || (isFetchingNextPage && )} -
- )} -
- )} -
- )} +
) diff --git a/apps/web/src/app/app/page.tsx b/apps/web/src/app/app/page.tsx index ba9d5c9f..b3df22a5 100644 --- a/apps/web/src/app/app/page.tsx +++ b/apps/web/src/app/app/page.tsx @@ -1,5 +1,5 @@ -import { AppIndex } from './app-index' +import { AppDashboard } from './app-dashboard' export default function AppIndexPage() { - return + return } diff --git a/apps/web/src/app/app/projects/app-projects-index.tsx b/apps/web/src/app/app/projects/app-projects-index.tsx new file mode 100644 index 00000000..7640769e --- /dev/null +++ b/apps/web/src/app/app/projects/app-projects-index.tsx @@ -0,0 +1,13 @@ +import { AppProjectsList } from '@/components/app-projects-list' + +export function AppProjectsIndex() { + return ( + <> +
+
+ +
+
+ + ) +} diff --git a/apps/web/src/app/app/projects/page.tsx b/apps/web/src/app/app/projects/page.tsx new file mode 100644 index 00000000..0466d9c2 --- /dev/null +++ b/apps/web/src/app/app/projects/page.tsx @@ -0,0 +1,5 @@ +import { AppProjectsIndex } from './app-projects-index' + +export default function AppProjectsIndexPage() { + return +} diff --git a/apps/web/src/components/app-consumers-list.tsx b/apps/web/src/components/app-consumers-list.tsx new file mode 100644 index 00000000..cfb10754 --- /dev/null +++ b/apps/web/src/components/app-consumers-list.tsx @@ -0,0 +1,101 @@ +'use client' + +import Link from 'next/link' +import useInfiniteScroll from 'react-infinite-scroll-hook' + +import { useAuthenticatedAgentic } from '@/components/agentic-provider' +import { LoadingIndicator } from '@/components/loading-indicator' +import { useInfiniteQuery } from '@/lib/query-client' + +export function AppConsumersList() { + const ctx = useAuthenticatedAgentic() + const limit = 10 + const { + data, + isLoading, + isError, + hasNextPage, + fetchNextPage, + isFetchingNextPage + } = useInfiniteQuery({ + queryKey: ['consumers', ctx?.api.authSession?.user?.id], + queryFn: ({ pageParam = 0 }) => + ctx!.api + .listConsumers({ + populate: ['project'], + offset: pageParam, + limit + }) + .then(async (consumers) => { + return { + consumers, + offset: pageParam, + limit, + nextOffset: + consumers.length >= limit + ? pageParam + consumers.length + : undefined + } + }), + getNextPageParam: (lastGroup) => lastGroup?.nextOffset, + enabled: !!ctx, + initialPageParam: 0 + }) + + const [sentryRef] = useInfiniteScroll({ + loading: isLoading || isFetchingNextPage, + hasNextPage, + onLoadMore: fetchNextPage, + disabled: !ctx || isError, + rootMargin: '0px 0px 200px 0px' + }) + + const consumers = data ? data.pages.flatMap((p) => p.consumers) : [] + + return ( + <> + {!ctx || isLoading ? ( + + ) : ( +
+

Your Subscriptions

+ + {isError ? ( +

Error fetching customer subscriptions

+ ) : !consumers.length ? ( +

+ No subscriptions found. Subscribe to your first project to get + started! +

+ ) : ( +
+ {consumers.map((consumer) => ( + +

{consumer.project.name}

+ +

+ {consumer.project.identifier} +

+ +
+                    {JSON.stringify(consumer, null, 2)}
+                  
+ + ))} + + {hasNextPage && ( +
+ {isLoading || (isFetchingNextPage && )} +
+ )} +
+ )} +
+ )} + + ) +} diff --git a/apps/web/src/components/app-projects-list.tsx b/apps/web/src/components/app-projects-list.tsx new file mode 100644 index 00000000..ca9d0eda --- /dev/null +++ b/apps/web/src/components/app-projects-list.tsx @@ -0,0 +1,98 @@ +'use client' + +import Link from 'next/link' +import useInfiniteScroll from 'react-infinite-scroll-hook' + +import { useAuthenticatedAgentic } from '@/components/agentic-provider' +import { LoadingIndicator } from '@/components/loading-indicator' +import { useInfiniteQuery } from '@/lib/query-client' + +export function AppProjectsList() { + const ctx = useAuthenticatedAgentic() + const limit = 10 + const { + data, + isLoading, + isError, + hasNextPage, + fetchNextPage, + isFetchingNextPage + } = useInfiniteQuery({ + queryKey: ['projects', ctx?.api.authSession?.user?.id], + queryFn: ({ pageParam = 0 }) => + ctx!.api + .listProjects({ + populate: ['lastPublishedDeployment'], + offset: pageParam, + limit + }) + .then(async (projects) => { + return { + projects, + offset: pageParam, + limit, + nextOffset: + projects.length >= limit ? pageParam + projects.length : undefined + } + }), + getNextPageParam: (lastGroup) => lastGroup?.nextOffset, + enabled: !!ctx, + initialPageParam: 0 + }) + + const [sentryRef] = useInfiniteScroll({ + loading: isLoading || isFetchingNextPage, + hasNextPage, + onLoadMore: fetchNextPage, + disabled: !ctx || isError, + rootMargin: '0px 0px 200px 0px' + }) + + const projects = data ? data.pages.flatMap((p) => p.projects) : [] + + return ( + <> + {!ctx || isLoading ? ( + + ) : ( +
+

Your Projects

+ + {isError ? ( +

Error fetching projects

+ ) : !projects.length ? ( +

No projects found. Create your first project to get started!

+ ) : ( +
+ {projects.map((project) => ( + +

{project.name}

+ +

{project.identifier}

+ + {project.lastPublishedDeployment && ( +

+ Last published:{' '} + {project.lastPublishedDeployment.version || + project.lastPublishedDeployment.hash} +

+ )} + + ))} + + {hasNextPage && ( +
+ {isLoading || (isFetchingNextPage && )} +
+ )} +
+ )} +
+ )} + + ) +}