-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
1,264 additions
and
776 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
apps/webservice/src/app/[workspaceSlug]/(app)/dashboards/CreateDashboardButton.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
"use client"; | ||
|
||
import { useRouter } from "next/navigation"; | ||
|
||
import { Button } from "@ctrlplane/ui/button"; | ||
|
||
import { api } from "~/trpc/react"; | ||
|
||
export const CreateDashboardButton: React.FC<{ | ||
workspace: { id: string; slug: string }; | ||
}> = ({ workspace }) => { | ||
const createDashboard = api.dashboard.create.useMutation(); | ||
const router = useRouter(); | ||
return ( | ||
<Button | ||
onClick={async () => { | ||
const ds = await createDashboard.mutateAsync({ | ||
name: "New Dashboard", | ||
description: "New Dashboard", | ||
workspaceId: workspace.id, | ||
}); | ||
router.push(`/${workspace.slug}/dashboards/${ds.id}`); | ||
}} | ||
> | ||
Create Dashboard | ||
</Button> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 26 additions & 2 deletions
28
apps/webservice/src/app/[workspaceSlug]/(app)/dashboards/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,27 @@ | ||
export default function DasboardsPage() { | ||
return null; | ||
import Link from "next/link"; | ||
import { notFound } from "next/navigation"; | ||
|
||
import { api } from "~/trpc/server"; | ||
import { CreateDashboardButton } from "./CreateDashboardButton"; | ||
|
||
export default async function DasboardsPage({ | ||
params, | ||
}: { | ||
params: { workspaceSlug: string }; | ||
}) { | ||
const workspace = await api.workspace | ||
.bySlug(params.workspaceSlug) | ||
.catch(() => null); | ||
if (workspace == null) return notFound(); | ||
const dashboards = await api.dashboard.byWorkspaceId(workspace.id); | ||
return ( | ||
<div className="flex flex-col gap-4"> | ||
<CreateDashboardButton workspace={workspace} /> | ||
{dashboards.map((d) => ( | ||
<Link key={d.id} href={`/${workspace.slug}/dashboards/${d.id}`}> | ||
{d.name} | ||
</Link> | ||
))} | ||
</div> | ||
); | ||
} |
Oops, something went wrong.