Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

move settings tab to client side hook

Steven Tey1c993bee5368
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/layout-client.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/layout-client.tsx
new file mode 100644
index 0000000000..22315dc4bc
--- /dev/null
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/layout-client.tsx
@@ -0,0 +1,119 @@
+"use client";
+
+import useWorkspace from "@/lib/swr/use-workspace";
+import SettingsLayout from "@/ui/layout/settings-layout";
+import {
+ CircleInfo,
+ ConnectedDots,
+ CubeSettings,
+ Gear2,
+ Gift,
+ Globe,
+ Key,
+ Receipt2,
+ ShieldCheck,
+ Tag,
+ Users6,
+} from "@dub/ui/src/icons";
+import { ReactNode, useMemo } from "react";
+
+export default function WorkspaceSettingsLayoutClient({
+ children,
+}: {
+ children: ReactNode;
+}) {
+ const { flags } = useWorkspace();
+
+ const tabs = useMemo(
+ () => [
+ // Workspace Settings
+ {
+ group: "Workspace Settings",
+ tabs: [
+ {
+ name: "General",
+ icon: Gear2,
+ segment: null,
+ },
+ {
+ name: "Domains",
+ icon: Globe,
+ segment: "domains",
+ },
+ {
+ name: "Tags",
+ icon: Tag,
+ segment: "tags",
+ },
+ {
+ name: "Billing",
+ icon: Receipt2,
+ segment: "billing",
+ },
+ {
+ name: "People",
+ icon: Users6,
+ segment: "people",
+ },
+ ...(flags?.integrations
+ ? [
+ {
+ name: "Integrations",
+ icon: ConnectedDots,
+ segment: "integrations",
+ },
+ ]
+ : []),
+ {
+ name: "Security",
+ icon: ShieldCheck,
+ segment: "security",
+ },
+ ...(flags?.referrals
+ ? [{ name: "Referrals", icon: Gift, segment: "referrals" }]
+ : []),
+ ],
+ },
+
+ // Developer Settings
+ {
+ group: "Developer Settings",
+ tabs: [
+ {
+ name: "API Keys",
+ icon: Key,
+ segment: "tokens",
+ },
+ ...(flags?.integrations
+ ? [
+ {
+ name: "OAuth Apps",
+ icon: CubeSettings,
+ segment: "oauth-apps",
+ },
+ ]
+ : []),
+ ],
+ },
+
+ // Account Settings
+ {
+ group: "Account Settings",
+ tabs: [
+ {
+ name: "Notifications",
+ icon: CircleInfo,
+ segment: "notifications",
+ },
+ ],
+ },
+ ],
+ [flags],
+ );
+
+ return (
+ <SettingsLayout tabs={tabs} tabContainerClassName="top-16">
+ {children}
+ </SettingsLayout>
+ );
+}
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/layout.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/layout.tsx
index b2f1a908fa..bc2ecb0794 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/layout.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/settings/layout.tsx
@@ -1,112 +1,12 @@
-import { getFeatureFlags } from "@/lib/edge-config";
-import SettingsLayout from "@/ui/layout/settings-layout";
-import {
- CircleInfo,
- ConnectedDots,
- CubeSettings,
- Gear2,
- Gift,
- Globe,
- Key,
- Receipt2,
- ShieldCheck,
- Tag,
- Users6,
-} from "@dub/ui/src/icons";
import { ReactNode } from "react";
+import WorkspaceSettingsLayoutClient from "./layout-client";
-export const revalidate = 0;
-
-export default async function WorkspaceSettingsLayout({
+export default function WorkspaceSettingsLayout({
children,
- params,
}: {
children: ReactNode;
- params: { slug: string };
}) {
- const flags = await getFeatureFlags({ workspaceSlug: params.slug });
-
- const tabs = [
- // Workspace Settings
- {
- group: "Workspace Settings",
- tabs: [
- {
- name: "General",
- icon: Gear2,
- segment: null,
- },
- {
- name: "Domains",
- icon: Globe,
- segment: "domains",
- },
- {
- name: "Tags",
- icon: Tag,
- segment: "tags",
- },
- {
- name: "Billing",
- icon: Receipt2,
- segment: "billing",
- },
- {
- name: "People",
- icon: Users6,
- segment: "people",
- },
- ...(flags.integrations
- ? [
- {
- name: "Integrations",
- icon: ConnectedDots,
- segment: "integrations",
- },
- ]
- : []),
- {
- name: "Security",
- icon: ShieldCheck,
- segment: "security",
- },
- ...(flags.referrals
- ? [{ name: "Referrals", icon: Gift, segment: "referrals" }]
- : []),
- ],
- },
-
- // Developer Settings
- {
- group: "Developer Settings",
- tabs: [
- {
- name: "API Keys",
- icon: Key,
- segment: "tokens",
- },
- ...(flags.integrations
- ? [{ name: "OAuth Apps", icon: CubeSettings, segment: "oauth-apps" }]
- : []),
- ],
- },
-
- // Account Settings
- {
- group: "Account Settings",
- tabs: [
- {
- name: "Notifications",
- icon: CircleInfo,
- segment: "notifications",
- },
- ],
- },
- ];
-
return (
- <SettingsLayout tabs={tabs} tabContainerClassName="top-16">
- {children}
- </SettingsLayout>
+ <WorkspaceSettingsLayoutClient>{children}</WorkspaceSettingsLayoutClient>
);
}