@nukleus-sports/page-shells 0.1.3 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -43,6 +43,7 @@ function MarketingDealsPanel({ adapter, className }) {
43
43
  currentEmptyMessage,
44
44
  completedEmptyMessage,
45
45
  gatedEmptyState,
46
+ completedYearFilter,
46
47
  getCollabMembership,
47
48
  getCollabHref,
48
49
  getOnCollabClick,
@@ -50,7 +51,9 @@ function MarketingDealsPanel({ adapter, className }) {
50
51
  onDeleteDeal,
51
52
  onOpenDocument,
52
53
  clientImageUrl,
53
- resolveImageUrl
54
+ resolveImageUrl,
55
+ getProjectDealAsideFooter,
56
+ getManualDealAsideFooter
54
57
  } = adapter;
55
58
  const [previewDeal, setPreviewDeal] = (0, import_react.useState)(null);
56
59
  const resolvedCompletedEmptyMessage = typeof completedEmptyMessage === "function" ? completedEmptyMessage(currentProjectDeals.length > 0) : completedEmptyMessage;
@@ -92,6 +95,17 @@ function MarketingDealsPanel({ adapter, className }) {
92
95
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "body-text text-text-primary text-center", children: errorMessage }),
93
96
  onRetry && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ui_web.Button, { variant: "secondary", size: "form", onClick: onRetry, children: "Retry" })
94
97
  ] }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
98
+ activeTab === "completed" && completedYearFilter && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
99
+ import_ui_web.Select,
100
+ {
101
+ value: completedYearFilter.value,
102
+ onValueChange: completedYearFilter.onChange,
103
+ children: [
104
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ui_web.SelectTrigger, { className: "w-[140px]", "aria-label": "Filter completed deals by year", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ui_web.SelectValue, {}) }),
105
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ui_web.SelectContent, { children: completedYearFilter.options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ui_web.SelectItem, { value: option.value, children: option.label }, option.value)) })
106
+ ]
107
+ }
108
+ ),
95
109
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "hidden sm:flex items-center bg-greys-grey-table-h rounded-t-[10px] py-0 px-3 gap-3 h-[33px]", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "label-xs-table text-text-primary font-ss02", children: "Deals" }) }),
96
110
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ui_web.TabsContent, { value: "current", className: "mt-0", children: gatedEmptyState ? gatedEmptyState : currentProjectDeals.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "flex flex-col gap-3 sm:gap-0", children: currentProjectDeals.map((deal) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
97
111
  import_marketing.ProjectDealCard,
@@ -101,7 +115,8 @@ function MarketingDealsPanel({ adapter, className }) {
101
115
  collabMembership: getCollabMembership(deal.project_id),
102
116
  collabHref: getCollabHref(deal.project_id),
103
117
  onCollabClick: getOnCollabClick?.(deal.project_id),
104
- resolveImageUrl
118
+ resolveImageUrl,
119
+ asideFooter: getProjectDealAsideFooter?.(deal)
105
120
  },
106
121
  deal.project_id
107
122
  )) }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_marketing.DealEmptyState, { message: currentEmptyMessage }) }),
@@ -114,7 +129,8 @@ function MarketingDealsPanel({ adapter, className }) {
114
129
  collabMembership: getCollabMembership(deal.project_id),
115
130
  collabHref: getCollabHref(deal.project_id),
116
131
  onCollabClick: getOnCollabClick?.(deal.project_id),
117
- resolveImageUrl
132
+ resolveImageUrl,
133
+ asideFooter: getProjectDealAsideFooter?.(deal)
118
134
  },
119
135
  deal.project_id
120
136
  )),
@@ -126,7 +142,8 @@ function MarketingDealsPanel({ adapter, className }) {
126
142
  onEdit: onEditDeal,
127
143
  onDelete: onDeleteDeal,
128
144
  onOpenDocument,
129
- resolveImageUrl
145
+ resolveImageUrl,
146
+ asideFooter: getManualDealAsideFooter?.(deal)
130
147
  },
131
148
  deal.id
