The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
started working on a child page for integrations
Steven Tey9bb566d7e10b
diff --git a/apps/web/app/api/oauth-apps/authorized/route.ts b/apps/web/app/api/oauth-apps/authorized/route.tsindex 263c7f2818..98f076baed 100644--- a/apps/web/app/api/oauth-apps/authorized/route.ts+++ b/apps/web/app/api/oauth-apps/authorized/route.ts@@ -15,6 +15,7 @@ export const GET = withWorkspace(oAuthApp: {select: {clientId: true,+ slug: true,name: true,developer: true,website: true,@@ -35,6 +36,7 @@ export const GET = withWorkspace(createdAt: app.createdAt,clientId: app.oAuthApp.clientId,name: app.oAuthApp.name,+ slug: app.oAuthApp.slug,developer: app.oAuthApp.developer,website: app.oAuthApp.website,logo: app.oAuthApp.logo,diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/integrations/[integrationSlug]/page-client.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/integrations/[integrationSlug]/page-client.tsxnew file mode 100644index 0000000000..4b78cf66d7--- /dev/null+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/integrations/[integrationSlug]/page-client.tsx@@ -0,0 +1,27 @@+"use client";++import { useDeleteAppModal } from "@/ui/modals/delete-oauth-app-modal";+import { Button, MaxWidthWrapper } from "@dub/ui";++export default function IntegrationPageClient() {+ const { DeleteAppModal, setShowDeleteAppModal } = useDeleteAppModal({+ app: {+ clientId: "123",+ name: "test",+ },+ appType: "authorized",+ });++ return (+ <MaxWidthWrapper className="my-20">+ <DeleteAppModal />+ <div className="w-fit">+ <Button+ text="Uninstall"+ variant="secondary"+ onClick={() => setShowDeleteAppModal(true)}+ />+ </div>+ </MaxWidthWrapper>+ );+}diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/integrations/[integrationSlug]/page.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/integrations/[integrationSlug]/page.tsxnew file mode 100644index 0000000000..330fe8ffc1--- /dev/null+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/integrations/[integrationSlug]/page.tsx@@ -0,0 +1,5 @@+import IntegrationPageClient from "./page-client";++export default function IntegrationPage() {+ return <IntegrationPageClient />;+}diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/integrations/integration-card.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/integrations/integration-card.tsxindex 3a4b661381..084e88e683 100644--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/integrations/integration-card.tsx+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/integrations/integration-card.tsx@@ -1,72 +1,32 @@+import useWorkspace from "@/lib/swr/use-workspace";import { OAuthAuthorizedAppProps } from "@/lib/types";-import { useDeleteAppModal } from "@/ui/modals/delete-oauth-app-modal";-import { Delete, ThreeDots } from "@/ui/shared/icons";-import { BlurImage, Button, Popover, TokenAvatar } from "@dub/ui";-import { useState } from "react";+import { BlurImage, TokenAvatar } from "@dub/ui";+import Link from "next/link";export default function IntegrationCard(app: OAuthAuthorizedAppProps) {- const [openPopover, setOpenPopover] = useState(false);-- const { DeleteAppModal, setShowDeleteAppModal } = useDeleteAppModal({- app: {- clientId: app.clientId,- name: app.name,- },- appType: "authorized",- });-+ const { slug } = useWorkspace();return (- <>- <DeleteAppModal />- <div className="relative rounded-xl border border-gray-200 bg-white px-5 py-4">- <div className="flex items-center space-x-3">- {app.logo ? (- <BlurImage- src={app.logo}- alt={`Logo for ${app.name}`}- className="h-10 w-10 rounded-full border border-gray-200"- width={20}- height={20}- />- ) : (- <TokenAvatar id={app.clientId} />- )}- <div className="flex flex-col space-y-px">- <p className="font-semibold text-gray-700">{app.name}</p>- <p className="text-sm text-gray-500">Installed</p>- </div>+ <Link+ href={`/${slug}/integrations/${app.slug}`}+ className="relative rounded-xl border border-gray-200 bg-white px-5 py-4"+ >+ <div className="flex items-center space-x-3">+ {app.logo ? (+ <BlurImage+ src={app.logo}+ alt={`Logo for ${app.name}`}+ className="h-10 w-10 rounded-full border border-gray-200"+ width={20}+ height={20}+ />+ ) : (+ <TokenAvatar id={app.clientId} />+ )}+ <div className="flex flex-col space-y-px">+ <p className="font-semibold text-gray-700">{app.name}</p>+ <p className="text-sm text-gray-500">Installed</p></div>- <Popover- content={- <div className="w-full sm:w-48">- <div className="grid gap-px p-2">- <Button- text="Disconnect"- variant="danger-outline"- icon={<Delete className="h-4 w-4" />}- className="h-9 justify-start px-2 font-medium"- onClick={() => {- setOpenPopover(false);- setShowDeleteAppModal(true);- }}- />- </div>- </div>- }- align="end"- openPopover={openPopover}- setOpenPopover={setOpenPopover}- >- <button- onClick={() => {- setOpenPopover(!openPopover);- }}- className="absolute right-4 rounded-md px-1 py-2 transition-all duration-75 hover:bg-gray-100 active:bg-gray-200"- >- <ThreeDots className="h-5 w-5 text-gray-500" />- </button>- </Popover></div>- </>+ </Link>);}diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/integrations/page-client.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/integrations/page-client.tsxindex 02da28be0d..8d46f4d8af 100644--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/integrations/page-client.tsx+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/integrations/page-client.tsx@@ -19,13 +19,15 @@ import { useState } from "react";import useSWR from "swr";import IntegrationCard from "./integration-card";-export default function AuthorizedAppsPageClient() {+export default function IntegrationsPageClient() {const { id: workspaceId, slug, flags } = useWorkspace();const { data: apps, isLoading } = useSWR<OAuthAuthorizedAppProps[]>(`/api/oauth-apps/authorized?workspaceId=${workspaceId}`,fetcher,);+ console.log({ apps });+if (!flags?.integrations) {redirect(`/${slug}`);}@@ -79,9 +81,7 @@ export default function AuthorizedAppsPageClient() {{isLoading || !apps ? (<div className="flex flex-col items-center justify-center space-y-4 py-20"><LoadingSpinner className="h-6 w-6 text-gray-500" />- <p className="text-sm text-gray-500">- Fetching authorized applications...- </p>+ <p className="text-sm text-gray-500">Fetching integrations...</p></div>) : apps.length > 0 ? (<div className="grid gap-4 sm:grid-cols-3">diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/integrations/page.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/integrations/page.tsxindex a0eb11f982..f5c0a4c3df 100644--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/integrations/page.tsx+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/integrations/page.tsx@@ -1,5 +1,5 @@-import AuthorizedAppsPageClient from "./page-client";+import IntegrationsPageClient from "./page-client";-export default function AuthorizedAppsPage() {- return <AuthorizedAppsPageClient />;+export default function IntegrationsPage() {+ return <IntegrationsPageClient />;}diff --git a/apps/web/lib/zod/schemas/oauth.ts b/apps/web/lib/zod/schemas/oauth.tsindex c13580b1aa..c5f748de66 100644--- a/apps/web/lib/zod/schemas/oauth.ts+++ b/apps/web/lib/zod/schemas/oauth.ts@@ -127,6 +127,7 @@ export const oAuthAuthorizedAppSchema = zoAuthAppSchema.pick({clientId: true,name: true,+ slug: true,developer: true,website: true,logo: true,