Files
xLog/src/components/dashboard/SettingsLayout.tsx
T
2023-02-24 22:48:43 +00:00

57 lines
1.7 KiB
TypeScript

import { useRouter } from "next/router"
import React from "react"
import { type TabItem, Tabs } from "../ui/Tabs"
import { DashboardMain } from "./DashboardMain"
import { useTranslation } from "next-i18next"
export const SettingsLayout: React.FC<{
title: string
children: React.ReactNode
type: "site" | "account"
}> = ({ title, children, type }) => {
const router = useRouter()
const { t } = useTranslation("dashboard")
const subdomain = router.query.subdomain as string
const tabItems: TabItem[] = (
type === "site"
? [
{ text: "General", href: `/dashboard/${subdomain}/settings/general` },
{
text: "Social Platforms",
href: `/dashboard/${subdomain}/settings/social-platforms`,
},
{
text: "Navigation",
href: `/dashboard/${subdomain}/settings/navigation`,
},
{ text: "Domains", href: `/dashboard/${subdomain}/settings/domains` },
{ text: "Custom CSS", href: `/dashboard/${subdomain}/settings/css` },
{
text: "Operators",
href: `/dashboard/${subdomain}/settings/operator`,
},
{
text: "Export data",
href: `https://export.crossbell.io/?handle=${subdomain}`,
},
]
: [{ text: "Profile", href: `/dashboard/${subdomain}/account/profile` }]
).map((item) => ({ ...item, active: router.asPath === item.href }))
return (
<DashboardMain>
<div className="">
<header className="mb-8">
<h2 className="text-2xl font-bold">{t(title)}</h2>
</header>
<div>
<Tabs items={tabItems} />
<div className="max-w-screen-md">{children}</div>
</div>
</div>
</DashboardMain>
)
}