2023-11-23 09:14:06 +00:00
|
|
|
import React from "react";
|
|
|
|
import { useRouter } from "next/router";
|
|
|
|
import Link from "next/link";
|
2023-11-23 15:08:50 +00:00
|
|
|
import { observer } from "mobx-react-lite";
|
|
|
|
// mobx
|
|
|
|
import { useMobxStore } from "lib/mobx/store-provider";
|
2023-11-23 09:14:06 +00:00
|
|
|
|
|
|
|
const PROFILE_LINKS: Array<{
|
2023-11-23 15:08:50 +00:00
|
|
|
key: string;
|
2023-11-23 09:14:06 +00:00
|
|
|
label: string;
|
|
|
|
href: string;
|
|
|
|
}> = [
|
|
|
|
{
|
2023-11-23 15:08:50 +00:00
|
|
|
key: "profile",
|
2023-11-23 09:14:06 +00:00
|
|
|
label: "Profile",
|
|
|
|
href: `/me/profile`,
|
|
|
|
},
|
|
|
|
{
|
2023-11-23 15:08:50 +00:00
|
|
|
key: "change-password",
|
|
|
|
label: "Change password",
|
|
|
|
href: `/me/profile/change-password`,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
key: "activity",
|
2023-11-23 09:14:06 +00:00
|
|
|
label: "Activity",
|
|
|
|
href: `/me/profile/activity`,
|
|
|
|
},
|
|
|
|
{
|
2023-11-23 15:08:50 +00:00
|
|
|
key: "preferences",
|
2023-11-23 09:14:06 +00:00
|
|
|
label: "Preferences",
|
|
|
|
href: `/me/profile/preferences`,
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
2023-11-23 15:08:50 +00:00
|
|
|
export const ProfileSettingsSidebar = observer(() => {
|
2023-11-23 09:14:06 +00:00
|
|
|
const router = useRouter();
|
2023-11-23 15:08:50 +00:00
|
|
|
const {
|
|
|
|
appConfig: { envConfig },
|
|
|
|
} = useMobxStore();
|
|
|
|
const enableEmailPassword =
|
|
|
|
envConfig &&
|
|
|
|
(envConfig?.email_password_login ||
|
|
|
|
!(
|
|
|
|
envConfig?.email_password_login ||
|
|
|
|
envConfig?.magic_login ||
|
|
|
|
envConfig?.google_client_id ||
|
|
|
|
envConfig?.github_client_id
|
|
|
|
));
|
2023-11-23 09:14:06 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<div className="flex flex-col gap-2 w-80 px-5">
|
|
|
|
<span className="text-xs text-custom-sidebar-text-400 font-semibold">My Account</span>
|
|
|
|
<div className="flex flex-col gap-1 w-full">
|
2023-11-23 15:08:50 +00:00
|
|
|
{PROFILE_LINKS.map((link) => {
|
|
|
|
if (link.key === "change-password" && !enableEmailPassword) return;
|
|
|
|
return (
|
|
|
|
<Link key={link.key} href={link.href}>
|
|
|
|
<a>
|
|
|
|
<div
|
|
|
|
className={`px-4 py-2 text-sm font-medium rounded-md ${
|
|
|
|
router.asPath === link.href
|
|
|
|
? "bg-custom-primary-100/10 text-custom-primary-100"
|
|
|
|
: "text-custom-sidebar-text-200 hover:bg-custom-sidebar-background-80 focus:bg-custom-sidebar-background-80"
|
|
|
|
}`}
|
|
|
|
>
|
|
|
|
{link.label}
|
|
|
|
</div>
|
|
|
|
</a>
|
|
|
|
</Link>
|
|
|
|
);
|
|
|
|
})}
|
2023-11-23 09:14:06 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
2023-11-23 15:08:50 +00:00
|
|
|
});
|