Skip to content

Open source CapCut alternative.

TypeScript

fix(site): let settings pages render for validation

David Le5c4dab7518ac
diff --git a/site/src/app/cut/app/(home)/settings/layout.tsx b/site/src/app/cut/app/(home)/settings/layout.tsx
index 925efcd2..f1ceaaaa 100644
--- a/site/src/app/cut/app/(home)/settings/layout.tsx
+++ b/site/src/app/cut/app/(home)/settings/layout.tsx
@@ -2,7 +2,6 @@ import type { Metadata } from "next";
import type { ReactNode } from "react";
import { SettingsHeader } from "@/app/cut/app/(home)/settings/SettingsHeader";
-import { SettingsGuard } from "@/cut/components/SettingsGuard";
export const metadata: Metadata = {
description: "Manage your Donkey Cut subscription, credits, and usage.",
@@ -15,18 +14,17 @@ export const metadata: Metadata = {
// their behavior: billing overflows and scrolls the pane, usage fills the
// remaining height exactly (flex-1 + h-full chain) and scrolls only its table
// body. p-px gives the cards' outside ring a pixel of room so the scroll
-// container can't clip their top border.
+// container can't clip their top border. Each page holds its own
+// SettingsGuard, so the page segment renders and Next can validate it.
export default function CutSettingsLayout({ children }: { children: ReactNode }) {
return (
- <SettingsGuard>
- <div className="flex h-full flex-col overflow-y-auto">
- <SettingsHeader />
- <div className="min-h-0 flex-1">
- <div className="mx-auto h-full w-full max-w-6xl px-10">
- <div className="h-full p-px">{children}</div>
- </div>
+ <div className="flex h-full flex-col overflow-y-auto">
+ <SettingsHeader />
+ <div className="min-h-0 flex-1">
+ <div className="mx-auto h-full w-full max-w-6xl px-10">
+ <div className="h-full p-px">{children}</div>
</div>
</div>
- </SettingsGuard>
+ </div>
);
}
diff --git a/site/src/app/cut/app/(home)/settings/page.tsx b/site/src/app/cut/app/(home)/settings/page.tsx
index 812e9d51..881d692d 100644
--- a/site/src/app/cut/app/(home)/settings/page.tsx
+++ b/site/src/app/cut/app/(home)/settings/page.tsx
@@ -2,14 +2,17 @@
import { CreditsCard } from "@/app/cut/app/(home)/settings/_components/CreditsCard";
import { ProCard } from "@/app/cut/app/(home)/settings/_components/ProCard";
+import { SettingsGuard } from "@/cut/components/SettingsGuard";
// Cut's billing page: the Pro subscription that carries the monthly AI
// credits, plus the credit balance and top-ups.
export default function CutBillingPage() {
return (
- <div className="max-w-2xl space-y-6 pb-9">
- <ProCard />
- <CreditsCard />
- </div>
+ <SettingsGuard>
+ <div className="max-w-2xl space-y-6 pb-9">
+ <ProCard />
+ <CreditsCard />
+ </div>
+ </SettingsGuard>
);
}
diff --git a/site/src/app/cut/app/(home)/settings/profile/page.tsx b/site/src/app/cut/app/(home)/settings/profile/page.tsx
index edf160c5..f3ebc865 100644
--- a/site/src/app/cut/app/(home)/settings/profile/page.tsx
+++ b/site/src/app/cut/app/(home)/settings/profile/page.tsx
@@ -13,6 +13,7 @@ import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
import { Skeleton } from "@/components/ui/skeleton";
+import { SettingsGuard } from "@/cut/components/SettingsGuard";
import { UserAvatar } from "@/cut/components/UserAvatar";
import {
useAccountProfile,
@@ -24,6 +25,14 @@ import {
// you can change. The display name is the product's; the Google account keeps
// the name and email it signed in with.
export default function CutProfilePage() {
+ return (
+ <SettingsGuard>
+ <ProfileView />
+ </SettingsGuard>
+ );
+}
+
+function ProfileView() {
const { data: profile, isPending, isError } = useAccountProfile();
const update = useUpdateDisplayName();
// Null means "not edited yet", so the field follows the saved value until
diff --git a/site/src/app/cut/app/(home)/settings/usage/page.tsx b/site/src/app/cut/app/(home)/settings/usage/page.tsx
index 098c5fd0..22024129 100644
--- a/site/src/app/cut/app/(home)/settings/usage/page.tsx
+++ b/site/src/app/cut/app/(home)/settings/usage/page.tsx
@@ -1,7 +1,12 @@
"use client";
import { UsageHistoryCard } from "@/components/UsageHistoryCard";
+import { SettingsGuard } from "@/cut/components/SettingsGuard";
export default function CutUsagePage() {
- return <UsageHistoryCard />;
+ return (
+ <SettingsGuard>
+ <UsageHistoryCard />
+ </SettingsGuard>
+ );
}
diff --git a/site/src/cut/components/SettingsGuard.tsx b/site/src/cut/components/SettingsGuard.tsx
index 90c724ca..4c0b3e3a 100644
--- a/site/src/cut/components/SettingsGuard.tsx
+++ b/site/src/cut/components/SettingsGuard.tsx
@@ -5,8 +5,8 @@ import type { ReactNode } from "react";
import { Skeleton } from "@/components/ui/skeleton";
import { useEngineUser } from "@/cut/lib/backend/hooks";
-// Account guard for Cut's billing and usage pages: they read the account, so
-// they wait for it.
+// Account guard for Cut's settings pages: they read the account, so they
+// wait for it.
//
// It waits on the app's account binding rather than on the session object.
// The auth client re-reads the session on every window focus and answers null
@@ -18,9 +18,8 @@ export function SettingsGuard({ children }: { children: ReactNode }) {
if (!user) {
return (
- <div className="mx-auto max-w-3xl px-8 py-10">
- <Skeleton className="h-8 w-48" />
- <Skeleton className="mt-6 h-40 w-full" />
+ <div className="max-w-2xl">
+ <Skeleton className="h-40 w-full rounded-xl" />
</div>
);
}