import { ReactNode, useCallback } from "react"; import { FormattedMessage } from "react-intl"; import { Link, useNavigate } from "react-router-dom"; import Icon from "@/Icons/Icon"; import { LoginStore, logout } from "@/Login"; import useLogin from "@/Hooks/useLogin"; import classNames from "classnames"; import { getCurrentSubscription } from "@/Subscription"; export type SettingsMenuItems = Array<{ title: ReactNode, items: Array<{ icon: string; iconBg: string; message: ReactNode, path?: string; action?: () => void; }> }>; const SettingsIndex = () => { const login = useLogin(); const navigate = useNavigate(); const sub = getCurrentSubscription(LoginStore.allSubscriptions()); const handleLogout = useCallback(() => { logout(login.id); navigate("/"); }, [login.id, navigate]); const settingsGroups = [ { title: , items: [ { icon: "profile", iconBg: "bg-green-500", message: , path: "profile", }, { icon: "key", iconBg: "bg-amber-500", message: , path: "keys", }, { icon: "badge", iconBg: "bg-pink-500", message: , path: "handle", }, { icon: "gear", iconBg: "bg-slate-500", message: , path: "preferences", }, { icon: "wallet", iconBg: "bg-emerald-500", message: , path: "wallet", }, ...(sub ? [ { icon: "code-circle", iconBg: "bg-indigo-500", message: , path: "accounts", }, ] : []), { icon: "tool", iconBg: "bg-slate-800", message: , path: "tools" } ], }, { title: , items: [ { icon: "relay", iconBg: "bg-dark bg-opacity-20", message: , path: "relays", }, { icon: "shield-tick", iconBg: "bg-yellow-500", message: , path: "moderation", }, { icon: "bell-outline", iconBg: "bg-red-500", message: , path: "notifications", }, { icon: "link", iconBg: "bg-blue-500", message: , path: "invite", }, { icon: "hard-drive", iconBg: "bg-cyan-500", message: , path: "cache", }, ], }, { title: , items: [ { icon: "heart", iconBg: "bg-purple-500", message: , path: "/donate", }, ...(CONFIG.features.subscriptions ? [ { icon: "diamond", iconBg: "bg-violet-500", message: , path: "/subscribe/manage", }, ] : []), ...(CONFIG.features.zapPool ? [ { icon: "piggy-bank", iconBg: "bg-rose-500", message: , path: "/zap-pool", }, ] : []), ], }, { title: , items: [ { icon: "logout", iconBg: "bg-red-500", message: , action: handleLogout, }, ], }, ] as SettingsMenuItems; return }; export function SettingsMenuComponent({ menu }: { menu: SettingsMenuItems }) { return (
{menu.map((group, groupIndex) => (
{group.title}
{group.items.map(({ icon, iconBg, message, path, action }, index) => (
{message}
))}
))}
); } export default SettingsIndex;