2023-05-11 13:10:17 +00:00
|
|
|
import { useEffect, useState } from "react";
|
|
|
|
// hooks
|
2023-05-30 13:44:35 +00:00
|
|
|
import useUserAuth from "hooks/use-user-auth";
|
2023-05-11 13:10:17 +00:00
|
|
|
// layouts
|
|
|
|
import { WorkspaceAuthorizationLayout } from "layouts/auth-layout";
|
|
|
|
import SettingsNavbar from "layouts/settings-navbar";
|
|
|
|
// components
|
|
|
|
import { CustomThemeSelector, ThemeSwitch } from "components/core";
|
|
|
|
// ui
|
|
|
|
import { Spinner } from "components/ui";
|
|
|
|
import { BreadcrumbItem, Breadcrumbs } from "components/breadcrumbs";
|
|
|
|
// types
|
|
|
|
import { ICustomTheme } from "types";
|
2023-08-10 07:33:42 +00:00
|
|
|
// mobx react lite
|
|
|
|
import { observer } from "mobx-react-lite";
|
|
|
|
// mobx store
|
|
|
|
import { useMobxStore } from "lib/mobx/store-provider";
|
2023-05-11 13:10:17 +00:00
|
|
|
|
2023-08-10 07:33:42 +00:00
|
|
|
const ProfilePreferences = observer(() => {
|
|
|
|
const { user: myProfile } = useUserAuth();
|
2023-05-11 13:10:17 +00:00
|
|
|
|
2023-08-10 07:33:42 +00:00
|
|
|
const store: any = useMobxStore();
|
2023-08-03 09:31:31 +00:00
|
|
|
|
2023-09-14 10:35:31 +00:00
|
|
|
// console.log("store", store?.theme?.theme);
|
|
|
|
// console.log("theme", theme);
|
2023-08-10 07:33:42 +00:00
|
|
|
|
|
|
|
const [customThemeSelectorOptions, setCustomThemeSelectorOptions] = useState(false);
|
|
|
|
|
|
|
|
const [preLoadedData, setPreLoadedData] = useState<ICustomTheme | null>(null);
|
2023-08-03 09:31:31 +00:00
|
|
|
|
2023-05-11 13:10:17 +00:00
|
|
|
useEffect(() => {
|
2023-08-10 07:33:42 +00:00
|
|
|
if (store?.user && store?.theme?.theme === "custom") {
|
|
|
|
const currentTheme = store?.user?.currentUserSettings?.theme;
|
|
|
|
if (currentTheme.palette)
|
2023-07-20 11:54:17 +00:00
|
|
|
setPreLoadedData({
|
2023-08-10 07:33:42 +00:00
|
|
|
background: currentTheme.background !== "" ? currentTheme.background : "#0d101b",
|
|
|
|
text: currentTheme.text !== "" ? currentTheme.text : "#c5c5c5",
|
|
|
|
primary: currentTheme.primary !== "" ? currentTheme.primary : "#3f76ff",
|
2023-07-20 11:54:17 +00:00
|
|
|
sidebarBackground:
|
2023-08-10 07:33:42 +00:00
|
|
|
currentTheme.sidebarBackground !== "" ? currentTheme.sidebarBackground : "#0d101b",
|
|
|
|
sidebarText: currentTheme.sidebarText !== "" ? currentTheme.sidebarText : "#c5c5c5",
|
2023-07-20 11:54:17 +00:00
|
|
|
darkPalette: false,
|
|
|
|
palette:
|
2023-08-10 07:33:42 +00:00
|
|
|
currentTheme.palette !== ",,,,"
|
|
|
|
? currentTheme.palette
|
2023-07-20 11:54:17 +00:00
|
|
|
: "#0d101b,#c5c5c5,#3f76ff,#0d101b,#c5c5c5",
|
2023-08-03 09:31:31 +00:00
|
|
|
theme: "custom",
|
2023-07-20 11:54:17 +00:00
|
|
|
});
|
2023-08-10 07:33:42 +00:00
|
|
|
setCustomThemeSelectorOptions((prevData) => true);
|
2023-05-11 13:10:17 +00:00
|
|
|
}
|
2023-08-10 07:33:42 +00:00
|
|
|
}, [store, store?.theme?.theme]);
|
2023-05-11 13:10:17 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<WorkspaceAuthorizationLayout
|
|
|
|
breadcrumbs={
|
|
|
|
<Breadcrumbs>
|
|
|
|
<BreadcrumbItem title="My Profile Preferences" />
|
|
|
|
</Breadcrumbs>
|
|
|
|
}
|
|
|
|
>
|
|
|
|
{myProfile ? (
|
2023-06-23 05:39:03 +00:00
|
|
|
<div className="p-8">
|
|
|
|
<div className="mb-8 space-y-6">
|
2023-05-11 13:10:17 +00:00
|
|
|
<div>
|
|
|
|
<h3 className="text-3xl font-semibold">Profile Settings</h3>
|
2023-07-10 07:17:00 +00:00
|
|
|
<p className="mt-1 text-custom-text-200">
|
2023-05-11 13:10:17 +00:00
|
|
|
This information will be visible to only you.
|
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
<SettingsNavbar profilePage />
|
|
|
|
</div>
|
|
|
|
<div className="space-y-8 sm:space-y-12">
|
|
|
|
<div className="grid grid-cols-12 gap-4 sm:gap-16">
|
|
|
|
<div className="col-span-12 sm:col-span-6">
|
2023-07-10 07:17:00 +00:00
|
|
|
<h4 className="text-lg font-semibold text-custom-text-100">Theme</h4>
|
|
|
|
<p className="text-sm text-custom-text-200">
|
2023-05-11 13:10:17 +00:00
|
|
|
Select or customize your interface color scheme.
|
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
<div className="col-span-12 sm:col-span-6">
|
|
|
|
<ThemeSwitch
|
|
|
|
setPreLoadedData={setPreLoadedData}
|
|
|
|
customThemeSelectorOptions={customThemeSelectorOptions}
|
|
|
|
setCustomThemeSelectorOptions={setCustomThemeSelectorOptions}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
{customThemeSelectorOptions && <CustomThemeSelector preLoadedData={preLoadedData} />}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
) : (
|
|
|
|
<div className="grid h-full w-full place-items-center px-4 sm:px-0">
|
|
|
|
<Spinner />
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
</WorkspaceAuthorizationLayout>
|
|
|
|
);
|
2023-08-10 07:33:42 +00:00
|
|
|
});
|
2023-05-11 13:10:17 +00:00
|
|
|
|
|
|
|
export default ProfilePreferences;
|