@tribe-nest/forge 3.60.0 → 3.61.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.
Files changed (207) hide show
  1. package/package.json +2 -1
  2. package/src/contexts/CartContext.tsx +34 -1
  3. package/src/contexts/PublicAuthContext.tsx +15 -3
  4. package/src/data/queries/_tests/metaSignals.spec.tsx +130 -0
  5. package/src/data/queries/useAccount.ts +33 -2
  6. package/src/data/queries/useAnalytics.ts +6 -6
  7. package/src/data/queries/useCallChat.ts +2 -2
  8. package/src/data/queries/useChat.ts +10 -1
  9. package/src/data/queries/useCheckouts.ts +2 -1
  10. package/src/data/queries/useCoachingAvailability.ts +10 -1
  11. package/src/data/queries/useCommunities.ts +2 -0
  12. package/src/data/queries/useCommunity.ts +362 -18
  13. package/src/data/queries/useCommunityAgent.ts +247 -0
  14. package/src/data/queries/useCommunityCalendar.ts +150 -0
  15. package/src/data/queries/useCommunityClassroom.ts +75 -0
  16. package/src/data/queries/useCommunityMembers.ts +108 -0
  17. package/src/data/queries/useCommunityModeration.ts +327 -0
  18. package/src/data/queries/useCommunityWiki.ts +137 -0
  19. package/src/data/queries/useCourses.ts +2 -0
  20. package/src/data/queries/useEmailSignIn.ts +79 -0
  21. package/src/data/queries/useEvents.ts +6 -1
  22. package/src/data/queries/useForms.ts +5 -1
  23. package/src/data/queries/useLeadMagnet.ts +6 -2
  24. package/src/data/queries/useMyBookings.ts +24 -1
  25. package/src/data/queries/useMyTickets.ts +24 -1
  26. package/src/data/queries/useNotifications.ts +6 -2
  27. package/src/data/queries/useOrders.ts +2 -1
  28. package/src/data/queries/usePWA.ts +111 -35
  29. package/src/data/queries/useSiteApp.ts +130 -0
  30. package/src/data/queries/useSubscriptions.ts +6 -1
  31. package/src/i18n/de.json +746 -1
  32. package/src/i18n/en.json +746 -1
  33. package/src/index.ts +17 -0
  34. package/src/runtime/pages.spec.ts +5 -0
  35. package/src/runtime/pages.ts +32 -6
  36. package/src/types/models.ts +11 -0
  37. package/src/ui/analytics/ForgeAnalytics.tsx +64 -34
  38. package/src/ui/analytics/PageMetaPixel.tsx +23 -8
  39. package/src/ui/analytics/_tests/ForgeAnalytics.meta.spec.tsx +129 -0
  40. package/src/ui/analytics/_tests/metaCommerceEvents.spec.tsx +159 -0
  41. package/src/ui/analytics/useMetaEvents.ts +78 -0
  42. package/src/ui/headless/_tests/communityAgent.spec.tsx +519 -0
  43. package/src/ui/headless/_tests/communityCalendar.spec.tsx +195 -0
  44. package/src/ui/headless/_tests/communityClassroom.spec.tsx +120 -0
  45. package/src/ui/headless/_tests/communityHarness.tsx +10 -3
  46. package/src/ui/headless/_tests/communityMembers.spec.tsx +316 -0
  47. package/src/ui/headless/_tests/communityPoll.spec.tsx +389 -0
  48. package/src/ui/headless/_tests/memberHomeBar.spec.ts +84 -0
  49. package/src/ui/headless/_tests/siteAppBar.spec.ts +83 -0
  50. package/src/ui/headless/_tests/siteAppHarness.ts +19 -0
  51. package/src/ui/headless/_tests/siteAppHome.spec.ts +226 -0
  52. package/src/ui/headless/_tests/siteAppPrompts.spec.ts +185 -0
  53. package/src/ui/headless/_tests/useCommunityJoin.spec.tsx +228 -14
  54. package/src/ui/headless/_tests/useCommunityMembership.spec.tsx +29 -1
  55. package/src/ui/headless/_tests/useCommunityModeration.spec.tsx +420 -0
  56. package/src/ui/headless/_tests/useCommunityReads.spec.tsx +11 -2
  57. package/src/ui/headless/_tests/useCommunityWiki.spec.tsx +224 -0
  58. package/src/ui/headless/_tests/useSiteApp.spec.tsx +52 -0
  59. package/src/ui/headless/_tests/wikiMediaImage.spec.tsx +132 -0
  60. package/src/ui/headless/auth/useEmailCodeSignIn.ts +186 -0
  61. package/src/ui/headless/auth/useSignupForm.ts +20 -1
  62. package/src/ui/headless/chat/useChatAttachmentUpload.ts +9 -6
  63. package/src/ui/headless/chat/useChatRoom.ts +35 -1
  64. package/src/ui/headless/communities/index.ts +41 -0
  65. package/src/ui/headless/communities/useCommunityCalendar.ts +156 -0
  66. package/src/ui/headless/communities/useCommunityClassroom.ts +84 -0
  67. package/src/ui/headless/communities/useCommunityHome.ts +3 -0
  68. package/src/ui/headless/communities/useCommunityJoin.ts +73 -23
  69. package/src/ui/headless/communities/useCommunityMembership.ts +48 -2
  70. package/src/ui/headless/communities/useCommunityWiki.ts +266 -0
  71. package/src/ui/headless/community/communityPoll.ts +297 -0
  72. package/src/ui/headless/community/countries.ts +123 -0
  73. package/src/ui/headless/community/index.ts +81 -1
  74. package/src/ui/headless/community/linkPreview.ts +71 -0
  75. package/src/ui/headless/community/richLexical.ts +27 -2
  76. package/src/ui/headless/community/useCommunityAgent.ts +285 -0
  77. package/src/ui/headless/community/useCommunityMembers.ts +175 -0
  78. package/src/ui/headless/community/useCommunityModeration.ts +300 -0
  79. package/src/ui/headless/community/useCommunitySpaceFeed.ts +22 -4
  80. package/src/ui/headless/community/useCommunityThread.ts +16 -3
  81. package/src/ui/headless/community/useMentionComposer.ts +17 -9
  82. package/src/ui/headless/community/useRichMentionComposer.ts +21 -5
  83. package/src/ui/headless/downloads/index.ts +8 -0
  84. package/src/ui/headless/downloads/useDownloadPage.ts +134 -0
  85. package/src/ui/headless/index.ts +13 -0
  86. package/src/ui/headless/memberHome/index.ts +10 -0
  87. package/src/ui/headless/memberHome/memberHomeBar.ts +91 -0
  88. package/src/ui/headless/memberHome/useMemberHomeNav.ts +56 -18
  89. package/src/ui/headless/portal/index.ts +57 -0
  90. package/src/ui/headless/portal/usePortal.ts +274 -0
  91. package/src/ui/headless/portal/usePortalFiles.ts +68 -0
  92. package/src/ui/headless/portal/usePortalMessages.ts +189 -0
  93. package/src/ui/headless/portal/usePortalPreview.ts +142 -0
  94. package/src/ui/headless/siteApp/appBar.ts +102 -0
  95. package/src/ui/headless/siteApp/appHome.ts +344 -0
  96. package/src/ui/headless/siteApp/appPrompts.ts +229 -0
  97. package/src/ui/headless/siteApp/index.ts +58 -0
  98. package/src/ui/headless/siteApp/useAppHome.ts +210 -0
  99. package/src/ui/headless/siteApp/useAppInstallRequest.ts +16 -0
  100. package/src/ui/headless/work/index.ts +2 -0
  101. package/src/ui/headless/work/useWorkPortal.ts +37 -26
  102. package/src/ui/index.ts +11 -0
  103. package/src/ui/styled/AccountDashboard.tsx +712 -352
  104. package/src/ui/styled/AiAgentWidget.tsx +13 -1
  105. package/src/ui/styled/ChatRoom.tsx +126 -16
  106. package/src/ui/styled/Checkout.tsx +8 -0
  107. package/src/ui/styled/CheckoutConfirmation.tsx +8 -0
  108. package/src/ui/styled/CoachingConfirmation.tsx +8 -0
  109. package/src/ui/styled/CoachingDetail.tsx +2 -0
  110. package/src/ui/styled/CourseConfirmation.tsx +5 -0
  111. package/src/ui/styled/CourseDetail.tsx +2 -0
  112. package/src/ui/styled/DownloadPage.tsx +263 -0
  113. package/src/ui/styled/EventConfirmation.tsx +10 -0
  114. package/src/ui/styled/EventDetail.tsx +10 -0
  115. package/src/ui/styled/FilmLibrary.tsx +22 -9
  116. package/src/ui/styled/MusicLinkPage.tsx +5 -5
  117. package/src/ui/styled/ProductDetail.tsx +12 -0
  118. package/src/ui/styled/PwaRegistration.tsx +5 -1
  119. package/src/ui/styled/SignupForm.tsx +18 -3
  120. package/src/ui/styled/_tests/AccountDashboardBookingCall.spec.tsx +5 -5
  121. package/src/ui/styled/_tests/AccountNotifications.spec.tsx +135 -0
  122. package/src/ui/styled/_tests/DownloadPage.spec.tsx +68 -0
  123. package/src/ui/styled/app/AppBar.tsx +298 -0
  124. package/src/ui/styled/app/AppHome.tsx +1139 -0
  125. package/src/ui/styled/app/AppHomeMark.tsx +66 -0
  126. package/src/ui/styled/app/AppPrompts.tsx +464 -0
  127. package/src/ui/styled/app/_tests/AppBar.spec.tsx +96 -0
  128. package/src/ui/styled/app/_tests/AppHome.spec.tsx +209 -0
  129. package/src/ui/styled/app/_tests/AppPrompts.spec.tsx +232 -0
  130. package/src/ui/styled/app/index.ts +7 -0
  131. package/src/ui/styled/chat/ChatThreadPanel.tsx +29 -4
  132. package/src/ui/styled/chat/MessageBubble.tsx +43 -6
  133. package/src/ui/styled/communities/CommunityAbout.tsx +6 -1
  134. package/src/ui/styled/communities/CommunityCalendar.tsx +484 -0
  135. package/src/ui/styled/communities/CommunityClassroom.tsx +302 -0
  136. package/src/ui/styled/communities/CommunityHome.tsx +134 -11
  137. package/src/ui/styled/communities/CommunityJoinSheet.tsx +119 -19
  138. package/src/ui/styled/communities/CommunityMembershipMenu.tsx +168 -52
  139. package/src/ui/styled/communities/CommunityPublicWiki.tsx +75 -0
  140. package/src/ui/styled/communities/CommunityWiki.tsx +289 -0
  141. package/src/ui/styled/communities/MyMembershipsList.tsx +31 -5
  142. package/src/ui/styled/communities/_tests/CommunityAppHome.spec.tsx +92 -0
  143. package/src/ui/styled/communities/_tests/CommunityClassroomCalendar.spec.tsx +453 -0
  144. package/src/ui/styled/communities/_tests/CommunityMobile.spec.tsx +399 -0
  145. package/src/ui/styled/communities/_tests/CommunityWiki.spec.tsx +223 -0
  146. package/src/ui/styled/communities/index.ts +9 -0
  147. package/src/ui/styled/communities/shared.tsx +39 -11
  148. package/src/ui/styled/community/CommunityAgent.tsx +286 -0
  149. package/src/ui/styled/community/CommunityComposer.tsx +266 -15
  150. package/src/ui/styled/community/CommunityFeed.tsx +50 -1
  151. package/src/ui/styled/community/CommunityLinkPreview.tsx +159 -0
  152. package/src/ui/styled/community/CommunityMemberGlobe.tsx +171 -0
  153. package/src/ui/styled/community/CommunityMemberProfile.tsx +137 -4
  154. package/src/ui/styled/community/CommunityMembers.tsx +387 -0
  155. package/src/ui/styled/community/CommunityModeration.tsx +587 -0
  156. package/src/ui/styled/community/CommunityModerationState.tsx +127 -0
  157. package/src/ui/styled/community/CommunityModeratorMenu.tsx +317 -0
  158. package/src/ui/styled/community/CommunityNotifications.tsx +52 -6
  159. package/src/ui/styled/community/CommunityPollCard.tsx +250 -0
  160. package/src/ui/styled/community/CommunityPostCard.tsx +110 -34
  161. package/src/ui/styled/community/CommunityPostDetail.tsx +157 -71
  162. package/src/ui/styled/community/CommunityRichText.tsx +177 -32
  163. package/src/ui/styled/community/CommunitySpaces.tsx +49 -14
  164. package/src/ui/styled/community/_tests/CommunityAgent.spec.tsx +571 -0
  165. package/src/ui/styled/community/_tests/CommunityLinkPreview.spec.tsx +167 -0
  166. package/src/ui/styled/community/_tests/CommunityMembers.spec.tsx +137 -0
  167. package/src/ui/styled/community/_tests/CommunityModeration.spec.tsx +291 -0
  168. package/src/ui/styled/community/_tests/CommunityPoll.spec.tsx +386 -0
  169. package/src/ui/styled/community/index.ts +37 -2
  170. package/src/ui/styled/forge-utilities.css +234 -0
  171. package/src/ui/styled/members/CallRecordingActions.tsx +182 -0
  172. package/src/ui/styled/members/MemberCallsCalendar.tsx +13 -158
  173. package/src/ui/styled/members/MemberHomeLayout.tsx +295 -15
  174. package/src/ui/styled/members/MemberPostsFeed.tsx +3 -2
  175. package/src/ui/styled/members/index.ts +8 -0
  176. package/src/ui/styled/portal/PortalAccountSection.tsx +61 -0
  177. package/src/ui/styled/portal/PortalActivity.tsx +167 -0
  178. package/src/ui/styled/portal/PortalBilling.tsx +197 -0
  179. package/src/ui/styled/portal/PortalFiles.tsx +279 -0
  180. package/src/ui/styled/portal/PortalHome.tsx +401 -0
  181. package/src/ui/styled/portal/PortalMessages.tsx +300 -0
  182. package/src/ui/styled/portal/PortalPreviewBanner.tsx +75 -0
  183. package/src/ui/styled/portal/PortalProjects.tsx +407 -0
  184. package/src/ui/styled/portal/PortalShell.tsx +397 -0
  185. package/src/ui/styled/portal/_tests/PortalAppHome.spec.tsx +90 -0
  186. package/src/ui/styled/portal/_tests/PortalFiles.spec.tsx +159 -0
  187. package/src/ui/styled/portal/_tests/PortalHome.spec.tsx +148 -0
  188. package/src/ui/styled/portal/_tests/PortalMessages.spec.tsx +168 -0
  189. package/src/ui/styled/portal/_tests/PortalPreviewBanner.spec.tsx +132 -0
  190. package/src/ui/styled/portal/_tests/portalNav.spec.ts +123 -0
  191. package/src/ui/styled/portal/index.ts +13 -0
  192. package/src/ui/styled/portal/portalNav.ts +260 -0
  193. package/src/ui/styled/portal/shared.tsx +206 -0
  194. package/src/ui/styled/work/WorkInviteAccept.tsx +228 -168
  195. package/src/ui/styled/work/WorkPortalProjects.tsx +68 -120
  196. package/src/ui/styled/work/WorkProjectDocuments.tsx +99 -128
  197. package/src/ui/styled/work/WorkProjectInvoices.tsx +91 -86
  198. package/src/ui/styled/work/WorkProjectReport.tsx +11 -17
  199. package/src/ui/styled/work/WorkReportBody.tsx +223 -248
  200. package/src/ui/styled/work/WorkTaskAttachments.tsx +23 -29
  201. package/src/ui/styled/work/WorkTaskComments.tsx +75 -102
  202. package/src/ui/styled/work/WorkTaskDetail.tsx +48 -59
  203. package/src/ui/styled/work/WorkTokenReport.tsx +8 -16
  204. package/src/ui/styled/work/index.ts +1 -1
  205. package/src/utils/_tests/metaEvents.spec.ts +264 -0
  206. package/src/utils/landing.ts +19 -6
  207. package/src/utils/metaEvents.ts +302 -0
