"use client" /** * Campus — the fifth home layout. * * Your App is only apps, and only their names. What distinguishes this variant * from the other four: * * 1. **School and program are workspace level.** One picker, under the * greeting and under Administrator, stamps the pair onto every school-family * product. It is the page's context line rather than a control on Your App. * A school-family app that does not license the selected program moves to * More from Exxat so Your App is only the campus that is open. Compliance * and Curriculum Mapping stay in Your App. * 2. **Every app card is the same card.** Mark and name, one size, no cover * art and no tagline. * 3. **Administrator sits in the greeting band.** It is a workspace console, * not a program and not a campus app. People and Courses sit under their * own **Workspace** section below Your App, on the same tile grid. * * One column, not a rail. Side by side, the catalogue sat at the same optical * weight as the apps the workspace owns, and capping both tracks to keep it * from outgrowing them spent the page width on margin. Stacked, reading order * carries the ranking instead: your apps, the workspace under them, then what * you do not have yet, then what changed. */ import * as React from "react" import { Link } from "react-router" import { Button } from "@/components/ui/button" import { StatusBadge } from "@/components/ui/status-badge" import { useScopeSwitcher } from "@/components/scope-switcher-menu" import { stampSchoolFamilyScope } from "@/hooks/use-active-scope" import type { Product } from "@/contexts/product-context" import { OPEN_AS_LABEL } from "@/lib/login-session" import { getProductBrand } from "@/lib/product-brand" import { orderedDirectoryLaunchSummaries, type ProductHomeCard } from "@/lib/product-home" import { productGlyph } from "@/lib/product-glyph" import { isSchoolScopedProduct, productLicensesScope, type ScopeChild, type ScopeParent, } from "@/lib/scope-switcher" import { cn } from "@/lib/utils" import { canReadDirectory } from "@/lib/workspace-role" import { useAppStore } from "@/stores/app-store" import { AdminAppCardDoor, useAdminAppScope } from "./admin-app-picker" import { BetaAccessAction } from "./product-beta-access" import { ProductMarkTile } from "./product-mark-tile" import { CampusWorkspaceChrome, campusGreetingName } from "./campus-workspace-chrome" import { ProductShelves } from "./product-shelves" import { ROW_ARROW, STRETCHED } from "./home-mosaic" import { useCampusBannerMode } from "@/hooks/use-campus-banner-mode" import { greetingForHour, HomeGreetingShelfCard, HomeVariantBody, NoProductsCard, openableDoors, useOpenAsIdentity, WhatsNewSection, type HomeBodyProps, } from "./product-home-parts" import { SectionHeading } from "./section-heading" /** The surface both app cells share, so hero and supporting stay one family. */ export const CAMPUS_CELL = "group relative flex h-full min-w-0 flex-col overflow-hidden rounded-xl border border-border bg-card transition-shadow hover:shadow-md focus-within:shadow-md" /** * How a card opens: straight through, forked into two identities, or via the * Administrator app picker. * * A hook rather than three copies of the same six lines, because the hero cell * and the supporting cell place the controls differently but must decide them * identically — a card that forks in the small cell and not in the big one * would be the same product with two different doors. */ export function useCampusDoor(card: ProductHomeCard, onOpen: (card: ProductHomeCard) => void) { const doors = openableDoors(card) const openAsIdentity = useOpenAsIdentity(onOpen) const appScope = useAdminAppScope(card) return { doors, forked: doors.length > 1, appScope, open: () => onOpen(appScope ? { ...card, href: appScope.href } : card), openAs: (role: (typeof doors)[number]) => openAsIdentity(card, role), } } type CampusDoor = ReturnType /** * The product name, as a stretched link or as plain text. * * Forked cards name themselves and hand the opening to the identity buttons. A * stretched link over the whole cell plus two doors inside it would be three * targets to one product, and the stretched one wins every click that misses a * button. */ export function CampusDoorName({ card, door }: { card: ProductHomeCard; door: CampusDoor }) { if (door.forked) return {card.label} return ( ) } /** Administrator's identity doors, when a card forks into two roles. */ export function CampusDoorActions({ card, door, className, }: { card: ProductHomeCard door: CampusDoor className?: string }) { if (!door.forked) return null return (
{door.doors.map(role => ( ))}
) } /** Stacked identity doors for catalog shelf cards. */ export function CampusDoorFooter({ card, door }: { card: ProductHomeCard; door: CampusDoor }) { return } /** * An owned app: mark and name, one shape for every card in the grid. * * No brand cover, and no tagline. An earlier pass gave every door a 64px band * of its own hue, which made the cards shout at one volume and left the reader * ranking them by colour preference; the mark carries the same identity in an * eighth of the area. The tagline went for a different reason — it is the * catalogue's sales line, and describing an app the workspace already owns is * noise. It stays in More from Exxat, where the reader has not bought yet. * * One size for all of them, deliberately. A pass that promoted the first app * to a 2×2 cell with its illustration ranked the grid, but the ranking was the * catalogue's order rather than anything the reader had asked for, and it made * the same product look like a different kind of thing to two workspaces. * * `glyphOnly` on the mark tile skips drawn SVG marks and renders solid Font * Awesome on the brand circle instead, the same language as the Workspace * section beside it. Switcher and other home variants keep the SVG set. */ export function CampusAppTile({ card, onOpen, tag, }: { card: ProductHomeCard onOpen: (card: ProductHomeCard) => void /** Entitlement or scope chip pinned to the tile corner (Catalog variant). */ tag?: React.ReactNode }) { const door = useCampusDoor(card, onOpen) const adminDoor = door.appScope && !door.forked const body = ( <> {tag ?
{tag}
: null}

{adminDoor || door.forked ? ( {card.label} ) : ( )}

{door.forked ? ( ) : ( )}
) return (
  • {adminDoor ? ( {body} ) : (
    {body}
    )}
  • ) } export type CampusCatalogTileReason = "upsell" | "off-campus" | "not-included" /** * Catalog or inactive app in the Campus cell — same border tile as Your App, * with the catalogue tagline and Learn more (Campus v3 folds More from Exxat * into Your App without the illustrated shelf). */ export function CampusCatalogTile({ card, reason, }: { card: ProductHomeCard reason: CampusCatalogTileReason }) { const learnMore = ( ) const trailingActions = card.stage === "beta" ? (
    {learnMore}
    ) : ( learnMore ) return (
  • {card.label} {reason === "off-campus" ? ( ) : null} {reason === "not-included" ? ( ) : null} {card.stage ? ( ) : null}

    {card.tagline ? (

    {card.tagline}

    ) : null}
    {trailingActions}
  • ) } /** Shared four-column grid class for Campus door sections. */ export const CAMPUS_DOOR_GRID_CLASS = "grid list-none grid-cols-1 gap-4 p-0 sm:grid-cols-2 xl:grid-cols-4" /** * The grid both door sections lay their cells on. * * Four columns, fixed. Not `ownedGridClassName`, which widens the track as * cards are added: every cell here is the same size, so a column count that * moved with the card count would make the same app a different width in two * workspaces — and would break Your App and Workspace onto different rhythms * whenever they held different numbers of cards. * * Shared rather than written twice because that is the whole claim the two * sections make: a door is a door, and the heading above it is what says * whether it opens an app or the records every app reads. An earlier pass drew * Workspace as a hairline list, which said the opposite — that its three items * were a different kind of object — and left the page with two unrelated * shapes stacked on each other. */ export function CampusDoorGrid({ cards, labelledBy, onOpen, }: { cards: ProductHomeCard[] labelledBy?: string onOpen: (card: ProductHomeCard) => void }) { return (
      {cards.map(card => ( ))}
    ) } /** * One school and program for the workspace, written onto every school-family * app so Open lands in the same campus. Reads Prism's unrestricted config so * the menu is the workspace's schools, not whichever product was last open. */ export function useWorkspaceSchoolSwitcher() { const bag = useScopeSwitcher("exxat-prism") const customProducts = useAppStore(s => s.customProducts) const stamp = React.useCallback( (parent: ScopeParent, child: ScopeChild) => { stampSchoolFamilyScope(parent, child, customProducts) }, [customProducts], ) return { ...bag, selectScope: stamp, selectParent: (parent: ScopeParent) => { const first = bag.config.childrenOf(parent)[0] if (!first) return stamp(parent, first) bag.showMain() }, selectChild: (child: ScopeChild) => { if (!bag.parent) return stamp(bag.parent, child) }, } } /** * Campus Your App is the apps that open in the picker’s school and program. * * A school-family product that does not license that pair still belongs to the * workspace, so it moves to More from Exxat rather than disappearing. There it * is a catalog row: the existing `/home/:slug` marketing page, not Open. Site-family * apps stay: they have no program to miss. Compliance and Curriculum Mapping * stay too: they are campus apps in this workspace, and Open still asks when * the picker is on a program they do not serve. When More from Exxat is hidden there * is nowhere to move them, so they stay in Your App. That is the Student with * two apps and Student with admin access sessions. */ const CAMPUS_STAYS_IN_YOUR_APP: ReadonlySet = new Set([ "exxat-compliance", "exxat-curriculum-mapping", ]) export function splitCampusOwned( owned: ProductHomeCard[], parentId: string | null, childId: string | null, moveOffCampus: boolean, ): { onCampus: ProductHomeCard[]; offCampus: ProductHomeCard[] } { if (!moveOffCampus || !parentId || !childId) { return { onCampus: owned, offCampus: [] } } const onCampus: ProductHomeCard[] = [] const offCampus: ProductHomeCard[] = [] for (const card of owned) { if ( isSchoolScopedProduct(card.product) && !CAMPUS_STAYS_IN_YOUR_APP.has(card.product) && !productLicensesScope(card.product, parentId, childId) ) { offCampus.push(card) } else { onCampus.push(card) } } return { onCampus, offCampus } } /** The console card. Homes keep it in the greeting band, not in Your App. */ export const ADMIN_PRODUCT: Product = "exxat-admin" export function campusAdministratorCard( owned: ProductHomeCard[], ): ProductHomeCard | null { return owned.find(card => card.product === ADMIN_PRODUCT) ?? null } /** Campus apps only. People and Courses live under Workspace, not Your App. */ export function campusAppCards( onCampus: ProductHomeCard[], includeRecords: boolean, ): ProductHomeCard[] { const apps = onCampus.filter(card => card.product !== ADMIN_PRODUCT) if (!includeRecords) return apps return [...apps, ...campusRecordCards(apps.map(card => card.product))] } /** * The shared record hubs as owned-app cards. * * They are already products (`exxat-people`, `exxat-courses`, * `exxat-programs`) with marks and grey tiles like Administrator. Campus keeps * them off the catalog inventory (`PRODUCTS_OFF_HOME`) so Storefront does not * sell them, then lists them under Workspace with the same Open row Your App * uses. `href` is what stops Open as: these hubs are records, not a * school-family app with two identities. Personnel Management is site-scoped * and stays off these rows. */ const CAMPUS_RECORD_PRODUCT: Record = { people: "exxat-people", courses: "exxat-courses", programs: "exxat-programs", } export function campusRecordCards(occupied: Product[] = []): ProductHomeCard[] { const taken = new Set(occupied) return orderedDirectoryLaunchSummaries().flatMap(object => { const product = CAMPUS_RECORD_PRODUCT[object.id] if (!product || taken.has(product)) return [] return [ { product, label: object.label, brandColor: getProductBrand(product)?.brandColor ?? "var(--muted-foreground)", // No count. Spotlight prints one under these two, and Campus tried it, // but a queue length on the home page is a number nobody asked for and // cannot act on from here — the hub itself states it in context. tagline: "", scopeLabel: object.scope, icon: productGlyph(product), scoped: false, entitled: true, slug: object.id, href: object.href, }, ] }) } export function CampusHome({ owned, available, onOpen, showYourApp, showMoreFromExxat, }: HomeBodyProps) { const campusScope = useWorkspaceSchoolSwitcher() const { onCampus, offCampus } = React.useMemo( () => splitCampusOwned( owned, campusScope.parent?.id ?? null, campusScope.child?.id ?? null, showMoreFromExxat, ), [owned, campusScope.parent?.id, campusScope.child?.id, showMoreFromExxat], ) const [greeting] = React.useState(() => greetingForHour(new Date().getHours())) const bannerMode = useCampusBannerMode() const administrator = campusAdministratorCard(owned) const apps = React.useMemo(() => campusAppCards(onCampus, false), [onCampus]) const workspace = React.useMemo( () => canReadDirectory() ? campusRecordCards(onCampus.map(card => card.product)) : [], [onCampus], ) const greetingBrandColor = onCampus[0]?.brandColor ?? apps[0]?.brandColor ?? getProductBrand("exxat-prism")!.brandColor const campusGreeting = ( ) return ( {bannerMode === "full" ? ( {campusGreeting} ) : ( campusGreeting )} {!showYourApp ? null : owned.length === 0 && !canReadDirectory() ? ( ) : ( <>
    {apps.length > 0 ? ( ) : null}
    {workspace.length > 0 ? (
    ) : null} )} {showMoreFromExxat ? (
    {/* The illustrated shelf every other variant sells from, rather than the hairline catalogue rows this column used as a rail. Off-campus apps lead: the workspace owns them, and their door is the same marketing page, so they read as the nearest thing to reachable. Asana template gallery IA: UI mock illustration, footer tag, corner mark. */}
    ) : null}
    ) }