// screens-saved.jsx — favourites: classes + teachers (with quick next-session) const { findClass, findCoach, findFriend, minutesUntil, fmtCountdown, DAYS_SHORT, DATES_THIS_WEEK } = window.NADI_HELPERS; function SavedScreen({ user, openClassSheet, toggleSavedClass, toggleSavedCoach, setTab, openFindFriends, openFriendProfile, unfollowFriend }) { const [seg, setSeg] = useState("classes"); // "classes" | "teachers" | "friends" return (
{/* Segmented control */}
{[ ["classes", "Classes", user.savedClasses.length], ["teachers", "Teachers", user.savedCoaches.length], ["friends", "Friends", user.following.length], ].map(([id, label, n]) => ( ))}
{seg === "classes" && } {seg === "teachers" && } {seg === "friends" && }
); } // ── Friends list ──────────────────────────────────────────────── function SavedFriendsList({ user, openFindFriends, openFriendProfile }) { const friends = user.following.map((id) => findFriend(id)).filter(Boolean); const pending = user.pendingFollowers.map((id) => findFriend(id)).filter(Boolean); return (
{/* Find friends CTA */} {/* Pending requests */} {pending.length > 0 && (
requests · {pending.length} waiting on you
{pending.map((p, i) => (
{p.name}
{p.mutual} mutual · sent {p.since}
))}
)} {/* Following list */} {friends.length > 0 && (
following · {friends.length} your circle
{friends.map((f) => { // Find a class this friend is going to (next one) const sharedNext = window.NADI.SCHEDULE .filter((s) => s.friends.includes(f.id)) .sort((a, b) => window.NADI_HELPERS.minutesUntil(a) - window.NADI_HELPERS.minutesUntil(b))[0]; return ( ); })}
)} {friends.length === 0 && pending.length === 0 && ( )}
); } function SavedClassList({ user, openClassSheet, toggleSavedClass, setTab }) { if (user.savedClasses.length === 0) return setTab("book")} />; return (
{user.savedClasses.map((id) => { const c = findClass(id); const nextSess = window.NADI.SCHEDULE .filter((s) => s.classId === id && minutesUntil(s) > 0) .sort((a, b) => minutesUntil(a) - minutesUntil(b))[0]; const accent = c.color === "primary" ? "var(--primary)" : c.color === "accent" ? "var(--accent)" : "var(--muted)"; return (
{c.duration} min · {c.level.toLowerCase()}

{c.name}

{c.tagline}.

{nextSess ? ( ) : (
not scheduled this week
)}
); })}
); } function SavedCoachList({ user, openClassSheet, toggleSavedCoach, setTab }) { if (user.savedCoaches.length === 0) return setTab("book")} />; return (
{user.savedCoaches.map((id) => { const co = findCoach(id); const nextSess = window.NADI.SCHEDULE .filter((s) => s.coachId === id && minutesUntil(s) > 0) .sort((a, b) => minutesUntil(a) - minutesUntil(b))[0]; return (
{co.yrs} yrs teaching

{co.name}

{co.title.toLowerCase()}

{co.bio}

{nextSess && ( )}
); })}
); } function EmptyState({ title, body, cta, onCta }) { return (

{title}

{body}

{cta &&
}
); } Object.assign(window, { SavedScreen, EmptyState, SavedFriendsList });