@@ -13,6 +13,7 @@ import { EventCountdown } from "./EventCountdown";
13
13
  import { EventWaitlist } from "./EventWaitlist";
14
14
  import { AddToCalendar } from "./AddToCalendar";
15
15
  import { PresaleCodeField } from "./PresaleCode";
16
+ import { useMetaViewContent } from "../analytics/useMetaEvents";
16
17
 
17
18
  export interface EventDetailProps {
18
19
  /** Event slug (resolves the event). */
@@ -67,6 +68,15 @@ export function EventDetail({
67
68
  // contains the tiers that code unlocked.
68
69
  const presale = usePresaleCode(slug, { initialEvent });
69
70
  const { event, isLoading } = presale;
71
+ useMetaViewContent(
72
+ event
73
+ ? {
74
+ id: event.id,
75
+ name: event.title,
76
+ value: event.tickets?.length ? Math.min(...event.tickets.map((ticket) => Number(ticket.price))) : undefined,
77
+ }
78
+ : null,
79
+ );
70
80
 
71
81
  if (isLoading) return <Loading fullPage />;
72
82
  if (!event) return <p>{tr("forge.event_detail.not_found")}</p>;
@@ -16,6 +16,11 @@ export interface FilmRentalListProps {
16
16
  basePath?: string;
17
17
  /** SPA navigation adapter. Defaults to a full-page visit. */
18
18
  navigate?: (href: string) => void;
19
+ /**
20
+ * `cards` (the default) boxes each rental. `rows` divides them with hairlines
21
+ * instead, the client portal's list style.
22
+ */
23
+ layout?: "cards" | "rows";
19
24
  className?: string;
20
25
  style?: CSSProperties;
21
26
  }
@@ -36,7 +41,7 @@ export type FilmLibraryProps = FilmRentalListProps;
36
41
  * that already read it (the dashboard does, to decide whether to draw the tab at
37
42
  * all) shares one request through react-query rather than making a second.
38
43
  */
39
- export function FilmRentalList({ basePath = "/i/films", navigate, className, style }: FilmRentalListProps) {
44
+ export function FilmRentalList({ basePath = "/i/films", navigate, layout = "cards", className, style }: FilmRentalListProps) {
40
45
  const t = useForgeT();
41
46
  const tokens = useThemeTokens();
42
47
  const { user, isInitialized } = usePublicAuth();
@@ -47,11 +52,12 @@ export function FilmRentalList({ basePath = "/i/films", navigate, className, sty
47
52
 
48
53
  const rentals = data?.data ?? [];
49
54
 
55
+ const rows = layout === "rows";
50
56
  const notice: CSSProperties = {
51
57
  padding: "28px 20px",
52
58
  borderRadius: tokens.cornerRadius,
53
- border: `1px solid ${tokens.border}`,
54
- background: tokens.surface,
59
+ border: `1px ${rows ? "dashed" : "solid"} ${tokens.border}`,
60
+ background: rows ? "transparent" : tokens.surface,
55
61
  color: tokens.muted,
56
62
  textAlign: "center",
57
63
  fontSize: 14,
@@ -63,7 +69,8 @@ export function FilmRentalList({ basePath = "/i/films", navigate, className, sty
63
69
  style={{
64
70
  display: "flex",
65
71
  flexDirection: "column",
66
- gap: 16,
72
+ gap: rows ? 0 : 16,
73
+ ...(rows && rentals.length > 0 ? { borderTop: `1px solid ${tokens.border}` } : {}),
67
74
  color: tokens.text,
68
75
  fontFamily: tokens.fontFamily,
69
76
  ...style,
@@ -92,7 +99,7 @@ export function FilmRentalList({ basePath = "/i/films", navigate, className, sty
92
99
  )}
93
100
 
94
101
  {rentals.map((rental) => (
95
- <RentalRow key={rental.id} rental={rental} t={t} basePath={basePath} go={go} />
102
+ <RentalRow key={rental.id} rental={rental} t={t} basePath={basePath} go={go} rows={rows} />
96
103
  ))}
97
104
  </div>
98
105
  );
@@ -161,11 +168,13 @@ function RentalRow({
161
168
  t,
162
169
  basePath,
163
170
  go,
171
+ rows,
164
172
  }: {
165
173
  rental: MyFilmRental;
166
174
  t: ForgeT;
167
175
  basePath: string;
168
176
  go: (href: string) => void;
177
+ rows?: boolean;
169
178
  }) {
170
179
  const tokens = useThemeTokens();
171
180
  const remaining = splitRemainingMs(rental.msRemaining);
@@ -195,10 +204,14 @@ function RentalRow({
195
204
  gap: 14,
196
205
  alignItems: "center",
197
206
  flexWrap: "wrap",
198
- padding: 14,
199
- borderRadius: tokens.cornerRadius,
200
- border: `1px solid ${tokens.border}`,
201
- background: tokens.surface,
207
+ ...(rows
208
+ ? { padding: "16px 0", borderBottom: `1px solid ${tokens.border}` }
209
+ : {
210
+ padding: 14,
211
+ borderRadius: tokens.cornerRadius,
212
+ border: `1px solid ${tokens.border}`,
213
+ background: tokens.surface,
214
+ }),
202
215
  opacity: rental.isLive ? 1 : 0.85,
203
216
  }}
204
217
  >
@@ -214,13 +214,13 @@ export function MusicLinkPage({
214
214
  const destinations = useMemo(() => link?.destinations ?? [], [link]);
215
215
 
216
216
  const onDestinationClick = (platform: string, url: string) => {
217
- // ONE id, shared by the browser pixel event and the server-side CAPI twin
218
- // that `maybeSendPageCapi` emits for this click. Meta deduplicates on
219
- // (event_id, event_name), so without a shared id the same tap is counted as
220
- // two conversions and the campaign optimises against inflated numbers.
217
+ // ONE id, the click's own, shared by the campaign pixel's Lead, its server
218
+ // copy and the first-party click. Meta deduplicates on (event_id,
219
+ // event_name), so without a shared id the same tap is counted as two
220
+ // conversions and the campaign optimises against inflated numbers.
221
221
  const eventId = newEventId();
222
222
 
223
- fire("Lead", { content_name: serviceMeta(platform).label, content_category: "music_link" });
223
+ fire("Lead", { content_name: serviceMeta(platform).label, content_category: "music_link" }, eventId);
224
224
 
225
225
  trackBeacon("click", {
226
226
  pathname: typeof window !== "undefined" ? window.location.pathname : undefined,
@@ -16,6 +16,7 @@ import { usePricesIncludeTax } from "../../data/queries/useWebsite";
16
16
  import { Button } from "./Button";
17
17
  import { Loading } from "./Loading";
18
18
  import { ReviewsSection } from "./ReviewsSection";
19
+ import { useMetaViewContent } from "../analytics/useMetaEvents";
19
20
 
20
21
  export interface ProductDetailProps {
21
22
  /** Product slug (resolves the product). */
@@ -68,6 +69,11 @@ export function ProductDetail({
68
69
  const tr = useForgeT();
69
70
  const { data: product, isLoading } = useGetProduct(slug, { initialData: initialProduct });
70
71
  const fmt = useAmountFormatter(formatAmount);
72
+ useMetaViewContent(
73
+ product
74
+ ? { id: product.id, name: product.title, value: lowestPrice(product.variants?.map((v) => v.price)) }
75
+ : null,
76
+ );
71
77
 
72
78
  if (isLoading) return <Loading fullPage />;
73
79
  if (!product) return <p style={{ color: t.text }}>{tr("forge.product_detail.not_found")}</p>;
@@ -101,6 +107,12 @@ export function ProductDetail({
101
107
  );
102
108
  }
103
109
 
110
+ /** The lowest numeric price, or undefined when none is a number. */
111
+ function lowestPrice(prices: (number | string | null | undefined)[] | undefined): number | undefined {
112
+ const numbers = (prices ?? []).map((p) => Number(p)).filter((n) => Number.isFinite(n));
113
+ return numbers.length ? Math.min(...numbers) : undefined;
114
+ }
115
+
104
116
  // ── Rich description (responsive media) ───────────────────────────────────────
105
117
  const RICH_CSS =
106
118
  ".forge-rich{overflow-wrap:break-word;line-height:1.6}" +
@@ -1,4 +1,5 @@
1
1
  import { useEffect } from "react";
2
+ import { captureInstallPrompt } from "../../data/queries/usePWA";
2
3
 
3
4
  export interface PwaRegistrationProps {
4
5
  /**
@@ -17,7 +18,7 @@ export interface PwaRegistrationProps {
17
18
  * Registers the Forge service worker (`/sw.js`) on the published site. Renders
18
19
  * nothing. The SW source lives in `@tribe-nest/forge/server`
19
20
  * (`forgeServiceWorkerScript()`) and is served by the starter's `/sw.js` route,
20
- * so a Forge version bump propagates SW fixes to every deployed site — never
21
+ * so a Forge version bump propagates SW fixes to every deployed site, never
21
22
  * frozen into per-site files.
22
23
  *
23
24
  * Gating (locked decision): registration is skipped unless `enabled` is true,
@@ -28,6 +29,9 @@ export interface PwaRegistrationProps {
28
29
  export function PwaRegistration({ enabled = false, swUrl = "/sw.js" }: PwaRegistrationProps) {
29
30
  useEffect(() => {
30
31
  if (!enabled) return;
32
+ // Hold the browser's one install prompt from the first page, so an app
33
+ // prompt shown later (after joining, after a purchase) can still use it.
34
+ captureInstallPrompt();
31
35
  if (typeof navigator === "undefined" || !("serviceWorker" in navigator)) return;
32
36
  let cancelled = false;
33
37
  const register = () => {
@@ -18,13 +18,22 @@ export interface SignupFormProps {
18
18
  /** The membership invite token riding on the same redirect, if any. See `MembershipTierCallout`. */
19
19
  membershipInviteToken?: string;
20
20
  couponCode?: string;
21
+ /** Start with this email filled in (a client-portal invite's address, for one). */
22
+ defaultEmail?: string;
21
23
  }
22
24
 
23
25
  /** Themed account signup form, built on `useSignupForm`. */
24
- export function SignupForm({ onSuccess, loginHref, membershipTierId, membershipInviteToken, couponCode }: SignupFormProps) {
26
+ export function SignupForm({
27
+ onSuccess,
28
+ loginHref,
29
+ membershipTierId,
30
+ membershipInviteToken,
31
+ couponCode,
32
+ defaultEmail,
33
+ }: SignupFormProps) {
25
34
  const t = useForgeT();
26
35
  const theme = useForgeTheme();
27
- const form = useSignupForm({ onSuccess, membershipTierId, couponCode });
36
+ const form = useSignupForm({ onSuccess, membershipTierId, couponCode, defaultEmail });
28
37
 
29
38
  // One key for the whole sentence, split on its own `{email}` slot so the
30
39
  // address keeps its <strong> without the sentence being assembled from two
@@ -104,6 +113,7 @@ export function SignupForm({ onSuccess, loginHref, membershipTierId, membershipI
104
113
  value={form.code}
105
114
  onChange={(e) => form.setCode(e.target.value)}
106
115
  style={input}
116
+ data-testid="signup-code"
107
117
  placeholder="123456"
108
118
  />,
109
119
  )}
@@ -117,6 +127,7 @@ export function SignupForm({ onSuccess, loginHref, membershipTierId, membershipI
117
127
  value={form.firstName}
118
128
  onChange={(e) => form.setFirstName(e.target.value)}
119
129
  style={input}
130
+ data-testid="signup-first-name"
120
131
  placeholder={t("forge.signup_form.first_name_placeholder")}
121
132
  />,
122
133
  )}
@@ -126,6 +137,7 @@ export function SignupForm({ onSuccess, loginHref, membershipTierId, membershipI
126
137
  value={form.lastName}
127
138
  onChange={(e) => form.setLastName(e.target.value)}
128
139
  style={input}
140
+ data-testid="signup-last-name"
129
141
  placeholder={t("forge.signup_form.last_name_placeholder")}
130
142
  />,
131
143
  )}
@@ -137,6 +149,7 @@ export function SignupForm({ onSuccess, loginHref, membershipTierId, membershipI
137
149
  value={form.email}
138
150
  onChange={(e) => form.setEmail(e.target.value)}
139
151
  style={input}
152
+ data-testid="signup-email"
140
153
  placeholder={t("forge.signup_form.email_placeholder")}
141
154
  />,
142
155
  )}
@@ -147,6 +160,7 @@ export function SignupForm({ onSuccess, loginHref, membershipTierId, membershipI
147
160
  value={form.password}
148
161
  onChange={(e) => form.setPassword(e.target.value)}
149
162
  style={input}
163
+ data-testid="signup-password"
150
164
  placeholder={t("forge.signup_form.password_placeholder")}
151
165
  />,
152
166
  )}
@@ -155,13 +169,14 @@ export function SignupForm({ onSuccess, loginHref, membershipTierId, membershipI
155
169
  type="checkbox"
156
170
  checked={form.acceptedTerms}
157
171
  onChange={(e) => form.setAcceptedTerms(e.target.checked)}
172
+ data-testid="signup-accept-terms"
158
173
  style={{ accentColor: theme.colors.primary }}
159
174
  />
160
175
  {t("forge.signup_form.accept_terms")}
161
176
  </label>
162
177
  </>
163
178
  )}
164
- <button type="submit" disabled={form.isSubmitting} style={button}>
179
+ <button type="submit" disabled={form.isSubmitting} style={button} data-testid="signup-submit">
165
180
  {form.isSubmitting
166
181
  ? t("forge.signup_form.submitting")
167
182
  : form.awaitingCode
@@ -90,11 +90,11 @@ const booking = (overrides: Partial<MyBooking> = {}): MyBooking => {
90
90
 
91
91
  function render(rows: MyBooking[]): string {
92
92
  const queryClient = new QueryClient({ defaultOptions: { queries: { retry: false } } });
93
- queryClient.setQueryData(["my-bookings", ACCOUNT_ID, PROFILE_ID, 1, 20], {
94
- data: rows,
95
- total: rows.length,
96
- page: 1,
97
- limit: 20,
93
+ // The list loads a page at a time (`useMyBookingsPaged`), so the cache holds
94
+ // infinite-query data: one page here.
95
+ queryClient.setQueryData(["my-bookings", ACCOUNT_ID, PROFILE_ID, "paged", 20], {
96
+ pages: [{ data: rows, total: rows.length, page: 1, limit: 20 }],
97
+ pageParams: [1],
98
98
  });
99
99
 
100
100
  return renderToStaticMarkup(
@@ -0,0 +1,135 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import { renderToStaticMarkup } from "react-dom/server";
3
+ import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
4
+ import { ForgeClientProvider } from "../../../provider/ForgeProvider";
5
+ import { PublicAuthContext } from "../../../contexts/PublicAuthContext";
6
+ import { ForgeThemeProvider } from "../../theme/ForgeThemeProvider";
7
+ import type { NotificationMatrix } from "../../../data/queries/useNotifications";
8
+ import { AccountSection } from "../AccountDashboard";
9
+
10
+ /**
11
+ * The notification settings, drawn from the server's matrix.
12
+ *
13
+ * The panel this replaced sent `{ newPosts: false }`, which the server dropped,
14
+ * and read `newPosts` back, which the server never sends: every switch looked
15
+ * on and nothing ever saved. These pin the two things that made it wrong (the
16
+ * keys it reads and writes are the server's `"<type>.<channel>"` keys) and the
17
+ * rule that only a channel a type can use is offered at all.
18
+ *
19
+ * The matrix is SEEDED into the query cache under `useNotificationMatrix`'s own
20
+ * key, so a rename of that key fails here.
21
+ */
22
+
23
+ const PROFILE_ID = "profile-1";
24
+
25
+ const member = {
26
+ id: "account-1",
27
+ email: "fan@example.com",
28
+ firstName: "Fan",
29
+ lastName: "Person",
30
+ kind: "fan",
31
+ status: "active",
32
+ createdAt: "2026-01-01T00:00:00.000Z",
33
+ updatedAt: "2026-01-01T00:00:00.000Z",
34
+ membership: null,
35
+ };
36
+
37
+ // The server's defaults, in the shape GET /public/notifications/preferences returns.
38
+ const defaults: NotificationMatrix["defaults"] = {
39
+ dm: { inapp: true, push: true, email: true, emailMode: "immediate" },
40
+ chat_message: { inapp: false, push: true, email: false, emailMode: "none" },
41
+ mention: { inapp: true, push: true, email: true, emailMode: "immediate" },
42
+ reply: { inapp: true, push: true, email: true, emailMode: "digest" },
43
+ reaction: { inapp: true, push: false, email: true, emailMode: "digest" },
44
+ new_community_post: { inapp: true, push: false, email: true, emailMode: "digest" },
45
+ new_post: { inapp: true, push: true, email: true, emailMode: "digest" },
46
+ event_reminder: { inapp: true, push: true, email: false, emailMode: "none" },
47
+ stream_live: { inapp: true, push: true, email: false, emailMode: "none" },
48
+ mod: { inapp: true, push: false, email: true, emailMode: "digest" },
49
+ task_comment: { inapp: true, push: true, email: false, emailMode: "none" },
50
+ };
51
+
52
+ function resolved(overrides: Record<string, boolean>): Record<string, boolean> {
53
+ const out: Record<string, boolean> = {};
54
+ for (const [type, def] of Object.entries(defaults)) {
55
+ for (const channel of ["inapp", "push", "email"] as const) {
56
+ const key = `${type}.${channel}`;
57
+ out[key] = key in overrides ? overrides[key]! : def[channel];
58
+ }
59
+ }
60
+ return out;
61
+ }
62
+
63
+ function render(overrides: Record<string, boolean> = {}, digestCadence: NotificationMatrix["digestCadence"] = "daily") {
64
+ const queryClient = new QueryClient({ defaultOptions: { queries: { retry: false } } });
65
+ const matrix: NotificationMatrix = {
66
+ id: "pref-1",
67
+ accountId: member.id,
68
+ profileId: PROFILE_ID,
69
+ digestCadence,
70
+ preferences: resolved(overrides),
71
+ overrides,
72
+ defaults,
73
+ };
74
+ queryClient.setQueryData(["public-notification-preferences", PROFILE_ID], matrix);
75
+ return renderToStaticMarkup(
76
+ <QueryClientProvider client={queryClient}>
77
+ <ForgeClientProvider apiUrl="http://api.test" profileId={PROFILE_ID}>
78
+ <PublicAuthContext.Provider
79
+ value={{ user: member, currencies: null, userSelectedCurrency: "USD", logout: () => {} } as never}
80
+ >
81
+ <ForgeThemeProvider
82
+ theme={{ colors: { text: "#111111", background: "#ffffff", primary: "#6d28d9" }, cornerRadius: 8 }}
83
+ >
84
+ <AccountSection section="notifications" />
85
+ </ForgeThemeProvider>
86
+ </PublicAuthContext.Provider>
87
+ </ForgeClientProvider>
88
+ </QueryClientProvider>,
89
+ );
90
+ }
91
+
92
+ const pressed = (html: string, key: string) => {
93
+ const match = html.match(new RegExp(`data-testid="notify-${key.replace(".", "\\.")}" aria-pressed="(true|false)"`));
94
+ return match ? match[1] === "true" : null;
95
+ };
96
+
97
+ describe("Account notification settings", () => {
98
+ it("groups the member's notifications and leaves out work notifications, which never reach them", () => {
99
+ const html = render();
100
+ expect(html).toContain("Messages");
101
+ expect(html).toContain("Community");
102
+ expect(html).toContain("Events and live");
103
+ expect(html).toContain('data-testid="notify-row-dm"');
104
+ expect(html).not.toContain('data-testid="notify-row-task_comment"');
105
+ });
106
+
107
+ it("offers only the channels a type can use", () => {
108
+ const html = render();
109
+ // A chat message writes no in-app row and never emails: push only.
110
+ expect(html).toContain('data-testid="notify-chat_message.push"');
111
+ expect(html).not.toContain('data-testid="notify-chat_message.inapp"');
112
+ expect(html).not.toContain('data-testid="notify-chat_message.email"');
113
+ // Reminders and "live now" never email.
114
+ expect(html).not.toContain('data-testid="notify-event_reminder.email"');
115
+ expect(html).not.toContain('data-testid="notify-stream_live.email"');
116
+ // A direct message can go anywhere.
117
+ for (const channel of ["inapp", "push", "email"]) {
118
+ expect(html).toContain(`data-testid="notify-dm.${channel}"`);
119
+ }
120
+ });
121
+
122
+ it("shows the server's resolved state, including an opt-out the member saved", () => {
123
+ const html = render({ "new_post.email": false, "reaction.push": true });
124
+ expect(pressed(html, "new_post.email")).toBe(false);
125
+ expect(pressed(html, "new_post.push")).toBe(true);
126
+ // Off by default, on because the member turned it on.
127
+ expect(pressed(html, "reaction.push")).toBe(true);
128
+ });
129
+
130
+ it("marks the member's email summary choice", () => {
131
+ const html = render({}, "hourly");
132
+ expect(html).toMatch(/data-testid="notify-digest-hourly"[^>]*aria-checked="true"|aria-checked="true"[^>]*data-testid="notify-digest-hourly"/);
133
+ expect(html).toMatch(/data-testid="notify-digest-daily"[^>]*aria-checked="false"|aria-checked="false"[^>]*data-testid="notify-digest-daily"/);
134
+ });
135
+ });
@@ -0,0 +1,68 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import { renderToStaticMarkup } from "react-dom/server";
3
+ import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
4
+ import { ForgeClientProvider } from "../../../provider/ForgeProvider";
5
+ import { PublicAuthContext } from "../../../contexts/PublicAuthContext";
6
+ import { ForgeThemeProvider } from "../../theme/ForgeThemeProvider";
7
+ import type { DownloadPageInfo } from "../../headless/downloads/useDownloadPage";
8
+ import { DownloadPage } from "../DownloadPage";
9
+
10
+ /**
11
+ * The download page, rendered through `react-dom/server` with the page read
12
+ * SEEDED into the query cache so the real `useDownloadPage` stays in the path.
13
+ */
14
+
15
+ const PROFILE_ID = "profile-1";
16
+ const TOKEN = "tok_abcdefghijklmnopqrstuvwxyz0123456789ABCDEFG";
17
+
18
+ function render(info: DownloadPageInfo | undefined, user: { id: string } | null = null) {
19
+ const queryClient = new QueryClient({ defaultOptions: { queries: { retry: false } } });
20
+ if (info) queryClient.setQueryData(["download-page", PROFILE_ID, TOKEN, user?.id ?? null], info);
21
+ return renderToStaticMarkup(
22
+ <QueryClientProvider client={queryClient}>
23
+ <ForgeClientProvider apiUrl="http://api.test" profileId={PROFILE_ID}>
24
+ <PublicAuthContext.Provider value={{ user, currencies: null, userSelectedCurrency: "USD", logout: () => {} } as never}>
25
+ <ForgeThemeProvider theme={{ colors: { text: "#111111", background: "#ffffff", primary: "#6d28d9" }, cornerRadius: 8 }}>
26
+ <DownloadPage token={TOKEN} />
27
+ </ForgeThemeProvider>
28
+ </PublicAuthContext.Provider>
29
+ </ForgeClientProvider>
30
+ </QueryClientProvider>,
31
+ );
32
+ }
33
+
34
+ const info: DownloadPageInfo = {
35
+ items: [{ title: "Night Drive", quantity: 1, coverImage: "https://cdn.test/cover.jpg" }],
36
+ files: [
37
+ { id: "archive", filename: "order-1.zip", size: 5 * 1024 * 1024 },
38
+ { id: "file-0", filename: "Master.wav", size: 700 * 1024 * 1024 },
39
+ ],
40
+ sentTo: "b***@example.com",
41
+ isGift: false,
42
+ signedInAsOwner: false,
43
+ };
44
+
45
+ describe("DownloadPage", () => {
46
+ it("names what was bought and every file, locked, and asks for a code sent to the recipient", () => {
47
+ const html = render(info);
48
+ expect(html).toContain("Night Drive");
49
+ expect(html).toContain("order-1.zip");
50
+ expect(html).toContain("5.0 MB");
51
+ expect(html).toContain("Master.wav");
52
+ expect(html).toContain('data-testid="download-gate"');
53
+ expect(html).toContain("We&#x27;ll email a 6-digit code to b***@example.com.");
54
+ expect(html).toContain("Email me a code");
55
+ // No download button and no address before the person proves who they are.
56
+ expect(html).not.toContain('data-testid="download-file-button"');
57
+ expect(html).not.toContain("http://api.test");
58
+ });
59
+
60
+ it("offers signing in, and brings the person back to this page", () => {
61
+ const html = render(info);
62
+ expect(html).toContain(`href="/i/login?redirect=${encodeURIComponent(`/i/downloads/${TOKEN}`)}"`);
63
+ });
64
+
65
+ it("says a gift is a gift", () => {
66
+ expect(render({ ...info, isGift: true })).toContain("A gift for you.");
67
+ });
68
+ });