"use client" /** * Every licensed scope in one flat list, grouped by parent. * * The list a session sees when it has not chosen a scope in this product yet. * Flat rather than the two-step the switcher menu uses (school, then program): * that menu is for changing a scope you already have, where the school is * context you keep. Here there is nothing to keep, and a school is not a * destination, so making someone open a school to discover its one program adds * a press that decides nothing. * * One press per row, no select-then-confirm. The row is the door. * * Also used inside `ProductSwitchDialog` as the blocking chooser — same school * logos and program glyphs as the utility-bar school selector, without nesting a * dropdown under the dialog overlay. */ import * as React from "react" import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar" import type { ScopeChild, ScopeConfig, ScopeParent } from "@/lib/scope-switcher" import { cn } from "@/lib/utils" export interface ScopeChoiceListProps { config: ScopeConfig onPick: (parent: ScopeParent, child: ScopeChild) => void /** The row mid-open, so the press that started it reads as work in progress. */ busyChildId?: string | null /** Parent to lead with, when the session has one it last worked in. */ suggestedParentId?: string | null className?: string } export function ScopeChoiceList({ config, onPick, busyChildId, suggestedParentId, className, }: ScopeChoiceListProps) { // The school this session last worked in leads, so a coordinator whose program // moved does not scroll past three others to find their own. const parents = React.useMemo(() => { if (!suggestedParentId) return config.parents const lead = config.parents.filter(p => p.id === suggestedParentId) return lead.length === 0 ? config.parents : [...lead, ...config.parents.filter(p => p.id !== suggestedParentId)] }, [config.parents, suggestedParentId]) return (