import React, { useState } from "react"; import { NavLink, Outlet, useNavigate } from "react-router"; import AppHeader from "src/components/AppHeader"; import { useInfo } from "src/hooks/useInfo"; import { ArrowRightLeftIcon, BoxIcon, BugIcon, CloudBackupIcon, CodeIcon, FingerprintIcon, InfoIcon, KeyRoundIcon, type LucideIcon, PowerIcon, SlidersHorizontalIcon, UserIcon, } from "lucide-react"; import { toast } from "sonner"; import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, AlertDialogTrigger, } from "src/components/ui/alert-dialog"; import { LoadingButton } from "src/components/ui/custom/loading-button"; import { Separator } from "src/components/ui/separator"; import { cn } from "src/lib/utils"; import { request } from "src/utils/request"; export default function SettingsLayout() { const { data: info, mutate: refetchInfo, hasMnemonic, hasNodeBackup, } = useInfo(); const navigate = useNavigate(); const [shuttingDown, setShuttingDown] = useState(false); const shutdown = React.useCallback(async () => { setShuttingDown(true); try { await request("/api/stop", { method: "POST", headers: { "Content-Type": "application/json", }, }); await refetchInfo(); setShuttingDown(false); navigate("/", { replace: true }); toast("Your node has been turned off."); } catch (error) { console.error(error); toast.error("Failed to shutdown node", { description: "" + error, }); } }, [navigate, refetchInfo]); return ( <>
{info?.version}
{!shuttingDown && } Do you want to turn off your Alby Hub? This will turn off your Alby Hub and make your node offline. You won't be able to send or receive bitcoin until you unlock it. Cancel Continue } />
); } const NavGroup = ({ label, children, }: { label: string; children: React.ReactNode; }) => (
{label} {children}
); export const MenuItem = ({ to, icon: Icon, children, }: { to: string; icon?: LucideIcon; children: React.ReactNode | string; }) => ( cn( "relative flex items-center gap-2 whitespace-nowrap rounded-md px-3 py-2 text-sm transition-colors text-foreground", isActive ? "bg-muted font-medium" : "hover:bg-muted/50" ) } > {() => ( <> {Icon && } {children} )} );