make one header component for the dashboard
This commit is contained in:
parent
b72c4bc788
commit
1501e6dea4
@ -1,4 +1,9 @@
|
|||||||
import { ReactElement } from "react";
|
import { ReactElement } from "react";
|
||||||
|
import DashboardHeader from "@/components/dashboard/dashboard-header";
|
||||||
|
|
||||||
const StatusPagesPage = (): ReactElement => <main>BOB?</main>;
|
const StatusPagesPage = (): ReactElement => (
|
||||||
|
<main className="flex flex-col gap-3">
|
||||||
|
<DashboardHeader title="Status Pages" />
|
||||||
|
</main>
|
||||||
|
);
|
||||||
export default StatusPagesPage;
|
export default StatusPagesPage;
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
import { ReactElement } from "react";
|
import { ReactElement } from "react";
|
||||||
import { Separator } from "@/components/ui/separator";
|
import { Separator } from "@/components/ui/separator";
|
||||||
import UserSettingsHeader from "@/components/dashboard/user/user-settings-header";
|
import DashboardHeader from "@/components/dashboard/dashboard-header";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The user billing page.
|
* The user billing page.
|
||||||
@ -11,7 +11,7 @@ import UserSettingsHeader from "@/components/dashboard/user/user-settings-header
|
|||||||
*/
|
*/
|
||||||
const UserBillingPage = (): ReactElement => (
|
const UserBillingPage = (): ReactElement => (
|
||||||
<main className="w-[47rem] flex flex-col gap-5">
|
<main className="w-[47rem] flex flex-col gap-5">
|
||||||
<UserSettingsHeader title="Billing" />
|
<DashboardHeader title="Billing" />
|
||||||
|
|
||||||
{/* Content */}
|
{/* Content */}
|
||||||
<div className="flex flex-col gap-5">
|
<div className="flex flex-col gap-5">
|
||||||
|
@ -6,7 +6,7 @@ import AvatarSetting from "@/components/dashboard/user/profile/avatar-setting";
|
|||||||
import UsernameSetting from "@/components/dashboard/user/profile/username-setting";
|
import UsernameSetting from "@/components/dashboard/user/profile/username-setting";
|
||||||
import EmailSetting from "@/components/dashboard/user/profile/email-setting";
|
import EmailSetting from "@/components/dashboard/user/profile/email-setting";
|
||||||
import TierSetting from "@/components/dashboard/user/profile/tier-setting";
|
import TierSetting from "@/components/dashboard/user/profile/tier-setting";
|
||||||
import UserSettingsHeader from "@/components/dashboard/user/user-settings-header";
|
import DashboardHeader from "@/components/dashboard/dashboard-header";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The user profile page.
|
* The user profile page.
|
||||||
@ -15,7 +15,7 @@ import UserSettingsHeader from "@/components/dashboard/user/user-settings-header
|
|||||||
*/
|
*/
|
||||||
const UserProfilePage = (): ReactElement => (
|
const UserProfilePage = (): ReactElement => (
|
||||||
<main className="w-[47rem] flex flex-col gap-5">
|
<main className="w-[47rem] flex flex-col gap-5">
|
||||||
<UserSettingsHeader title="My Profile" />
|
<DashboardHeader title="My Profile" />
|
||||||
|
|
||||||
{/* Content */}
|
{/* Content */}
|
||||||
<div className="flex flex-col gap-5">
|
<div className="flex flex-col gap-5">
|
||||||
|
@ -3,8 +3,8 @@
|
|||||||
import { ReactElement } from "react";
|
import { ReactElement } from "react";
|
||||||
import { Separator } from "@/components/ui/separator";
|
import { Separator } from "@/components/ui/separator";
|
||||||
import TFASetting from "@/components/dashboard/user/settings/tfa/tfa-setting";
|
import TFASetting from "@/components/dashboard/user/settings/tfa/tfa-setting";
|
||||||
import UserSettingsHeader from "@/components/dashboard/user/user-settings-header";
|
|
||||||
import DevicesSetting from "@/components/dashboard/user/settings/device/devices-setting";
|
import DevicesSetting from "@/components/dashboard/user/settings/device/devices-setting";
|
||||||
|
import DashboardHeader from "@/components/dashboard/dashboard-header";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The user settings page.
|
* The user settings page.
|
||||||
@ -13,7 +13,7 @@ import DevicesSetting from "@/components/dashboard/user/settings/device/devices-
|
|||||||
*/
|
*/
|
||||||
const UserSettingsPage = (): ReactElement => (
|
const UserSettingsPage = (): ReactElement => (
|
||||||
<main className="w-[47rem] flex flex-col gap-5">
|
<main className="w-[47rem] flex flex-col gap-5">
|
||||||
<UserSettingsHeader title="Settings" />
|
<DashboardHeader title="Settings" />
|
||||||
|
|
||||||
{/* Content */}
|
{/* Content */}
|
||||||
<div className="flex flex-col gap-5">
|
<div className="flex flex-col gap-5">
|
||||||
|
@ -12,6 +12,19 @@ import {
|
|||||||
BreadcrumbPage,
|
BreadcrumbPage,
|
||||||
BreadcrumbSeparator,
|
BreadcrumbSeparator,
|
||||||
} from "@/components/ui/breadcrumb";
|
} from "@/components/ui/breadcrumb";
|
||||||
|
import { Organization } from "@/app/types/org/organization";
|
||||||
|
import { useOrganizationContext } from "@/app/provider/organization-provider";
|
||||||
|
import { OrganizationState } from "@/app/store/organization-store";
|
||||||
|
import { usePathname } from "next/navigation";
|
||||||
|
import {
|
||||||
|
DropdownMenu,
|
||||||
|
DropdownMenuContent,
|
||||||
|
DropdownMenuTrigger,
|
||||||
|
} from "@/components/ui/dropdown-menu";
|
||||||
|
import { ChevronDownIcon } from "@heroicons/react/24/outline";
|
||||||
|
import UserMenuLinks from "@/components/dashboard/sidebar/user-menu/user-menu-links";
|
||||||
|
import OrganizationLogo from "@/components/org/organization-logo";
|
||||||
|
import UserAvatar from "@/components/user/user-avatar";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The props for this header.
|
* The props for this header.
|
||||||
@ -21,11 +34,6 @@ type DashboardHeaderProps = {
|
|||||||
* The title of this header.
|
* The title of this header.
|
||||||
*/
|
*/
|
||||||
title: string;
|
title: string;
|
||||||
|
|
||||||
/**
|
|
||||||
* The breadcrumb of this header.
|
|
||||||
*/
|
|
||||||
breadcrumb: ReactElement;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -35,13 +43,15 @@ type DashboardHeaderProps = {
|
|||||||
* @param props the header props
|
* @param props the header props
|
||||||
* @return the header jsx
|
* @return the header jsx
|
||||||
*/
|
*/
|
||||||
const DashboardHeader = ({
|
const DashboardHeader = ({ title }: DashboardHeaderProps): ReactElement => {
|
||||||
title,
|
const path: string = usePathname();
|
||||||
breadcrumb,
|
|
||||||
}: DashboardHeaderProps): ReactElement => {
|
|
||||||
const user: User | undefined = useUserContext(
|
const user: User | undefined = useUserContext(
|
||||||
(state: UserState) => state.user
|
(state: UserState) => state.user
|
||||||
);
|
);
|
||||||
|
const selectedOrganization: Organization | undefined =
|
||||||
|
useOrganizationContext((state: OrganizationState) => state.selected);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col gap-1.5 select-none">
|
<div className="flex flex-col gap-1.5 select-none">
|
||||||
<h1 className="text-2xl font-bold">{title}</h1>
|
<h1 className="text-2xl font-bold">{title}</h1>
|
||||||
@ -54,7 +64,13 @@ const DashboardHeader = ({
|
|||||||
</BreadcrumbLink>
|
</BreadcrumbLink>
|
||||||
</BreadcrumbItem>
|
</BreadcrumbItem>
|
||||||
<BreadcrumbSeparator />
|
<BreadcrumbSeparator />
|
||||||
{breadcrumb}
|
{path.startsWith("/dashboard/org") ? (
|
||||||
|
<OrganizationBreadcrumb
|
||||||
|
organization={selectedOrganization as Organization}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<UserBreadcrumb user={user as User} />
|
||||||
|
)}
|
||||||
<BreadcrumbSeparator />
|
<BreadcrumbSeparator />
|
||||||
<BreadcrumbItem>
|
<BreadcrumbItem>
|
||||||
<BreadcrumbPage>{title}</BreadcrumbPage>
|
<BreadcrumbPage>{title}</BreadcrumbPage>
|
||||||
@ -64,4 +80,31 @@ const DashboardHeader = ({
|
|||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const UserBreadcrumb = ({ user }: { user: User }): ReactElement => (
|
||||||
|
<BreadcrumbItem>
|
||||||
|
<DropdownMenu>
|
||||||
|
<DropdownMenuTrigger className="flex gap-1.5 items-center">
|
||||||
|
<UserAvatar className="translate-y-0.5" user={user} size="sm" />
|
||||||
|
<span>@{user?.username}</span>
|
||||||
|
<ChevronDownIcon className="w-3 h-3" />
|
||||||
|
</DropdownMenuTrigger>
|
||||||
|
<DropdownMenuContent align="start">
|
||||||
|
<UserMenuLinks />
|
||||||
|
</DropdownMenuContent>
|
||||||
|
</DropdownMenu>
|
||||||
|
</BreadcrumbItem>
|
||||||
|
);
|
||||||
|
|
||||||
|
const OrganizationBreadcrumb = ({
|
||||||
|
organization,
|
||||||
|
}: {
|
||||||
|
organization: Organization;
|
||||||
|
}): ReactElement => (
|
||||||
|
<BreadcrumbItem className="gap-3">
|
||||||
|
<OrganizationLogo organization={organization} size="sm" />
|
||||||
|
<span>{organization.name}</span>
|
||||||
|
</BreadcrumbItem>
|
||||||
|
);
|
||||||
|
|
||||||
export default DashboardHeader;
|
export default DashboardHeader;
|
||||||
|
@ -1,64 +0,0 @@
|
|||||||
import { ReactElement } from "react";
|
|
||||||
import { User } from "@/app/types/user/user";
|
|
||||||
import { useUserContext } from "@/app/provider/user-provider";
|
|
||||||
import { UserState } from "@/app/store/user-store";
|
|
||||||
import {
|
|
||||||
Breadcrumb,
|
|
||||||
BreadcrumbItem,
|
|
||||||
BreadcrumbLink,
|
|
||||||
BreadcrumbList,
|
|
||||||
BreadcrumbPage,
|
|
||||||
BreadcrumbSeparator,
|
|
||||||
} from "@/components/ui/breadcrumb";
|
|
||||||
import {
|
|
||||||
DropdownMenu,
|
|
||||||
DropdownMenuContent,
|
|
||||||
DropdownMenuTrigger,
|
|
||||||
} from "@/components/ui/dropdown-menu";
|
|
||||||
import { ChevronDownIcon } from "@heroicons/react/24/outline";
|
|
||||||
import UserMenuLinks from "@/components/dashboard/sidebar/user-menu/user-menu-links";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The header to display
|
|
||||||
* on user settings pages.
|
|
||||||
*
|
|
||||||
* @param title the title of this header
|
|
||||||
* @return the header jsx
|
|
||||||
*/
|
|
||||||
const UserSettingsHeader = ({ title }: { title: string }): ReactElement => {
|
|
||||||
const user: User | undefined = useUserContext(
|
|
||||||
(state: UserState) => state.user
|
|
||||||
);
|
|
||||||
return (
|
|
||||||
<div className="flex flex-col gap-1.5 select-none">
|
|
||||||
<h1 className="text-2xl font-bold">{title}</h1>
|
|
||||||
|
|
||||||
<Breadcrumb>
|
|
||||||
<BreadcrumbList>
|
|
||||||
<BreadcrumbItem>
|
|
||||||
<BreadcrumbLink href="/dashboard" draggable={false}>
|
|
||||||
Dashboard
|
|
||||||
</BreadcrumbLink>
|
|
||||||
</BreadcrumbItem>
|
|
||||||
<BreadcrumbSeparator />
|
|
||||||
<BreadcrumbItem>
|
|
||||||
<DropdownMenu>
|
|
||||||
<DropdownMenuTrigger className="flex gap-1.5 items-center">
|
|
||||||
@{user?.username}
|
|
||||||
<ChevronDownIcon className="w-3 h-3" />
|
|
||||||
</DropdownMenuTrigger>
|
|
||||||
<DropdownMenuContent align="start">
|
|
||||||
<UserMenuLinks />
|
|
||||||
</DropdownMenuContent>
|
|
||||||
</DropdownMenu>
|
|
||||||
</BreadcrumbItem>
|
|
||||||
<BreadcrumbSeparator />
|
|
||||||
<BreadcrumbItem>
|
|
||||||
<BreadcrumbPage>{title}</BreadcrumbPage>
|
|
||||||
</BreadcrumbItem>
|
|
||||||
</BreadcrumbList>
|
|
||||||
</Breadcrumb>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
export default UserSettingsHeader;
|
|
Loading…
x
Reference in New Issue
Block a user