132
149
  ))
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/marketing/index.ts","../src/marketing/marketing-deals-panel.tsx"],"sourcesContent":["export {\n MarketingDealsPanel,\n type MarketingDealsAdapter,\n type MarketingDealsPanelProps,\n} from \"./marketing-deals-panel\";\n","import { useState, type MouseEvent, type ReactNode } from \"react\";\n\nimport {\n Button,\n Skeleton,\n Tabs,\n TabsContent,\n TabsList,\n TabsTrigger,\n cn,\n} from \"@nukleus-sports/ui-web\";\nimport {\n DealEmptyState,\n ManualDealCard,\n ManualDealPreviewDialog,\n ProjectDealCard,\n type EntityImageResolver,\n type ManualDeal,\n type ManualDealDocumentRef,\n type ProjectCollabMembership,\n type ProjectDeal,\n} from \"@nukleus-sports/ui-patterns/marketing\";\n\n/**\n * Reconciled from both apps' real current pages:\n * - `nukleus-app`'s `MarketingDealsTab.tsx` (`ClientMarketingTab`)\n * - `nukleus-clientapp`'s `pages/Marketing.tsx` + `hooks/useMarketing.ts`\n *\n * Both pages share one identical skeleton: a \"Current Deals\"/\"Completed\" tab\n * pair, a \"Deals\" label bar, a `ProjectDealCard` list per tab (`Completed`\n * also appends `ManualDealCard`s), matching empty states, and a shared\n * `ManualDealPreviewDialog`. That skeleton is this component's entire scope.\n *\n * ## Deliberately NOT in this shell (stays app-local, per CLAUDE.md's\n * page-shells rule and the decisions already made for this feature)\n * - The page header/title and the \"Record Past Deal\"/\"New Marketing Deal\"\n * buttons — `nukleus-app`-only chrome with no clientapp equivalent.\n * - `MarketingDealForm` (the CRUD create/edit form) and `DeleteDialog` —\n * `nukleus-app`-only, no clientapp read-only counterpart to reconcile\n * against, same reasoning as `MarketingOverviewPanel`/`Card` (also kept\n * app-local, rendered alongside this shell, not inside it).\n * - The top-level access gate (`nukleus-app`'s `marketingPermission ===\n * \"No Access\"` → `RestrictedAccessCard`; `clientapp`'s `!isAgencyLinked` →\n * `AgencyLinkBanner`). Both are a one-time \"should the deals experience\n * render at all\" decision made from each app's own permission shape\n * (`@nukleus-sports/core`'s `MarketingPermission` union) *before* this\n * shell ever mounts — not something this component re-derives.\n * - Project-membership resolution for the \"Collab\" link gate (`@nukleus-sports/\n * ui-patterns`' `ProjectDealCard` already enforces this structurally via its\n * required `collabMembership` prop) — the actual membership check is an\n * app-level query, surfaced here through `getCollabMembership`.\n *\n * ## Genuine differences reconciled (not formatting)\n * - Client-status gating (`nukleus-app`'s `isGated`, e.g. a \"Prospect\" client\n * can't have deals yet): `clientapp` has no such concept. Modeled as an\n * optional `gatedEmptyState` — when supplied, it replaces the Current tab's\n * content and the Completed tab is disabled, exactly matching `nukleus-app`'s\n * structure; omit it and both tabs behave normally (`clientapp`'s case).\n * - Loading skeleton: `clientapp` shows one before the tabs ever render;\n * `nukleus-app` has none (deals just populate once the query resolves).\n * Kept as an additive, opt-in `isLoading` prop — a loading affordance isn't\n * an agency-vs-client distinction, so both can use it.\n * - \"Deals\" label bar visibility on mobile: `nukleus-app` hides it below `sm`\n * (`hidden sm:flex`), `clientapp` always shows it. Kept `nukleus-app`'s\n * responsive hiding — the mobile layout is already a compact card stack\n * without a tabular header, so the label reads as redundant there.\n * - Completed-tab empty message: `nukleus-app`'s wording depends on whether\n * there are current-tab project deals (\"No past deals recorded yet.\" vs.\n * the fuller \"no deals at all\" message); `clientapp`'s is a single fixed\n * string. `completedEmptyMessage` accepts either a plain string or a\n * `(hasCurrentProjectDeals: boolean) => string` so both shapes work without\n * baking either app's copy into this package.\n */\n\n/**\n * The app-supplied bridge to its own data/backend — per\n * `docs/APPLICATION_ARCHITECTURE.md`'s Layer 5 adapter pattern, this shell\n * takes a single typed `adapter` prop rather than flat individual props, so\n * each app's own `use<Page>()` hook has one output shape to satisfy and\n * drifting apart becomes a compile error, not a silent runtime mismatch.\n */\nexport interface MarketingDealsAdapter {\n /** Shows a loading skeleton in place of the tabs. Additive — see module doc. */\n isLoading?: boolean;\n /** Shows an inline error message in place of the deal lists. */\n error?: boolean;\n errorMessage?: string;\n /** Shows a \"Retry\" button in the error state when supplied. Both apps'\n * real pages combine retrying whichever underlying query actually failed\n * behind one button — this stays a single callback for the same reason. */\n onRetry?: () => void;\n\n activeTab: \"current\" | \"completed\";\n onTabChange: (tab: \"current\" | \"completed\") => void;\n\n currentProjectDeals: ProjectDeal[];\n completedProjectDeals: ProjectDeal[];\n manualDeals: ManualDeal[];\n\n currentEmptyMessage: string;\n completedEmptyMessage: string | ((hasCurrentProjectDeals: boolean) => string);\n\n /**\n * Replaces the Current tab's content and disables the Completed tab —\n * `nukleus-app`'s client-status gating. Omit for `clientapp`'s ungated\n * behavior.\n */\n gatedEmptyState?: ReactNode;\n\n /** Required — `ProjectDealCard` structurally can't omit this. See module doc. */\n getCollabMembership: (projectId: string) => ProjectCollabMembership;\n getCollabHref: (projectId: string) => string;\n /** `nukleus-app`'s demo-mode upsell toast swaps the link for a button. */\n getOnCollabClick?: (\n projectId: string,\n ) => ((e: MouseEvent<HTMLButtonElement>) => void) | undefined;\n\n /** Presence of each enables that affordance on `ManualDealCard`/the preview\n * dialog — same shape `ManualDealCard`/`ManualDealPreviewDialog` already\n * take, so this just passes through. */\n onEditDeal?: (deal: ManualDeal) => void;\n onDeleteDeal?: (deal: ManualDeal) => void;\n onOpenDocument: (doc: ManualDealDocumentRef) => void;\n\n /** Photo of the client whose page this panel is rendered on, shown beside\n * \"Client Name\" in the manual deal preview dialog. Omit to show just the\n * name (no avatar). */\n clientImageUrl?: string | null;\n resolveImageUrl?: EntityImageResolver;\n}\n\nexport interface MarketingDealsPanelProps {\n adapter: MarketingDealsAdapter;\n /** Pure styling override — not part of the adapter, since it's never\n * backend/data-shaped. */\n className?: string;\n}\n\nexport function MarketingDealsPanel({ adapter, className }: MarketingDealsPanelProps) {\n const {\n isLoading,\n error,\n errorMessage = \"Could not load marketing deals. Please try again.\",\n onRetry,\n activeTab,\n onTabChange,\n currentProjectDeals,\n completedProjectDeals,\n manualDeals,\n currentEmptyMessage,\n completedEmptyMessage,\n gatedEmptyState,\n getCollabMembership,\n getCollabHref,\n getOnCollabClick,\n onEditDeal,\n onDeleteDeal,\n onOpenDocument,\n clientImageUrl,\n resolveImageUrl,\n } = adapter;\n\n const [previewDeal, setPreviewDeal] = useState<ManualDeal | null>(null);\n\n const resolvedCompletedEmptyMessage =\n typeof completedEmptyMessage === \"function\"\n ? completedEmptyMessage(currentProjectDeals.length > 0)\n : completedEmptyMessage;\n const hasCompletedContent = completedProjectDeals.length > 0 || manualDeals.length > 0;\n\n if (isLoading) {\n return (\n <div className={cn(\"flex flex-col gap-3\", className)}>\n <Skeleton className=\"h-9 w-full rounded-[10px]\" />\n <Skeleton className=\"h-[300px] w-full rounded-[10px]\" />\n </div>\n );\n }\n\n return (\n <div className={className}>\n <Tabs\n value={activeTab}\n onValueChange={(value) => onTabChange(value as \"current\" | \"completed\")}\n className=\"w-full flex flex-col gap-3\"\n >\n <TabsList className=\"grid w-full grid-cols-2 bg-transparent border-b border-greys-grey-strokes-tables rounded-none h-auto p-0\">\n <TabsTrigger\n value=\"current\"\n className=\"py-2.5 px-2 rounded-none border-b-2 border-transparent text-text-primary data-[state=active]:text-primary-color-nuk-text data-[state=active]:border-primary-color-nuk-text data-[state=active]:bg-transparent data-[state=active]:shadow-none\"\n >\n Current Deals\n </TabsTrigger>\n <TabsTrigger\n value=\"completed\"\n disabled={!!gatedEmptyState}\n className=\"py-2.5 px-2 rounded-none border-b-2 border-transparent text-text-primary data-[state=active]:text-primary-color-nuk-text data-[state=active]:border-primary-color-nuk-text data-[state=active]:bg-transparent data-[state=active]:shadow-none disabled:opacity-50 disabled:cursor-not-allowed\"\n >\n Completed\n </TabsTrigger>\n </TabsList>\n\n {error ? (\n <div className=\"flex flex-col items-center justify-center gap-3 py-10 px-6\" role=\"alert\">\n <p className=\"body-text text-text-primary text-center\">{errorMessage}</p>\n {onRetry && (\n <Button variant=\"secondary\" size=\"form\" onClick={onRetry}>\n Retry\n </Button>\n )}\n </div>\n ) : (\n <>\n <div className=\"hidden sm:flex items-center bg-greys-grey-table-h rounded-t-[10px] py-0 px-3 gap-3 h-[33px]\">\n <span className=\"label-xs-table text-text-primary font-ss02\">Deals</span>\n </div>\n\n <TabsContent value=\"current\" className=\"mt-0\">\n {gatedEmptyState ? (\n gatedEmptyState\n ) : currentProjectDeals.length > 0 ? (\n <div className=\"flex flex-col gap-3 sm:gap-0\">\n {currentProjectDeals.map((deal) => (\n <ProjectDealCard\n key={deal.project_id}\n deal={deal}\n isCompleted={false}\n collabMembership={getCollabMembership(deal.project_id)}\n collabHref={getCollabHref(deal.project_id)}\n onCollabClick={getOnCollabClick?.(deal.project_id)}\n resolveImageUrl={resolveImageUrl}\n />\n ))}\n </div>\n ) : (\n <DealEmptyState message={currentEmptyMessage} />\n )}\n </TabsContent>\n\n <TabsContent value=\"completed\" className=\"mt-0\">\n {!hasCompletedContent ? (\n <DealEmptyState message={resolvedCompletedEmptyMessage} />\n ) : (\n <div className=\"flex flex-col gap-3 sm:gap-0\">\n {completedProjectDeals.map((deal) => (\n <ProjectDealCard\n key={deal.project_id}\n deal={deal}\n isCompleted={true}\n collabMembership={getCollabMembership(deal.project_id)}\n collabHref={getCollabHref(deal.project_id)}\n onCollabClick={getOnCollabClick?.(deal.project_id)}\n resolveImageUrl={resolveImageUrl}\n />\n ))}\n {manualDeals.map((deal) => (\n <ManualDealCard\n key={deal.id}\n deal={deal}\n onPreview={setPreviewDeal}\n onEdit={onEditDeal}\n onDelete={onDeleteDeal}\n onOpenDocument={onOpenDocument}\n resolveImageUrl={resolveImageUrl}\n />\n ))}\n </div>\n )}\n </TabsContent>\n </>\n )}\n </Tabs>\n\n <ManualDealPreviewDialog\n deal={previewDeal}\n open={!!previewDeal}\n onOpenChange={(open) => {\n if (!open) setPreviewDeal(null);\n }}\n onEdit={\n onEditDeal\n ? (deal) => {\n // Close the preview before handing off to the edit flow,\n // matching nukleus-app's original behavior.\n setPreviewDeal(null);\n onEditDeal(deal);\n }\n : undefined\n }\n onOpenDocument={onOpenDocument}\n clientImageUrl={clientImageUrl}\n resolveImageUrl={resolveImageUrl}\n />\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,mBAA0D;AAE1D,oBAQO;AACP,uBAUO;AAuJD;AAlCC,SAAS,oBAAoB,EAAE,SAAS,UAAU,GAA6B;AACpF,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA,eAAe;AAAA,IACf;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI;AAEJ,QAAM,CAAC,aAAa,cAAc,QAAI,uBAA4B,IAAI;AAEtE,QAAM,gCACJ,OAAO,0BAA0B,aAC7B,sBAAsB,oBAAoB,SAAS,CAAC,IACpD;AACN,QAAM,sBAAsB,sBAAsB,SAAS,KAAK,YAAY,SAAS;AAErF,MAAI,WAAW;AACb,WACE,6CAAC,SAAI,eAAW,kBAAG,uBAAuB,SAAS,GACjD;AAAA,kDAAC,0BAAS,WAAU,6BAA4B;AAAA,MAChD,4CAAC,0BAAS,WAAU,mCAAkC;AAAA,OACxD;AAAA,EAEJ;AAEA,SACE,6CAAC,SAAI,WACH;AAAA;AAAA,MAAC;AAAA;AAAA,QACC,OAAO;AAAA,QACP,eAAe,CAAC,UAAU,YAAY,KAAgC;AAAA,QACtE,WAAU;AAAA,QAEV;AAAA,uDAAC,0BAAS,WAAU,4GAClB;AAAA;AAAA,cAAC;AAAA;AAAA,gBACC,OAAM;AAAA,gBACN,WAAU;AAAA,gBACX;AAAA;AAAA,YAED;AAAA,YACA;AAAA,cAAC;AAAA;AAAA,gBACC,OAA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AW;AAAA,kBACX,QAAQ;AAAA,kBACR,UAAU;AAAA,kBACV;AAAA,kBACA;AAAA;AAAA,gBANK,KAAK;AAAA,cAOZ,CACD;AAAA,eACH,GAEJ;AAAA,aACF;AAAA;AAAA;AAAA,IAEJ;AAAA,IAEA;AAAA,MAAC;AAAA;AAAA,QACC,MAAM;AAAA,QACN,MAAM,CAAC,CAAC;AAAA,QACR,cAAc,CAAC,SAAS;AACtB,cAAI,CAAC,KAAM,gBAAe,IAAI;AAAA,QAChC;AAAA,QACA,QACE,aACI,CAAC,SAAS;AAGR,yBAAe,IAAI;AACnB,qBAAW,IAAI;AAAA,QACjB,IACA;AAAA,QAEN;AAAA,QACA;AAAA,QACA;AAAA;AAAA,IACF;AAAA,KACF;AAEJ;","names":[]}
1
+ {"version":3,"sources":["../src/marketing/index.ts","../src/marketing/marketing-deals-panel.tsx"],"sourcesContent":["export {\n MarketingDealsPanel,\n type MarketingDealsAdapter,\n type MarketingDealsPanelProps,\n} from \"./marketing-deals-panel\";\n","import { useState, type MouseEvent, type ReactNode } from \"react\";\n\nimport {\n Button,\n Select,\n SelectContent,\n SelectItem,\n SelectTrigger,\n SelectValue,\n Skeleton,\n Tabs,\n TabsContent,\n TabsList,\n TabsTrigger,\n cn,\n} from \"@nukleus-sports/ui-web\";\nimport { type EntityImageResolver } from \"@nukleus-sports/ui-patterns\";\nimport {\n DealEmptyState,\n ManualDealCard,\n ManualDealPreviewDialog,\n ProjectDealCard,\n type ManualDeal,\n type ManualDealDocumentRef,\n type ProjectCollabMembership,\n type ProjectDeal,\n} from \"@nukleus-sports/ui-patterns/marketing\";\n\n/**\n * Reconciled from both apps' real current pages:\n * - `nukleus-app`'s `MarketingDealsTab.tsx` (`ClientMarketingTab`)\n * - `nukleus-clientapp`'s `pages/Marketing.tsx` + `hooks/useMarketing.ts`\n *\n * Both pages share one identical skeleton: a \"Current Deals\"/\"Completed\" tab\n * pair, a \"Deals\" label bar, a `ProjectDealCard` list per tab (`Completed`\n * also appends `ManualDealCard`s), matching empty states, and a shared\n * `ManualDealPreviewDialog`. That skeleton is this component's entire scope.\n *\n * ## Deliberately NOT in this shell (stays app-local, per CLAUDE.md's\n * page-shells rule and the decisions already made for this feature)\n * - The page header/title and the \"Record Past Deal\"/\"New Marketing Deal\"\n * buttons — `nukleus-app`-only chrome with no clientapp equivalent.\n * - `MarketingDealForm` (the CRUD create/edit form) and `DeleteDialog` —\n * `nukleus-app`-only, no clientapp read-only counterpart to reconcile\n * against, same reasoning as `MarketingOverviewPanel`/`Card` (also kept\n * app-local, rendered alongside this shell, not inside it).\n * - The top-level access gate (`nukleus-app`'s `marketingPermission ===\n * \"No Access\"` → `RestrictedAccessCard`; `clientapp`'s `!isAgencyLinked` →\n * `AgencyLinkBanner`). Both are a one-time \"should the deals experience\n * render at all\" decision made from each app's own permission shape\n * (`@nukleus-sports/core`'s `MarketingPermission` union) *before* this\n * shell ever mounts — not something this component re-derives.\n * - Project-membership resolution for the \"Collab\" link gate (`@nukleus-sports/\n * ui-patterns`' `ProjectDealCard` already enforces this structurally via its\n * required `collabMembership` prop) — the actual membership check is an\n * app-level query, surfaced here through `getCollabMembership`.\n *\n * ## Genuine differences reconciled (not formatting)\n * - Client-status gating (`nukleus-app`'s `isGated`, e.g. a \"Prospect\" client\n * can't have deals yet): `clientapp` has no such concept. Modeled as an\n * optional `gatedEmptyState` — when supplied, it replaces the Current tab's\n * content and the Completed tab is disabled, exactly matching `nukleus-app`'s\n * structure; omit it and both tabs behave normally (`clientapp`'s case).\n * - Loading skeleton: `clientapp` shows one before the tabs ever render;\n * `nukleus-app` has none (deals just populate once the query resolves).\n * Kept as an additive, opt-in `isLoading` prop — a loading affordance isn't\n * an agency-vs-client distinction, so both can use it.\n * - \"Deals\" label bar visibility on mobile: `nukleus-app` hides it below `sm`\n * (`hidden sm:flex`), `clientapp` always shows it. Kept `nukleus-app`'s\n * responsive hiding — the mobile layout is already a compact card stack\n * without a tabular header, so the label reads as redundant there.\n * - Completed-tab empty message: `nukleus-app`'s wording depends on whether\n * there are current-tab project deals (\"No past deals recorded yet.\" vs.\n * the fuller \"no deals at all\" message); `clientapp`'s is a single fixed\n * string. `completedEmptyMessage` accepts either a plain string or a\n * `(hasCurrentProjectDeals: boolean) => string` so both shapes work without\n * baking either app's copy into this package.\n * - Completed-tab year filter: `clientapp` lets a client filter years of\n * deal history via a dropdown; `nukleus-app` has no equivalent at all.\n * Modeled as an optional `completedYearFilter` — when supplied, this\n * package renders the dropdown (and nothing else; which deals actually\n * appear is still just `completedProjectDeals`/`manualDeals`, already\n * filtered by the adapter before this object is built). `nukleus-app`\n * simply omits it, same pattern as `gatedEmptyState`.\n */\n\n/**\n * The app-supplied bridge to its own data/backend — per\n * `docs/APPLICATION_ARCHITECTURE.md`'s Layer 5 adapter pattern, this shell\n * takes a single typed `adapter` prop rather than flat individual props, so\n * each app's own `use<Page>()` hook has one output shape to satisfy and\n * drifting apart becomes a compile error, not a silent runtime mismatch.\n */\nexport interface MarketingDealsAdapter {\n /** Shows a loading skeleton in place of the tabs. Additive — see module doc. */\n isLoading?: boolean;\n /** Shows an inline error message in place of the deal lists. */\n error?: boolean;\n errorMessage?: string;\n /** Shows a \"Retry\" button in the error state when supplied. Both apps'\n * real pages combine retrying whichever underlying query actually failed\n * behind one button — this stays a single callback for the same reason. */\n onRetry?: () => void;\n\n activeTab: \"current\" | \"completed\";\n onTabChange: (tab: \"current\" | \"completed\") => void;\n\n currentProjectDeals: ProjectDeal[];\n completedProjectDeals: ProjectDeal[];\n manualDeals: ManualDeal[];\n\n currentEmptyMessage: string;\n completedEmptyMessage: string | ((hasCurrentProjectDeals: boolean) => string);\n\n /**\n * Replaces the Current tab's content and disables the Completed tab —\n * `nukleus-app`'s client-status gating. Omit for `clientapp`'s ungated\n * behavior.\n */\n gatedEmptyState?: ReactNode;\n\n /**\n * Year filter for the Completed tab's deal history (`clientapp`-only\n * today — `nukleus-app` has no equivalent, so it simply never supplies\n * this). This package renders only the dropdown; filtering which deals\n * actually appear in `completedProjectDeals`/`manualDeals` is the\n * adapter's own job, done before this object is built (same as\n * `clientapp`'s own hook already filtering before this retrofit).\n * `options` already includes any \"All\" entry the caller wants — this\n * package has no opinion on that sentinel value or its label.\n */\n completedYearFilter?: {\n options: { value: string; label: string }[];\n value: string;\n onChange: (value: string) => void;\n };\n\n /** Required — `ProjectDealCard` structurally can't omit this. See module doc. */\n getCollabMembership: (projectId: string) => ProjectCollabMembership;\n getCollabHref: (projectId: string) => string;\n /** `nukleus-app`'s demo-mode upsell toast swaps the link for a button. */\n getOnCollabClick?: (\n projectId: string,\n ) => ((e: MouseEvent<HTMLButtonElement>) => void) | undefined;\n\n /** Presence of each enables that affordance on `ManualDealCard`/the preview\n * dialog — same shape `ManualDealCard`/`ManualDealPreviewDialog` already\n * take, so this just passes through. */\n onEditDeal?: (deal: ManualDeal) => void;\n onDeleteDeal?: (deal: ManualDeal) => void;\n onOpenDocument: (doc: ManualDealDocumentRef) => void;\n\n /** Photo of the client whose page this panel is rendered on, shown beside\n * \"Client Name\" in the manual deal preview dialog. Omit to show just the\n * name (no avatar). */\n clientImageUrl?: string | null;\n resolveImageUrl?: EntityImageResolver;\n\n /**\n * Rendered via `ProjectDealCard`/`ManualDealCard`'s own `asideFooter` slot\n * for the given deal — e.g. `clientapp`'s per-deal commission breakdown,\n * which `nukleus-app` has no equivalent for. This package has no opinion\n * on the content; omit either (or both) for nothing extra. `ManualDealCard`\n * only renders its slot on desktop today — see that component's module doc.\n */\n getProjectDealAsideFooter?: (deal: ProjectDeal) => ReactNode;\n getManualDealAsideFooter?: (deal: ManualDeal) => ReactNode;\n}\n\nexport interface MarketingDealsPanelProps {\n adapter: MarketingDealsAdapter;\n /** Pure styling override — not part of the adapter, since it's never\n * backend/data-shaped. */\n className?: string;\n}\n\nexport function MarketingDealsPanel({ adapter, className }: MarketingDealsPanelProps) {\n const {\n isLoading,\n error,\n errorMessage = \"Could not load marketing deals. Please try again.\",\n onRetry,\n activeTab,\n onTabChange,\n currentProjectDeals,\n completedProjectDeals,\n manualDeals,\n currentEmptyMessage,\n completedEmptyMessage,\n gatedEmptyState,\n completedYearFilter,\n getCollabMembership,\n getCollabHref,\n getOnCollabClick,\n onEditDeal,\n onDeleteDeal,\n onOpenDocument,\n clientImageUrl,\n resolveImageUrl,\n getProjectDealAsideFooter,\n getManualDealAsideFooter,\n } = adapter;\n\n const [previewDeal, setPreviewDeal] = useState<ManualDeal | null>(null);\n\n const resolvedCompletedEmptyMessage =\n typeof completedEmptyMessage === \"function\"\n ? completedEmptyMessage(currentProjectDeals.length > 0)\n : completedEmptyMessage;\n const hasCompletedContent = completedProjectDeals.length > 0 || manualDeals.length > 0;\n\n if (isLoading) {\n return (\n <div className={cn(\"flex flex-col gap-3\", className)}>\n <Skeleton className=\"h-9 w-full rounded-[10px]\" />\n <Skeleton className=\"h-[300px] w-full rounded-[10px]\" />\n </div>\n );\n }\n\n return (\n <div className={className}>\n <Tabs\n value={activeTab}\n onValueChange={(value) => onTabChange(value as \"current\" | \"completed\")}\n className=\"w-full flex flex-col gap-3\"\n >\n <TabsList className=\"grid w-full grid-cols-2 bg-transparent border-b border-greys-grey-strokes-tables rounded-none h-auto p-0\">\n <TabsTrigger\n value=\"current\"\n className=\"py-2.5 px-2 rounded-none border-b-2 border-transparent text-text-primary data-[state=active]:text-primary-color-nuk-text data-[state=active]:border-primary-color-nuk-text data-[state=active]:bg-transparent data-[state=active]:shadow-none\"\n >\n Current Deals\n </TabsTrigger>\n <TabsTrigger\n value=\"completed\"\n disabled={!!gatedEmptyState}\n className=\"py-2.5 px-2 rounded-none border-b-2 border-transparent text-text-primary data-[state=active]:text-primary-color-nuk-text data-[state=active]:border-primary-color-nuk-text data-[state=active]:bg-transparent data-[state=active]:shadow-none disabled:opacity-50 disabled:cursor-not-allowed\"\n >\n Completed\n </TabsTrigger>\n </TabsList>\n\n {error ? (\n <div className=\"flex flex-col items-center justify-center gap-3 py-10 px-6\" role=\"alert\">\n <p className=\"body-text text-text-primary text-center\">{errorMessage}</p>\n {onRetry && (\n <Button variant=\"secondary\" size=\"form\" onClick={onRetry}>\n Retry\n </Button>\n )}\n </div>\n ) : (\n <>\n {activeTab === \"completed\" && completedYearFilter && (\n <Select\n value={completedYearFilter.value}\n onValueChange={completedYearFilter.onChange}\n >\n <SelectTrigger className=\"w-[140px]\" aria-label=\"Filter completed deals by year\">\n <SelectValue />\n </SelectTrigger>\n <SelectContent>\n {completedYearFilter.options.map((option) => (\n <SelectItem key={option.value} value={option.value}>\n {option.label}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n )}\n\n <div className=\"hidden sm:flex items-center bg-greys-grey-table-h rounded-t-[10px] py-0 px-3 gap-3 h-[33px]\">\n <span className=\"label-xs-table text-text-primary font-ss02\">Deals</span>\n </div>\n\n <TabsContent value=\"current\" className=\"mt-0\">\n {gatedEmptyState ? (\n gatedEmptyState\n ) : currentProjectDeals.length > 0 ? (\n <div className=\"flex flex-col gap-3 sm:gap-0\">\n {currentProjectDeals.map((deal) => (\n <ProjectDealCard\n key={deal.project_id}\n deal={deal}\n isCompleted={false}\n collabMembership={getCollabMembership(deal.project_id)}\n collabHref={getCollabHref(deal.project_id)}\n onCollabClick={getOnCollabClick?.(deal.project_id)}\n resolveImageUrl={resolveImageUrl}\n asideFooter={getProjectDealAsideFooter?.(deal)}\n />\n ))}\n </div>\n ) : (\n <DealEmptyState message={currentEmptyMessage} />\n )}\n </TabsContent>\n\n <TabsContent value=\"completed\" className=\"mt-0\">\n {!hasCompletedContent ? (\n <DealEmptyState message={resolvedCompletedEmptyMessage} />\n ) : (\n <div className=\"flex flex-col gap-3 sm:gap-0\">\n {completedProjectDeals.map((deal) => (\n <ProjectDealCard\n key={deal.project_id}\n deal={deal}\n isCompleted={true}\n collabMembership={getCollabMembership(deal.project_id)}\n collabHref={getCollabHref(deal.project_id)}\n onCollabClick={getOnCollabClick?.(deal.project_id)}\n resolveImageUrl={resolveImageUrl}\n asideFooter={getProjectDealAsideFooter?.(deal)}\n />\n ))}\n {manualDeals.map((deal) => (\n <ManualDealCard\n key={deal.id}\n deal={deal}\n onPreview={setPreviewDeal}\n onEdit={onEditDeal}\n onDelete={onDeleteDeal}\n onOpenDocument={onOpenDocument}\n resolveImageUrl={resolveImageUrl}\n asideFooter={getManualDealAsideFooter?.(deal)}\n />\n ))}\n </div>\n )}\n </TabsContent>\n </>\n )}\n </Tabs>\n\n <ManualDealPreviewDialog\n deal={previewDeal}\n open={!!previewDeal}\n onOpenChange={(open) => {\n if (!open) setPreviewDeal(null);\n }}\n onEdit={\n onEditDeal\n ? (deal) => {\n // Close the preview before handing off to the edit flow,\n // matching nukleus-app's original behavior.\n setPreviewDeal(null);\n onEditDeal(deal);\n }\n : undefined\n }\n onOpenDocument={onOpenDocument}\n clientImageUrl={clientImageUrl}\n resolveImageUrl={resolveImageUrl}\n />\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,mBAA0D;AAE1D,oBAaO;AAEP,uBASO;AA2LD;AArCC,SAAS,oBAAoB,EAAE,SAAS,UAAU,GAA6B;AACpF,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA,eAAe;AAAA,IACf;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI;AAEJ,QAAM,CAAC,aAAa,cAAc,QAAI,uBAA4B,IAAI;AAEtE,QAAM,gCACJ,OAAO,0BAA0B,aAC7B,sBAAsB,oBAAoB,SAAS,CAAC,IACpD;AACN,QAAM,sBAAsB,sBAAsB,SAAS,KAAK,YAAY,SAAS;AAErF,MAAI,WAAW;AACb,WACE,6CAAC,SAAI,eAAW,kBAAG,uBAAuB,SAAS,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qBAAW,IAAI;AAAA,QACjB,IACA;AAAA,QAEN;AAAA,QACA;AAAA,QACA;AAAA;AAAA,IACF;AAAA,KACF;AAEJ;","names":[]}
@@ -1,6 +1,7 @@
1
1
  import * as react from 'react';
2
2
  import { ReactNode, MouseEvent } from 'react';
3
- import { ProjectDeal, ManualDeal, ProjectCollabMembership, ManualDealDocumentRef, EntityImageResolver } from '@nukleus-sports/ui-patterns/marketing';
3
+ import { EntityImageResolver } from '@nukleus-sports/ui-patterns';
4
+ import { ProjectDeal, ManualDeal, ProjectCollabMembership, ManualDealDocumentRef } from '@nukleus-sports/ui-patterns/marketing';
4
5
 
5
6
  /**
6
7
  * Reconciled from both apps' real current pages:
@@ -51,6 +52,13 @@ import { ProjectDeal, ManualDeal, ProjectCollabMembership, ManualDealDocumentRef
51
52
  * string. `completedEmptyMessage` accepts either a plain string or a
52
53
  * `(hasCurrentProjectDeals: boolean) => string` so both shapes work without
53
54
  * baking either app's copy into this package.
55
+ * - Completed-tab year filter: `clientapp` lets a client filter years of
56
+ * deal history via a dropdown; `nukleus-app` has no equivalent at all.
57
+ * Modeled as an optional `completedYearFilter` — when supplied, this
58
+ * package renders the dropdown (and nothing else; which deals actually
59
+ * appear is still just `completedProjectDeals`/`manualDeals`, already
60
+ * filtered by the adapter before this object is built). `nukleus-app`
61
+ * simply omits it, same pattern as `gatedEmptyState`.
54
62
  */
55
63
  /**
56
64
  * The app-supplied bridge to its own data/backend — per
@@ -82,6 +90,24 @@ interface MarketingDealsAdapter {
82
90
  * behavior.
83
91
  */
84
92
  gatedEmptyState?: ReactNode;
93
+ /**
94
+ * Year filter for the Completed tab's deal history (`clientapp`-only
95
+ * today — `nukleus-app` has no equivalent, so it simply never supplies
96
+ * this). This package renders only the dropdown; filtering which deals
97
+ * actually appear in `completedProjectDeals`/`manualDeals` is the
98
+ * adapter's own job, done before this object is built (same as
99
+ * `clientapp`'s own hook already filtering before this retrofit).
100
+ * `options` already includes any "All" entry the caller wants — this
101
+ * package has no opinion on that sentinel value or its label.
102
+ */
103
+ completedYearFilter?: {
104
+ options: {
105
+ value: string;
106
+ label: string;
107
+ }[];
108
+ value: string;
109
+ onChange: (value: string) => void;
110
+ };
85
111
  /** Required — `ProjectDealCard` structurally can't omit this. See module doc. */
86
112
  getCollabMembership: (projectId: string) => ProjectCollabMembership;
87
113
  getCollabHref: (projectId: string) => string;
@@ -98,6 +124,15 @@ interface MarketingDealsAdapter {
98
124
  * name (no avatar). */
99
125
  clientImageUrl?: string | null;
100
126
  resolveImageUrl?: EntityImageResolver;
127
+ /**
128
+ * Rendered via `ProjectDealCard`/`ManualDealCard`'s own `asideFooter` slot
129
+ * for the given deal — e.g. `clientapp`'s per-deal commission breakdown,
130
+ * which `nukleus-app` has no equivalent for. This package has no opinion
131
+ * on the content; omit either (or both) for nothing extra. `ManualDealCard`
132
+ * only renders its slot on desktop today — see that component's module doc.
133
+ */
134
+ getProjectDealAsideFooter?: (deal: ProjectDeal) => ReactNode;
135
+ getManualDealAsideFooter?: (deal: ManualDeal) => ReactNode;
101
136
  }
102
137
  interface MarketingDealsPanelProps {
103
138
  adapter: MarketingDealsAdapter;
@@ -1,6 +1,7 @@
1
1
  import * as react from 'react';
2
2
  import { ReactNode, MouseEvent } from 'react';
3
- import { ProjectDeal, ManualDeal, ProjectCollabMembership, ManualDealDocumentRef, EntityImageResolver } from '@nukleus-sports/ui-patterns/marketing';
3
+ import { EntityImageResolver } from '@nukleus-sports/ui-patterns';
4
+ import { ProjectDeal, ManualDeal, ProjectCollabMembership, ManualDealDocumentRef } from '@nukleus-sports/ui-patterns/marketing';
4
5
 
5
6
  /**
6
7
  * Reconciled from both apps' real current pages:
@@ -51,6 +52,13 @@ import { ProjectDeal, ManualDeal, ProjectCollabMembership, ManualDealDocumentRef
51
52
  * string. `completedEmptyMessage` accepts either a plain string or a
52
53
  * `(hasCurrentProjectDeals: boolean) => string` so both shapes work without
53
54
  * baking either app's copy into this package.
55
+ * - Completed-tab year filter: `clientapp` lets a client filter years of
56
+ * deal history via a dropdown; `nukleus-app` has no equivalent at all.
57
+ * Modeled as an optional `completedYearFilter` — when supplied, this
58
+ * package renders the dropdown (and nothing else; which deals actually
59
+ * appear is still just `completedProjectDeals`/`manualDeals`, already
60
+ * filtered by the adapter before this object is built). `nukleus-app`
61
+ * simply omits it, same pattern as `gatedEmptyState`.
54
62
  */
55
63
  /**
56
64
  * The app-supplied bridge to its own data/backend — per
@@ -82,6 +90,24 @@ interface MarketingDealsAdapter {
82
90
  * behavior.
83
91
  */
84
92
  gatedEmptyState?: ReactNode;
93
+ /**
94
+ * Year filter for the Completed tab's deal history (`clientapp`-only
95
+ * today — `nukleus-app` has no equivalent, so it simply never supplies
96
+ * this). This package renders only the dropdown; filtering which deals
97
+ * actually appear in `completedProjectDeals`/`manualDeals` is the
98
+ * adapter's own job, done before this object is built (same as
99
+ * `clientapp`'s own hook already filtering before this retrofit).
100
+ * `options` already includes any "All" entry the caller wants — this
101
+ * package has no opinion on that sentinel value or its label.
102
+ */
103
+ completedYearFilter?: {
104
+ options: {
105
+ value: string;
106
+ label: string;
107
+ }[];
108
+ value: string;
109
+ onChange: (value: string) => void;
110
+ };
85
111
  /** Required — `ProjectDealCard` structurally can't omit this. See module doc. */
86
112
  getCollabMembership: (projectId: string) => ProjectCollabMembership;
87
113
  getCollabHref: (projectId: string) => string;
@@ -98,6 +124,15 @@ interface MarketingDealsAdapter {
98
124
  * name (no avatar). */
99
125
  clientImageUrl?: string | null;
100
126
  resolveImageUrl?: EntityImageResolver;
127
+ /**
128
+ * Rendered via `ProjectDealCard`/`ManualDealCard`'s own `asideFooter` slot
129
+ * for the given deal — e.g. `clientapp`'s per-deal commission breakdown,
130
+ * which `nukleus-app` has no equivalent for. This package has no opinion
131
+ * on the content; omit either (or both) for nothing extra. `ManualDealCard`
132
+ * only renders its slot on desktop today — see that component's module doc.
133
+ */
134
+ getProjectDealAsideFooter?: (deal: ProjectDeal) => ReactNode;
135
+ getManualDealAsideFooter?: (deal: ManualDeal) => ReactNode;
101
136
  }
102
137
  interface MarketingDealsPanelProps {
103
138
  adapter: MarketingDealsAdapter;
package/dist/marketing.js CHANGED
@@ -2,6 +2,11 @@
2
2
  import { useState } from "react";
3
3
  import {
4
4
  Button,
5
+ Select,
6
+ SelectContent,
7
+ SelectItem,
8
+ SelectTrigger,
9
+ SelectValue,
5
10
  Skeleton,
6
11
  Tabs,
7
12
  TabsContent,
@@ -30,6 +35,7 @@ function MarketingDealsPanel({ adapter, className }) {
30
35
  currentEmptyMessage,
31
36
  completedEmptyMessage,
32
37
  gatedEmptyState,
38
+ completedYearFilter,
33
39
  getCollabMembership,
34
40
  getCollabHref,
35
41
  getOnCollabClick,
@@ -37,7 +43,9 @@ function MarketingDealsPanel({ adapter, className }) {
37
43
  onDeleteDeal,
38
44
  onOpenDocument,
39
45
  clientImageUrl,
40
- resolveImageUrl
46
+ resolveImageUrl,
47
+ getProjectDealAsideFooter,
48
+ getManualDealAsideFooter
41
49
  } = adapter;
42
50
  const [previewDeal, setPreviewDeal] = useState(null);
43
51
  const resolvedCompletedEmptyMessage = typeof completedEmptyMessage === "function" ? completedEmptyMessage(currentProjectDeals.length > 0) : completedEmptyMessage;
@@ -79,6 +87,17 @@ function MarketingDealsPanel({ adapter, className }) {
79
87
  /* @__PURE__ */ jsx("p", { className: "body-text text-text-primary text-center", children: errorMessage }),
80
88
  onRetry && /* @__PURE__ */ jsx(Button, { variant: "secondary", size: "form", onClick: onRetry, children: "Retry" })
81
89
  ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
90
+ activeTab === "completed" && completedYearFilter && /* @__PURE__ */ jsxs(
91
+ Select,
92
+ {
93
+ value: completedYearFilter.value,
94
+ onValueChange: completedYearFilter.onChange,
95
+ children: [
96
+ /* @__PURE__ */ jsx(SelectTrigger, { className: "w-[140px]", "aria-label": "Filter completed deals by year", children: /* @__PURE__ */ jsx(SelectValue, {}) }),
97
+ /* @__PURE__ */ jsx(SelectContent, { children: completedYearFilter.options.map((option) => /* @__PURE__ */ jsx(SelectItem, { value: option.value, children: option.label }, option.value)) })
98
+ ]
99
+ }
100
+ ),
82
101
  /* @__PURE__ */ jsx("div", { className: "hidden sm:flex items-center bg-greys-grey-table-h rounded-t-[10px] py-0 px-3 gap-3 h-[33px]", children: /* @__PURE__ */ jsx("span", { className: "label-xs-table text-text-primary font-ss02", children: "Deals" }) }),
83
102
  /* @__PURE__ */ jsx(TabsContent, { value: "current", className: "mt-0", children: gatedEmptyState ? gatedEmptyState : currentProjectDeals.length > 0 ? /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-3 sm:gap-0", children: currentProjectDeals.map((deal) => /* @__PURE__ */ jsx(
84
103
  ProjectDealCard,
@@ -88,7 +107,8 @@ function MarketingDealsPanel({ adapter, className }) {
88
107
  collabMembership: getCollabMembership(deal.project_id),
89
108
  collabHref: getCollabHref(deal.project_id),
90
109
  onCollabClick: getOnCollabClick?.(deal.project_id),
91
- resolveImageUrl
110
+ resolveImageUrl,
111
+ asideFooter: getProjectDealAsideFooter?.(deal)
92
112
  },
93
113
  deal.project_id
94
114
  )) }) : /* @__PURE__ */ jsx(DealEmptyState, { message: currentEmptyMessage }) }),
@@ -101,7 +121,8 @@ function MarketingDealsPanel({ adapter, className }) {
101
121
  collabMembership: getCollabMembership(deal.project_id),
102
122
  collabHref: getCollabHref(deal.project_id),
103
123
  onCollabClick: getOnCollabClick?.(deal.project_id),
104
- resolveImageUrl
124
+ resolveImageUrl,
125
+ asideFooter: getProjectDealAsideFooter?.(deal)
105
126
  },
106
127
  deal.project_id
107
128
  )),
