"use client"; import { useEffect, useState } from "react"; import { useSession, useToasts } from "@/lib/store"; import type { PublicUser, UserSettings, WalletView } from "@spinza/shared"; import { AnimatePresence, motion } from "framer-motion"; import { cn } from "@/lib/utils"; import { SessionReminder } from "./session-reminder"; export function Providers({ children, session }: { children: React.ReactNode; session: { user: PublicUser; wallet: WalletView; settings: UserSettings } | null }) { const hydrate = useSession((s) => s.hydrate); // Hydrate synchronously on first render so the first paint already knows the session. useState(() => { hydrate(session); return true; }); useEffect(() => { hydrate(session); }, [session, hydrate]); return ( <> {children} ); } function Toaster() { const toasts = useToasts((s) => s.toasts); const dismiss = useToasts((s) => s.dismiss); return (
{toasts.map((t) => ( dismiss(t.id)} className={cn( "pointer-events-auto glass w-full max-w-sm rounded-md px-4 py-3 text-left shadow-2xl", t.tone === "success" && "border-success/40", t.tone === "danger" && "border-danger/40", t.tone === "credit" && "border-accent/40", )} >
{t.title}
{t.description ?
{t.description}
: null}
))}
); }