import SettingsLayout from "@/layouts/SettingsLayout"; import { useState, useEffect } from "react"; import useAccountStore from "@/store/account"; import { AccountSettings } from "@/types/global"; import { toast } from "react-hot-toast"; import React from "react"; import useLocalSettingsStore from "@/store/localSettings"; export default function Appearance() { const { updateSettings } = useLocalSettingsStore(); const submit = async () => { setSubmitLoader(true); const load = toast.loading("Applying..."); const response = await updateAccount({ ...user, }); toast.dismiss(load); if (response.ok) { toast.success("Settings Applied!"); } else toast.error(response.data as string); setSubmitLoader(false); }; const [submitLoader, setSubmitLoader] = useState(false); const { account, updateAccount } = useAccountStore(); const [user, setUser] = useState( !objectIsEmpty(account) ? account : ({ // @ts-ignore id: null, name: "", username: "", email: "", emailVerified: null, blurredFavicons: null, image: "", isPrivate: true, // @ts-ignore createdAt: null, whitelistedUsers: [], } as unknown as AccountSettings) ); function objectIsEmpty(obj: object) { return Object.keys(obj).length === 0; } useEffect(() => { if (!objectIsEmpty(account)) setUser({ ...account }); }, [account]); return (

Appearance

Select Theme

updateSettings({ theme: "dark" })} >

Dark

{/*
*/}
updateSettings({ theme: "light" })} >

Light

{/*
*/}
{/* */}
); }