@@ -113,7 +134,8 @@ function MarketingDealsPanel({ adapter, className }) {
113
134
  onEdit: onEditDeal,
114
135
  onDelete: onDeleteDeal,
115
136
  onOpenDocument,
116
- resolveImageUrl
137
+ resolveImageUrl,
138
+ asideFooter: getManualDealAsideFooter?.(deal)
117
139
  },
118
140
  deal.id
119
141
  ))
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/marketing/marketing-deals-panel.tsx"],"sourcesContent":["import { useState, type MouseEvent, type ReactNode } from \"react\";\n\nimport {\n Button,\n Skeleton,\n Tabs,\n TabsContent,\n TabsList,\n TabsTrigger,\n cn,\n} from \"@nukleus-sports/ui-web\";\nimport {\n DealEmptyState,\n ManualDealCard,\n ManualDealPreviewDialog,\n ProjectDealCard,\n type EntityImageResolver,\n type ManualDeal,\n type ManualDealDocumentRef,\n type ProjectCollabMembership,\n type ProjectDeal,\n} from \"@nukleus-sports/ui-patterns/marketing\";\n\n/**\n * Reconciled from both apps' real current pages:\n * - `nukleus-app`'s `MarketingDealsTab.tsx` (`ClientMarketingTab`)\n * - `nukleus-clientapp`'s `pages/Marketing.tsx` + `hooks/useMarketing.ts`\n *\n * Both pages share one identical skeleton: a \"Current Deals\"/\"Completed\" tab\n * pair, a \"Deals\" label bar, a `ProjectDealCard` list per tab (`Completed`\n * also appends `ManualDealCard`s), matching empty states, and a shared\n * `ManualDealPreviewDialog`. That skeleton is this component's entire scope.\n *\n * ## Deliberately NOT in this shell (stays app-local, per CLAUDE.md's\n * page-shells rule and the decisions already made for this feature)\n * - The page header/title and the \"Record Past Deal\"/\"New Marketing Deal\"\n * buttons — `nukleus-app`-only chrome with no clientapp equivalent.\n * - `MarketingDealForm` (the CRUD create/edit form) and `DeleteDialog` —\n * `nukleus-app`-only, no clientapp read-only counterpart to reconcile\n * against, same reasoning as `MarketingOverviewPanel`/`Card` (also kept\n * app-local, rendered alongside this shell, not inside it).\n * - The top-level access gate (`nukleus-app`'s `marketingPermission ===\n * \"No Access\"` → `RestrictedAccessCard`; `clientapp`'s `!isAgencyLinked` →\n * `AgencyLinkBanner`). Both are a one-time \"should the deals experience\n * render at all\" decision made from each app's own permission shape\n * (`@nukleus-sports/core`'s `MarketingPermission` union) *before* this\n * shell ever mounts — not something this component re-derives.\n * - Project-membership resolution for the \"Collab\" link gate (`@nukleus-sports/\n * ui-patterns`' `ProjectDealCard` already enforces this structurally via its\n * required `collabMembership` prop) — the actual membership check is an\n * app-level query, surfaced here through `getCollabMembership`.\n *\n * ## Genuine differences reconciled (not formatting)\n * - Client-status gating (`nukleus-app`'s `isGated`, e.g. a \"Prospect\" client\n * can't have deals yet): `clientapp` has no such concept. Modeled as an\n * optional `gatedEmptyState` — when supplied, it replaces the Current tab's\n * content and the Completed tab is disabled, exactly matching `nukleus-app`'s\n * structure; omit it and both tabs behave normally (`clientapp`'s case).\n * - Loading skeleton: `clientapp` shows one before the tabs ever render;\n * `nukleus-app` has none (deals just populate once the query resolves).\n * Kept as an additive, opt-in `isLoading` prop — a loading affordance isn't\n * an agency-vs-client distinction, so both can use it.\n * - \"Deals\" label bar visibility on mobile: `nukleus-app` hides it below `sm`\n * (`hidden sm:flex`), `clientapp` always shows it. Kept `nukleus-app`'s\n * responsive hiding — the mobile layout is already a compact card stack\n * without a tabular header, so the label reads as redundant there.\n * - Completed-tab empty message: `nukleus-app`'s wording depends on whether\n * there are current-tab project deals (\"No past deals recorded yet.\" vs.\n * the fuller \"no deals at all\" message); `clientapp`'s is a single fixed\n * string. `completedEmptyMessage` accepts either a plain string or a\n * `(hasCurrentProjectDeals: boolean) => string` so both shapes work without\n * baking either app's copy into this package.\n */\n\n/**\n * The app-supplied bridge to its own data/backend — per\n * `docs/APPLICATION_ARCHITECTURE.md`'s Layer 5 adapter pattern, this shell\n * takes a single typed `adapter` prop rather than flat individual props, so\n * each app's own `use<Page>()` hook has one output shape to satisfy and\n * drifting apart becomes a compile error, not a silent runtime mismatch.\n */\nexport interface MarketingDealsAdapter {\n /** Shows a loading skeleton in place of the tabs. Additive — see module doc. */\n isLoading?: boolean;\n /** Shows an inline error message in place of the deal lists. */\n error?: boolean;\n errorMessage?: string;\n /** Shows a \"Retry\" button in the error state when supplied. Both apps'\n * real pages combine retrying whichever underlying query actually failed\n * behind one button — this stays a single callback for the same reason. */\n onRetry?: () => void;\n\n activeTab: \"current\" | \"completed\";\n onTabChange: (tab: \"current\" | \"completed\") => void;\n\n currentProjectDeals: ProjectDeal[];\n completedProjectDeals: ProjectDeal[];\n manualDeals: ManualDeal[];\n\n currentEmptyMessage: string;\n completedEmptyMessage: string | ((hasCurrentProjectDeals: boolean) => string);\n\n /**\n * Replaces the Current tab's content and disables the Completed tab —\n * `nukleus-app`'s client-status gating. Omit for `clientapp`'s ungated\n * behavior.\n */\n gatedEmptyState?: ReactNode;\n\n /** Required — `ProjectDealCard` structurally can't omit this. See module doc. */\n getCollabMembership: (projectId: string) => ProjectCollabMembership;\n getCollabHref: (projectId: string) => string;\n /** `nukleus-app`'s demo-mode upsell toast swaps the link for a button. */\n getOnCollabClick?: (\n projectId: string,\n ) => ((e: MouseEvent<HTMLButtonElement>) => void) | undefined;\n\n /** Presence of each enables that affordance on `ManualDealCard`/the preview\n * dialog — same shape `ManualDealCard`/`ManualDealPreviewDialog` already\n * take, so this just passes through. */\n onEditDeal?: (deal: ManualDeal) => void;\n onDeleteDeal?: (deal: ManualDeal) => void;\n onOpenDocument: (doc: ManualDealDocumentRef) => void;\n\n /** Photo of the client whose page this panel is rendered on, shown beside\n * \"Client Name\" in the manual deal preview dialog. Omit to show just the\n * name (no avatar). */\n clientImageUrl?: string | null;\n resolveImageUrl?: EntityImageResolver;\n}\n\nexport interface MarketingDealsPanelProps {\n adapter: MarketingDealsAdapter;\n /** Pure styling override — not part of the adapter, since it's never\n * backend/data-shaped. */\n className?: string;\n}\n\nexport function MarketingDealsPanel({ adapter, className }: MarketingDealsPanelProps) {\n const {\n isLoading,\n error,\n errorMessage = \"Could not load marketing deals. Please try again.\",\n onRetry,\n activeTab,\n onTabChange,\n currentProjectDeals,\n completedProjectDeals,\n manualDeals,\n currentEmptyMessage,\n completedEmptyMessage,\n gatedEmptyState,\n getCollabMembership,\n getCollabHref,\n getOnCollabClick,\n onEditDeal,\n onDeleteDeal,\n onOpenDocument,\n clientImageUrl,\n resolveImageUrl,\n } = adapter;\n\n const [previewDeal, setPreviewDeal] = useState<ManualDeal | null>(null);\n\n const resolvedCompletedEmptyMessage =\n typeof completedEmptyMessage === \"function\"\n ? completedEmptyMessage(currentProjectDeals.length > 0)\n : completedEmptyMessage;\n const hasCompletedContent = completedProjectDeals.length > 0 || manualDeals.length > 0;\n\n if (isLoading) {\n return (\n <div className={cn(\"flex flex-col gap-3\", className)}>\n <Skeleton className=\"h-9 w-full rounded-[10px]\" />\n <Skeleton className=\"h-[300px] w-full rounded-[10px]\" />\n </div>\n );\n }\n\n return (\n <div className={className}>\n <Tabs\n value={activeTab}\n onValueChange={(value) => onTabChange(value as \"current\" | \"completed\")}\n className=\"w-full flex flex-col gap-3\"\n >\n <TabsList className=\"grid w-full grid-cols-2 bg-transparent border-b border-greys-grey-strokes-tables rounded-none h-auto p-0\">\n <TabsTrigger\n value=\"current\"\n className=\"py-2.5 px-2 rounded-none border-b-2 border-transparent text-text-primary data-[state=active]:text-primary-color-nuk-text data-[state=active]:border-primary-color-nuk-text data-[state=active]:bg-transparent data-[state=active]:shadow-none\"\n >\n Current Deals\n </TabsTrigger>\n <TabsTrigger\n value=\"completed\"\n disabled={!!gatedEmptyState}\n className=\"py-2.5 px-2 rounded-none border-b-2 border-transparent text-text-primary data-[state=active]:text-primary-color-nuk-text data-[state=active]:border-primary-color-nuk-text data-[state=active]:bg-transparent data-[state=active]:shadow-none disabled:opacity-50 disabled:cursor-not-allowed\"\n >\n Completed\n </TabsTrigger>\n </TabsList>\n\n {error ? (\n <div className=\"flex flex-col items-center justify-center gap-3 py-10 px-6\" role=\"alert\">\n <p className=\"body-text text-text-primary text-center\">{errorMessage}</p>\n {onRetry && (\n <Button variant=\"secondary\" size=\"form\" onClick={onRetry}>\n Retry\n </Button>\n )}\n </div>\n ) : (\n <>\n <div className=\"hidden sm:flex items-center bg-greys-grey-table-h rounded-t-[10px] py-0 px-3 gap-3 h-[33px]\">\n <span className=\"label-xs-table text-text-primary font-ss02\">Deals</span>\n </div>\n\n <TabsContent value=\"current\" className=\"mt-0\">\n {gatedEmptyState ? (\n gatedEmptyState\n ) : currentProjectDeals.length > 0 ? (\n <div className=\"flex flex-col gap-3 sm:gap-0\">\n {currentProjectDeals.map((deal) => (\n <ProjectDealCard\n key={deal.project_id}\n deal={deal}\n isCompleted={false}\n collabMembership={getCollabMembership(deal.project_id)}\n collabHref={getCollabHref(deal.project_id)}\n onCollabClick={getOnCollabClick?.(deal.project_id)}\n resolveImageUrl={resolveImageUrl}\n />\n ))}\n </div>\n ) : (\n <DealEmptyState message={currentEmptyMessage} />\n )}\n </TabsContent>\n\n <TabsContent value=\"completed\" className=\"mt-0\">\n {!hasCompletedContent ? (\n <DealEmptyState message={resolvedCompletedEmptyMessage} />\n ) : (\n <div className=\"flex flex-col gap-3 sm:gap-0\">\n {completedProjectDeals.map((deal) => (\n <ProjectDealCard\n key={deal.project_id}\n deal={deal}\n isCompleted={true}\n collabMembership={getCollabMembership(deal.project_id)}\n collabHref={getCollabHref(deal.project_id)}\n onCollabClick={getOnCollabClick?.(deal.project_id)}\n resolveImageUrl={resolveImageUrl}\n />\n ))}\n {manualDeals.map((deal) => (\n <ManualDealCard\n key={deal.id}\n deal={deal}\n onPreview={setPreviewDeal}\n onEdit={onEditDeal}\n onDelete={onDeleteDeal}\n onOpenDocument={onOpenDocument}\n resolveImageUrl={resolveImageUrl}\n />\n ))}\n </div>\n )}\n </TabsContent>\n </>\n )}\n </Tabs>\n\n <ManualDealPreviewDialog\n deal={previewDeal}\n open={!!previewDeal}\n onOpenChange={(open) => {\n if (!open) setPreviewDeal(null);\n }}\n onEdit={\n onEditDeal\n ? (deal) => {\n // Close the preview before handing off to the edit flow,\n // matching nukleus-app's original behavior.\n setPreviewDeal(null);\n onEditDeal(deal);\n }\n : undefined\n }\n onOpenDocument={onOpenDocument}\n clientImageUrl={clientImageUrl}\n resolveImageUrl={resolveImageUrl}\n />\n </div>\n );\n}\n"],"mappings":";AAAA,SAAS,gBAAiD;AAE1D;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP;AA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QACC,MAAM;AAAA,QACN,MAAM,CAAC,CAAC;AAAA,QACR,cAAc,CAAC,SAAS;AACtB,cAAI,CAAC,KAAM,gBAAe,IAAI;AAAA,QAChC;AAAA,QACA,QACE,aACI,CAAC,SAAS;AAGR,yBAAe,IAAI;AACnB,qBAAW,IAAI;AAAA,QACjB,IACA;AAAA,QAEN;AAAA,QACA;AAAA,QACA;AAAA;AAAA,IACF;AAAA,KACF;AAEJ;","names":[]}
1
+ {"version":3,"sources":["../src/marketing/marketing-deals-panel.tsx"],"sourcesContent":["import { useState, type MouseEvent, type ReactNode } from \"react\";\n\nimport {\n Button,\n Select,\n SelectContent,\n SelectItem,\n SelectTrigger,\n SelectValue,\n Skeleton,\n Tabs,\n TabsContent,\n TabsList,\n TabsTrigger,\n cn,\n} from \"@nukleus-sports/ui-web\";\nimport { type EntityImageResolver } from \"@nukleus-sports/ui-patterns\";\nimport {\n DealEmptyState,\n ManualDealCard,\n ManualDealPreviewDialog,\n ProjectDealCard,\n type ManualDeal,\n type ManualDealDocumentRef,\n type ProjectCollabMembership,\n type ProjectDeal,\n} from \"@nukleus-sports/ui-patterns/marketing\";\n\n/**\n * Reconciled from both apps' real current pages:\n * - `nukleus-app`'s `MarketingDealsTab.tsx` (`ClientMarketingTab`)\n * - `nukleus-clientapp`'s `pages/Marketing.tsx` + `hooks/useMarketing.ts`\n *\n * Both pages share one identical skeleton: a \"Current Deals\"/\"Completed\" tab\n * pair, a \"Deals\" label bar, a `ProjectDealCard` list per tab (`Completed`\n * also appends `ManualDealCard`s), matching empty states, and a shared\n * `ManualDealPreviewDialog`. That skeleton is this component's entire scope.\n *\n * ## Deliberately NOT in this shell (stays app-local, per CLAUDE.md's\n * page-shells rule and the decisions already made for this feature)\n * - The page header/title and the \"Record Past Deal\"/\"New Marketing Deal\"\n * buttons — `nukleus-app`-only chrome with no clientapp equivalent.\n * - `MarketingDealForm` (the CRUD create/edit form) and `DeleteDialog` —\n * `nukleus-app`-only, no clientapp read-only counterpart to reconcile\n * against, same reasoning as `MarketingOverviewPanel`/`Card` (also kept\n * app-local, rendered alongside this shell, not inside it).\n * - The top-level access gate (`nukleus-app`'s `marketingPermission ===\n * \"No Access\"` → `RestrictedAccessCard`; `clientapp`'s `!isAgencyLinked` →\n * `AgencyLinkBanner`). Both are a one-time \"should the deals experience\n * render at all\" decision made from each app's own permission shape\n * (`@nukleus-sports/core`'s `MarketingPermission` union) *before* this\n * shell ever mounts — not something this component re-derives.\n * - Project-membership resolution for the \"Collab\" link gate (`@nukleus-sports/\n * ui-patterns`' `ProjectDealCard` already enforces this structurally via its\n * required `collabMembership` prop) — the actual membership check is an\n * app-level query, surfaced here through `getCollabMembership`.\n *\n * ## Genuine differences reconciled (not formatting)\n * - Client-status gating (`nukleus-app`'s `isGated`, e.g. a \"Prospect\" client\n * can't have deals yet): `clientapp` has no such concept. Modeled as an\n * optional `gatedEmptyState` — when supplied, it replaces the Current tab's\n * content and the Completed tab is disabled, exactly matching `nukleus-app`'s\n * structure; omit it and both tabs behave normally (`clientapp`'s case).\n * - Loading skeleton: `clientapp` shows one before the tabs ever render;\n * `nukleus-app` has none (deals just populate once the query resolves).\n * Kept as an additive, opt-in `isLoading` prop — a loading affordance isn't\n * an agency-vs-client distinction, so both can use it.\n * - \"Deals\" label bar visibility on mobile: `nukleus-app` hides it below `sm`\n * (`hidden sm:flex`), `clientapp` always shows it. Kept `nukleus-app`'s\n * responsive hiding — the mobile layout is already a compact card stack\n * without a tabular header, so the label reads as redundant there.\n * - Completed-tab empty message: `nukleus-app`'s wording depends on whether\n * there are current-tab project deals (\"No past deals recorded yet.\" vs.\n * the fuller \"no deals at all\" message); `clientapp`'s is a single fixed\n * string. `completedEmptyMessage` accepts either a plain string or a\n * `(hasCurrentProjectDeals: boolean) => string` so both shapes work without\n * baking either app's copy into this package.\n * - Completed-tab year filter: `clientapp` lets a client filter years of\n * deal history via a dropdown; `nukleus-app` has no equivalent at all.\n * Modeled as an optional `completedYearFilter` — when supplied, this\n * package renders the dropdown (and nothing else; which deals actually\n * appear is still just `completedProjectDeals`/`manualDeals`, already\n * filtered by the adapter before this object is built). `nukleus-app`\n * simply omits it, same pattern as `gatedEmptyState`.\n */\n\n/**\n * The app-supplied bridge to its own data/backend — per\n * `docs/APPLICATION_ARCHITECTURE.md`'s Layer 5 adapter pattern, this shell\n * takes a single typed `adapter` prop rather than flat individual props, so\n * each app's own `use<Page>()` hook has one output shape to satisfy and\n * drifting apart becomes a compile error, not a silent runtime mismatch.\n */\nexport interface MarketingDealsAdapter {\n /** Shows a loading skeleton in place of the tabs. Additive — see module doc. */\n isLoading?: boolean;\n /** Shows an inline error message in place of the deal lists. */\n error?: boolean;\n errorMessage?: string;\n /** Shows a \"Retry\" button in the error state when supplied. Both apps'\n * real pages combine retrying whichever underlying query actually failed\n * behind one button — this stays a single callback for the same reason. */\n onRetry?: () => void;\n\n activeTab: \"current\" | \"completed\";\n onTabChange: (tab: \"current\" | \"completed\") => void;\n\n currentProjectDeals: ProjectDeal[];\n completedProjectDeals: ProjectDeal[];\n manualDeals: ManualDeal[];\n\n currentEmptyMessage: string;\n completedEmptyMessage: string | ((hasCurrentProjectDeals: boolean) => string);\n\n /**\n * Replaces the Current tab's content and disables the Completed tab —\n * `nukleus-app`'s client-status gating. Omit for `clientapp`'s ungated\n * behavior.\n */\n gatedEmptyState?: ReactNode;\n\n /**\n * Year filter for the Completed tab's deal history (`clientapp`-only\n * today — `nukleus-app` has no equivalent, so it simply never supplies\n * this). This package renders only the dropdown; filtering which deals\n * actually appear in `completedProjectDeals`/`manualDeals` is the\n * adapter's own job, done before this object is built (same as\n * `clientapp`'s own hook already filtering before this retrofit).\n * `options` already includes any \"All\" entry the caller wants — this\n * package has no opinion on that sentinel value or its label.\n */\n completedYearFilter?: {\n options: { value: string; label: string }[];\n value: string;\n onChange: (value: string) => void;\n };\n\n /** Required — `ProjectDealCard` structurally can't omit this. See module doc. */\n getCollabMembership: (projectId: string) => ProjectCollabMembership;\n getCollabHref: (projectId: string) => string;\n /** `nukleus-app`'s demo-mode upsell toast swaps the link for a button. */\n getOnCollabClick?: (\n projectId: string,\n ) => ((e: MouseEvent<HTMLButtonElement>) => void) | undefined;\n\n /** Presence of each enables that affordance on `ManualDealCard`/the preview\n * dialog — same shape `ManualDealCard`/`ManualDealPreviewDialog` already\n * take, so this just passes through. */\n onEditDeal?: (deal: ManualDeal) => void;\n onDeleteDeal?: (deal: ManualDeal) => void;\n onOpenDocument: (doc: ManualDealDocumentRef) => void;\n\n /** Photo of the client whose page this panel is rendered on, shown beside\n * \"Client Name\" in the manual deal preview dialog. Omit to show just the\n * name (no avatar). */\n clientImageUrl?: string | null;\n resolveImageUrl?: EntityImageResolver;\n\n /**\n * Rendered via `ProjectDealCard`/`ManualDealCard`'s own `asideFooter` slot\n * for the given deal — e.g. `clientapp`'s per-deal commission breakdown,\n * which `nukleus-app` has no equivalent for. This package has no opinion\n * on the content; omit either (or both) for nothing extra. `ManualDealCard`\n * only renders its slot on desktop today — see that component's module doc.\n */\n getProjectDealAsideFooter?: (deal: ProjectDeal) => ReactNode;\n getManualDealAsideFooter?: (deal: ManualDeal) => ReactNode;\n}\n\nexport interface MarketingDealsPanelProps {\n adapter: MarketingDealsAdapter;\n /** Pure styling override — not part of the adapter, since it's never\n * backend/data-shaped. */\n className?: string;\n}\n\nexport function MarketingDealsPanel({ adapter, className }: MarketingDealsPanelProps) {\n const {\n isLoading,\n error,\n errorMessage = \"Could not load marketing deals. Please try again.\",\n onRetry,\n activeTab,\n onTabChange,\n currentProjectDeals,\n completedProjectDeals,\n manualDeals,\n currentEmptyMessage,\n completedEmptyMessage,\n gatedEmptyState,\n completedYearFilter,\n getCollabMembership,\n getCollabHref,\n getOnCollabClick,\n onEditDeal,\n onDeleteDeal,\n onOpenDocument,\n clientImageUrl,\n resolveImageUrl,\n getProjectDealAsideFooter,\n getManualDealAsideFooter,\n } = adapter;\n\n const [previewDeal, setPreviewDeal] = useState<ManualDeal | null>(null);\n\n const resolvedCompletedEmptyMessage =\n typeof completedEmptyMessage === \"function\"\n ? completedEmptyMessage(currentProjectDeals.length > 0)\n : completedEmptyMessage;\n const hasCompletedContent = completedProjectDeals.length > 0 || manualDeals.length > 0;\n\n if (isLoading) {\n return (\n <div className={cn(\"flex flex-col gap-3\", className)}>\n <Skeleton className=\"h-9 w-full rounded-[10px]\" />\n <Skeleton className=\"h-[300px] w-full rounded-[10px]\" />\n </div>\n );\n }\n\n return (\n <div className={className}>\n <Tabs\n value={activeTab}\n onValueChange={(value) => onTabChange(value as \"current\" | \"completed\")}\n className=\"w-full flex flex-col gap-3\"\n >\n <TabsList className=\"grid w-full grid-cols-2 bg-transparent border-b border-greys-grey-strokes-tables rounded-none h-auto p-0\">\n <TabsTrigger\n value=\"current\"\n className=\"py-2.5 px-2 rounded-none border-b-2 border-transparent text-text-primary data-[state=active]:text-primary-color-nuk-text data-[state=active]:border-primary-color-nuk-text data-[state=active]:bg-transparent data-[state=active]:shadow-none\"\n >\n Current Deals\n </TabsTrigger>\n <TabsTrigger\n value=\"completed\"\n disabled={!!gatedEmptyState}\n className=\"py-2.5 px-2 rounded-none border-b-2 border-transparent text-text-primary data-[state=active]:text-primary-color-nuk-text data-[state=active]:border-primary-color-nuk-text data-[state=active]:bg-transparent data-[state=active]:shadow-none disabled:opacity-50 disabled:cursor-not-allowed\"\n >\n Completed\n </TabsTrigger>\n </TabsList>\n\n {error ? (\n <div className=\"flex flex-col items-center justify-center gap-3 py-10 px-6\" role=\"alert\">\n <p className=\"body-text text-text-primary text-center\">{errorMessage}</p>\n {onRetry && (\n <Button variant=\"secondary\" size=\"form\" onClick={onRetry}>\n Retry\n </Button>\n )}\n </div>\n ) : (\n <>\n {activeTab === \"completed\" && completedYearFilter && (\n <Select\n value={completedYearFilter.value}\n onValueChange={completedYearFilter.onChange}\n >\n <SelectTrigger className=\"w-[140px]\" aria-label=\"Filter completed deals by year\">\n <SelectValue />\n </SelectTrigger>\n <SelectContent>\n {completedYearFilter.options.map((option) => (\n <SelectItem key={option.value} value={option.value}>\n {option.label}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n )}\n\n <div className=\"hidden sm:flex items-center bg-greys-grey-table-h rounded-t-[10px] py-0 px-3 gap-3 h-[33px]\">\n <span className=\"label-xs-table text-text-primary font-ss02\">Deals</span>\n </div>\n\n <TabsContent value=\"current\" className=\"mt-0\">\n {gatedEmptyState ? (\n gatedEmptyState\n ) : currentProjectDeals.length > 0 ? (\n <div className=\"flex flex-col gap-3 sm:gap-0\">\n {currentProjectDeals.map((deal) => (\n <ProjectDealCard\n key={deal.project_id}\n deal={deal}\n isCompleted={false}\n collabMembership={getCollabMembership(deal.project_id)}\n collabHref={getCollabHref(deal.project_id)}\n onCollabClick={getOnCollabClick?.(deal.project_id)}\n resolveImageUrl={resolveImageUrl}\n asideFooter={getProjectDealAsideFooter?.(deal)}\n />\n ))}\n </div>\n ) : (\n <DealEmptyState message={currentEmptyMessage} />\n )}\n </TabsContent>\n\n <TabsContent value=\"completed\" className=\"mt-0\">\n {!hasCompletedContent ? (\n <DealEmptyState message={resolvedCompletedEmptyMessage} />\n ) : (\n <div className=\"flex flex-col gap-3 sm:gap-0\">\n {completedProjectDeals.map((deal) => (\n <ProjectDealCard\n key={deal.project_id}\n deal={deal}\n isCompleted={true}\n collabMembership={getCollabMembership(deal.project_id)}\n collabHref={getCollabHref(deal.project_id)}\n onCollabClick={getOnCollabClick?.(deal.project_id)}\n resolveImageUrl={resolveImageUrl}\n asideFooter={getProjectDealAsideFooter?.(deal)}\n />\n ))}\n {manualDeals.map((deal) => (\n <ManualDealCard\n key={deal.id}\n deal={deal}\n onPreview={setPreviewDeal}\n onEdit={onEditDeal}\n onDelete={onDeleteDeal}\n onOpenDocument={onOpenDocument}\n resolveImageUrl={resolveImageUrl}\n asideFooter={getManualDealAsideFooter?.(deal)}\n />\n ))}\n </div>\n )}\n </TabsContent>\n </>\n )}\n </Tabs>\n\n <ManualDealPreviewDialog\n deal={previewDeal}\n open={!!previewDeal}\n onOpenChange={(open) => {\n if (!open) setPreviewDeal(null);\n }}\n onEdit={\n onEditDeal\n ? (deal) => {\n // Close the preview before handing off to the edit flow,\n // matching nukleus-app's original behavior.\n setPreviewDeal(null);\n onEditDeal(deal);\n }\n : undefined\n }\n onOpenDocument={onOpenDocument}\n clientImageUrl={clientImageUrl}\n resolveImageUrl={resolveImageUrl}\n />\n </div>\n );\n}\n"],"mappings":";AAAA,SAAS,gBAAiD;AAE1D;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAKK;AA2LD,SAwCI,UAvCF,KADF;AArCC,SAAS,oBAAoB,EAAE,SAAS,UAAU,GAA6B;AACpF,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA,eAAe;AAAA,IACf;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI;AAEJ,QAAM,CAAC,aAAa,cAAc,IAAI,SAA4B,IAAI;AAEtE,QAAM,gCACJ,OAAO,0BAA0B,aAC7B,sBAAsB,oBAAoB,SAAS,CAAC,IACpD;AACN,QAAM,sBAAsB,sBAAsB,SAAS,KAAK,YAAY,SAAS;AAErF,MAAI,WAAW;AACb,WACE,qBAAC,SAAI,WAAW,GAAG,uBAAuB,SAAS,GACjD;AAAA,0BAAC,YAAS,WAAU,6BAA4B;AAAA,MAChD,oBAAC,YAAS,WAAU,mCAAkC;AAAA,OACxD;AAAA,EAEJ;AAEA,SACE,qBAAC,SAAI,WACH;AAAA;AA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
  "name": "@nukleus-sports/page-shells",
3
- "version": "0.1.3",
3
+ "version": "0.3.0",
4
4
  "type": "module",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",
@@ -26,7 +26,7 @@
26
26
  "build": "tsup",
27
27
  "dev": "tsup --watch",
28
28
  "test": "vitest run",
29
- "lint": "eslint \"src/**/*.ts\" \"src/**/*.tsx\" \"tests/**/*.ts\"",
29
+ "lint": "eslint \"src/**/*.ts\" \"src/**/*.tsx\" \"tests/**/*.ts\" \"tests/**/*.tsx\"",
30
30
  "typecheck": "tsc --noEmit",
31
31
  "prepublishOnly": "bun run build"
32
32
  },
@@ -40,15 +40,17 @@
40
40
  "react-dom": "^18 || ^19"
41
41
  },
42
42
  "dependencies": {
43
- "@nukleus-sports/ui-patterns": "^0.1.2",
44
- "@nukleus-sports/ui-web": "^0.1.0"
43
+ "@nukleus-sports/ui-patterns": "^0.3.0",
44
+ "@nukleus-sports/ui-web": "^0.1.1"
45
45
  },
46
46
  "devDependencies": {
47
+ "@testing-library/jest-dom": "^6.9.1",
48
+ "@testing-library/react": "^16.3.2",
47
49
  "@types/node": "^26.6.1",
48
50
  "@types/react": "^18.3.3",
49
51
  "@types/react-dom": "^18.3.0",
50
- "react": "^18.3.1",
51
- "react-dom": "^18.3.1",
52
+ "react": "^19.3.1",
53
+ "react-dom": "^19.3.1",
52
54
  "tsup": "^8.4.0",
53
55
  "typescript": "^5.8.2",
54
56
  "vitest": "^5.0.1"