2025-04-12 02:57:17 +08:00
|
|
|
import DashboardLayout from "@/components/layout/DashboardLayout";
|
2025-04-12 08:04:40 +08:00
|
|
|
import { createClient } from "@/lib/supabase/server";
|
|
|
|
import { redirect } from "next/navigation";
|
2025-04-12 02:57:17 +08:00
|
|
|
|
2025-04-13 00:37:45 +08:00
|
|
|
interface PersonalAccountLayoutProps {
|
2025-04-12 08:04:40 +08:00
|
|
|
children: React.ReactNode;
|
2025-04-13 00:37:45 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
export default async function PersonalAccountLayout({
|
|
|
|
children,
|
|
|
|
}: PersonalAccountLayoutProps) {
|
2025-04-12 08:04:40 +08:00
|
|
|
// Get the current user via Supabase
|
|
|
|
const supabaseClient = createClient();
|
|
|
|
const { data: { user } } = await supabaseClient.auth.getUser();
|
|
|
|
|
|
|
|
// Redirect if not logged in
|
|
|
|
if (!user) {
|
|
|
|
redirect("/login");
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get the personal account details
|
|
|
|
const { data: personalAccount } = await supabaseClient.rpc('get_personal_account');
|
2025-04-12 02:57:17 +08:00
|
|
|
|
2025-04-12 08:04:40 +08:00
|
|
|
const navigation = [
|
2025-04-13 00:37:45 +08:00
|
|
|
{ name: "Dashboard", href: "/dashboard" },
|
|
|
|
{ name: "Agents", href: "/dashboard/agents" },
|
|
|
|
{ name: "Settings", href: "/dashboard/settings" },
|
2025-04-12 08:04:40 +08:00
|
|
|
];
|
2025-04-12 02:57:17 +08:00
|
|
|
|
2025-04-12 08:04:40 +08:00
|
|
|
return (
|
|
|
|
<DashboardLayout
|
|
|
|
navigation={navigation}
|
|
|
|
accountId={personalAccount?.account_id || user.id}
|
2025-04-13 00:37:45 +08:00
|
|
|
userName={user?.user_metadata?.name || user.email?.split('@')[0] || 'User'}
|
|
|
|
userEmail={user.email}
|
|
|
|
rightPanelTitle="Suna's Computer"
|
2025-04-12 08:04:40 +08:00
|
|
|
>
|
|
|
|
{children}
|
|
|
|
</DashboardLayout>
|
|
|
|
);
|
2025-04-12 02:57:17 +08:00
|
|
|
}
|