create-ailk 0.39.0 → 0.40.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.
- package/dist/add-route.js +15 -0
- package/dist/body-heading.d.ts +2 -1
- package/dist/body-heading.js +31 -3
- package/dist/module-architecture.js +0 -3
- package/dist/remove-module.js +13 -4
- package/dist/routes.d.ts +7 -0
- package/dist/routes.js +1 -1
- package/dist/site-roster.js +7 -1
- package/dist/surfaces.d.ts +2 -0
- package/dist/surfaces.js +59 -172
- package/package.json +3 -3
- package/templates/apps/web/CLAUDE.md +7 -1
- package/templates/apps/web/__tests__/__mocks__/next-intl-server.ts +3 -2
- package/templates/apps/web/__tests__/__mocks__/next-intl.ts +3 -2
- package/templates/apps/web/app/[locale]/layout.tsx +1 -1
- package/templates/apps/web/i18n/request.ts +5 -1
- package/templates/apps/web/jest.config.cjs +6 -0
- package/templates/apps/web/lib/__tests__/deck-page.test.ts +9 -0
- package/templates/apps/web/lib/__tests__/in-page-magnet-self-request.test.ts +1 -1
- package/templates/apps/web/lib/__tests__/in-page-magnet.test.ts +2 -2
- package/templates/apps/web/lib/__tests__/pricing-page.test.ts +1 -1
- package/templates/apps/web/lib/__tests__/structured-data.test.tsx +17 -4
- package/templates/apps/web/lib/in-page-magnet.ts +2 -2
- package/templates/apps/web/lib/pricing-page.ts +3 -3
- package/templates/apps/web/{app/[locale]/contact → lib}/site-contact-email.ts +1 -1
- package/templates/apps/web/{app/[locale]/contact → lib}/site-contact-lines.ts +1 -1
- package/templates/apps/web/lib/site-header.ts +1 -1
- package/templates/apps/web/messages/en.json +0 -119
- package/templates/apps/web/next.config.mjs +7 -0
- package/templates/apps/web/package.json +1 -0
- package/templates/apps/web/site-pages.config.tsx +85 -0
- package/templates/tools/body-heading.ts +30 -3
- package/versions.json +50 -49
- package/templates/apps/web/app/[locale]/(authed)/leads/__tests__/page.test.tsx +0 -205
- package/templates/apps/web/app/[locale]/(authed)/leads/components/LeadsTable.tsx +0 -137
- package/templates/apps/web/app/[locale]/(authed)/leads/page.tsx +0 -122
- package/templates/apps/web/app/[locale]/(authed)/waitlist/components/ForbiddenState.tsx +0 -24
- package/templates/apps/web/app/[locale]/(authed)/waitlist/format.ts +0 -111
- package/templates/apps/web/app/[locale]/[slug]/[detail]/__tests__/page.test.tsx +0 -402
- package/templates/apps/web/app/[locale]/[slug]/[detail]/page.tsx +0 -143
- package/templates/apps/web/app/[locale]/[slug]/__tests__/page.test.tsx +0 -148
- package/templates/apps/web/app/[locale]/[slug]/page.tsx +0 -109
- package/templates/apps/web/app/[locale]/about/[slug]/page.tsx +0 -46
- package/templates/apps/web/app/[locale]/about/__tests__/about-routes.test.tsx +0 -353
- package/templates/apps/web/app/[locale]/about/page.tsx +0 -122
- package/templates/apps/web/app/[locale]/alternatives/__tests__/page.test.tsx +0 -161
- package/templates/apps/web/app/[locale]/alternatives/page.tsx +0 -112
- package/templates/apps/web/app/[locale]/careers/[slug]/[action]/page.tsx +0 -244
- package/templates/apps/web/app/[locale]/careers/[slug]/apply.actions.ts +0 -325
- package/templates/apps/web/app/[locale]/careers/[slug]/job-application-form.ts +0 -120
- package/templates/apps/web/app/[locale]/careers/[slug]/page.tsx +0 -73
- package/templates/apps/web/app/[locale]/careers/__tests__/apply.actions.test.ts +0 -497
- package/templates/apps/web/app/[locale]/careers/__tests__/careers-hub.test.tsx +0 -172
- package/templates/apps/web/app/[locale]/careers/__tests__/careers-set.test.tsx +0 -153
- package/templates/apps/web/app/[locale]/careers/__tests__/job-application-form.test.ts +0 -141
- package/templates/apps/web/app/[locale]/careers/__tests__/job-apply-page.test.tsx +0 -546
- package/templates/apps/web/app/[locale]/careers/__tests__/page-renderer-migration.test.tsx +0 -189
- package/templates/apps/web/app/[locale]/careers/page.tsx +0 -165
- package/templates/apps/web/app/[locale]/case-studies/[slug]/page.tsx +0 -49
- package/templates/apps/web/app/[locale]/case-studies/__tests__/hub-children.test.tsx +0 -65
- package/templates/apps/web/app/[locale]/case-studies/__tests__/page-renderer-migration.test.tsx +0 -125
- package/templates/apps/web/app/[locale]/case-studies/page.tsx +0 -49
- package/templates/apps/web/app/[locale]/clients/__tests__/page-renderer-migration.test.tsx +0 -85
- package/templates/apps/web/app/[locale]/clients/page.tsx +0 -47
- package/templates/apps/web/app/[locale]/contact/ConversationalIntakeWrapper.tsx +0 -249
- package/templates/apps/web/app/[locale]/contact/__tests__/ConversationalIntakeWrapper.test.tsx +0 -400
- package/templates/apps/web/app/[locale]/contact/__tests__/contact-form-magnet.test.ts +0 -138
- package/templates/apps/web/app/[locale]/contact/__tests__/contact-form-text.test.ts +0 -49
- package/templates/apps/web/app/[locale]/contact/__tests__/contact-magnet-page.test.tsx +0 -494
- package/templates/apps/web/app/[locale]/contact/__tests__/contact.actions.test.ts +0 -1122
- package/templates/apps/web/app/[locale]/contact/__tests__/intake-analytics.test.ts +0 -51
- package/templates/apps/web/app/[locale]/contact/__tests__/page-renderer-migration.test.tsx +0 -319
- package/templates/apps/web/app/[locale]/contact/contact-form-magnet.ts +0 -77
- package/templates/apps/web/app/[locale]/contact/contact-form-text.ts +0 -52
- package/templates/apps/web/app/[locale]/contact/contact.actions.ts +0 -403
- package/templates/apps/web/app/[locale]/contact/intake-analytics.ts +0 -49
- package/templates/apps/web/app/[locale]/contact/intake-script.ts +0 -92
- package/templates/apps/web/app/[locale]/contact/page.tsx +0 -267
- package/templates/apps/web/app/[locale]/courses/[slug]/page.tsx +0 -50
- package/templates/apps/web/app/[locale]/courses/__tests__/hub-children.test.tsx +0 -32
- package/templates/apps/web/app/[locale]/courses/__tests__/page-renderer-migration.test.tsx +0 -123
- package/templates/apps/web/app/[locale]/courses/page.tsx +0 -49
- package/templates/apps/web/app/[locale]/events/[slug]/page.tsx +0 -57
- package/templates/apps/web/app/[locale]/events/__tests__/hub-children.test.tsx +0 -32
- package/templates/apps/web/app/[locale]/events/__tests__/page-renderer-migration.test.tsx +0 -164
- package/templates/apps/web/app/[locale]/events/__tests__/program-event.test.tsx +0 -120
- package/templates/apps/web/app/[locale]/events/page.tsx +0 -60
- package/templates/apps/web/app/[locale]/faq/page.tsx +0 -54
- package/templates/apps/web/app/[locale]/features/[slug]/page.tsx +0 -54
- package/templates/apps/web/app/[locale]/features/__tests__/hub-children.test.tsx +0 -32
- package/templates/apps/web/app/[locale]/features/page.tsx +0 -50
- package/templates/apps/web/app/[locale]/for/[slug]/page.tsx +0 -54
- package/templates/apps/web/app/[locale]/for/__tests__/hub-children.test.tsx +0 -32
- package/templates/apps/web/app/[locale]/for/__tests__/page-renderer-migration.test.tsx +0 -90
- package/templates/apps/web/app/[locale]/for/page.tsx +0 -51
- package/templates/apps/web/app/[locale]/glossary/page.tsx +0 -53
- package/templates/apps/web/app/[locale]/how-to/[slug]/page.tsx +0 -50
- package/templates/apps/web/app/[locale]/how-to/__tests__/page-renderer-migration.test.tsx +0 -78
- package/templates/apps/web/app/[locale]/how-to/page.tsx +0 -50
- package/templates/apps/web/app/[locale]/integrations/[slug]/page.tsx +0 -54
- package/templates/apps/web/app/[locale]/integrations/__tests__/hub-children.test.tsx +0 -38
- package/templates/apps/web/app/[locale]/integrations/__tests__/page-renderer-migration.test.tsx +0 -141
- package/templates/apps/web/app/[locale]/integrations/page.tsx +0 -49
- package/templates/apps/web/app/[locale]/launch-service/page.tsx +0 -44
- package/templates/apps/web/app/[locale]/newsletter/__tests__/page.test.tsx +0 -236
- package/templates/apps/web/app/[locale]/newsletter/page.tsx +0 -179
- package/templates/apps/web/app/[locale]/page.tsx +0 -147
- package/templates/apps/web/app/[locale]/partners/[slug]/page.tsx +0 -45
- package/templates/apps/web/app/[locale]/partners/__tests__/hub-children.test.tsx +0 -32
- package/templates/apps/web/app/[locale]/partners/__tests__/page-renderer-migration.test.tsx +0 -125
- package/templates/apps/web/app/[locale]/partners/page.tsx +0 -49
- package/templates/apps/web/app/[locale]/portfolio/[slug]/page.tsx +0 -46
- package/templates/apps/web/app/[locale]/portfolio/__tests__/hub-children.test.tsx +0 -38
- package/templates/apps/web/app/[locale]/portfolio/page.tsx +0 -50
- package/templates/apps/web/app/[locale]/pricing/[slug]/__tests__/page.test.tsx +0 -324
- package/templates/apps/web/app/[locale]/pricing/[slug]/page.tsx +0 -87
- package/templates/apps/web/app/[locale]/pricing/__tests__/__snapshots__/unconnected.test.tsx.snap +0 -7
- package/templates/apps/web/app/[locale]/pricing/__tests__/offerings.test.tsx +0 -605
- package/templates/apps/web/app/[locale]/pricing/__tests__/page.test.tsx +0 -219
- package/templates/apps/web/app/[locale]/pricing/__tests__/pricing-pages.test.tsx +0 -215
- package/templates/apps/web/app/[locale]/pricing/__tests__/unconnected.test.tsx +0 -282
- package/templates/apps/web/app/[locale]/pricing/page.tsx +0 -120
- package/templates/apps/web/app/[locale]/privacy/page.tsx +0 -40
- package/templates/apps/web/app/[locale]/products/[slug]/page.tsx +0 -50
- package/templates/apps/web/app/[locale]/products/__tests__/hub-children.test.tsx +0 -32
- package/templates/apps/web/app/[locale]/products/__tests__/page-renderer-migration.test.tsx +0 -141
- package/templates/apps/web/app/[locale]/products/page.tsx +0 -49
- package/templates/apps/web/app/[locale]/projects/[slug]/page.tsx +0 -37
- package/templates/apps/web/app/[locale]/projects/__tests__/hub-children.test.tsx +0 -32
- package/templates/apps/web/app/[locale]/projects/__tests__/page-renderer-migration.test.tsx +0 -157
- package/templates/apps/web/app/[locale]/projects/page.tsx +0 -49
- package/templates/apps/web/app/[locale]/purchase-policy/page.tsx +0 -49
- package/templates/apps/web/app/[locale]/resources/[slug]/page.tsx +0 -54
- package/templates/apps/web/app/[locale]/resources/__tests__/hub-children.test.tsx +0 -38
- package/templates/apps/web/app/[locale]/resources/__tests__/page-renderer-migration.test.tsx +0 -151
- package/templates/apps/web/app/[locale]/resources/page.tsx +0 -49
- package/templates/apps/web/app/[locale]/services/[slug]/[child]/page.tsx +0 -68
- package/templates/apps/web/app/[locale]/services/[slug]/page.tsx +0 -88
- package/templates/apps/web/app/[locale]/services/__tests__/hub-children.test.tsx +0 -158
- package/templates/apps/web/app/[locale]/services/__tests__/page-renderer-migration.test.tsx +0 -187
- package/templates/apps/web/app/[locale]/services/__tests__/service-detail-sections.test.tsx +0 -224
- package/templates/apps/web/app/[locale]/services/__tests__/service-families.test.tsx +0 -368
- package/templates/apps/web/app/[locale]/services/page.tsx +0 -71
- package/templates/apps/web/app/[locale]/software/[slug]/page.tsx +0 -49
- package/templates/apps/web/app/[locale]/software/__tests__/page-renderer-migration.test.tsx +0 -81
- package/templates/apps/web/app/[locale]/software/page.tsx +0 -49
- package/templates/apps/web/app/[locale]/team/[slug]/page.tsx +0 -45
- package/templates/apps/web/app/[locale]/team/__tests__/hub-children.test.tsx +0 -32
- package/templates/apps/web/app/[locale]/team/__tests__/team-routes.test.tsx +0 -161
- package/templates/apps/web/app/[locale]/team/page.tsx +0 -50
- package/templates/apps/web/app/[locale]/tech-articles/[slug]/page.tsx +0 -54
- package/templates/apps/web/app/[locale]/tech-articles/__tests__/page-renderer-migration.test.tsx +0 -82
- package/templates/apps/web/app/[locale]/tech-articles/page.tsx +0 -49
- package/templates/apps/web/app/[locale]/templates/[slug]/__tests__/page.test.tsx +0 -203
- package/templates/apps/web/app/[locale]/templates/[slug]/page.tsx +0 -81
- package/templates/apps/web/app/[locale]/templates/__tests__/page.test.tsx +0 -237
- package/templates/apps/web/app/[locale]/templates/page.tsx +0 -114
- package/templates/apps/web/app/[locale]/terms/page.tsx +0 -40
- package/templates/apps/web/app/[locale]/testimonials/__tests__/page-renderer-migration.test.tsx +0 -85
- package/templates/apps/web/app/[locale]/testimonials/page.tsx +0 -51
- package/templates/apps/web/app/[locale]/thanks/[slug]/__tests__/page.test.tsx +0 -136
- package/templates/apps/web/app/[locale]/thanks/[slug]/page.tsx +0 -39
- package/templates/apps/web/app/[locale]/unsubscribe/__tests__/unsubscribe-rsc-boundary.test.tsx +0 -226
- package/templates/apps/web/app/[locale]/unsubscribe/__tests__/unsubscribe.test.tsx +0 -217
- package/templates/apps/web/app/[locale]/unsubscribe/page.tsx +0 -106
- package/templates/apps/web/app/[locale]/unsubscribe/unsubscribe-button.tsx +0 -94
- package/templates/apps/web/app/[locale]/unsubscribe/unsubscribe.actions.ts +0 -55
- package/templates/apps/web/app/[locale]/vs/[slug]/__tests__/page.test.tsx +0 -100
- package/templates/apps/web/app/[locale]/vs/[slug]/page.tsx +0 -60
- package/templates/apps/web/app/[locale]/whitepapers/[slug]/page.tsx +0 -54
- package/templates/apps/web/app/[locale]/whitepapers/__tests__/page-renderer-migration.test.tsx +0 -82
- package/templates/apps/web/app/[locale]/whitepapers/page.tsx +0 -49
- package/templates/apps/web/app/[locale]/working-agreement/__tests__/page.test.tsx +0 -63
- package/templates/apps/web/app/[locale]/working-agreement/page.tsx +0 -41
- package/templates/apps/web/lib/__tests__/hub-children.fixtures.ts +0 -279
- package/templates/apps/web/lib/__tests__/route-family.test.ts +0 -57
- package/templates/apps/web/lib/__tests__/service-listing.test.ts +0 -111
- package/templates/apps/web/lib/__tests__/template-listing.test.ts +0 -158
- package/templates/apps/web/lib/hub-children.tsx +0 -351
- package/templates/apps/web/lib/meet-placeholder.ts +0 -5
- package/templates/apps/web/lib/posting-title.ts +0 -39
- package/templates/apps/web/lib/route-family.ts +0 -69
- package/templates/apps/web/lib/service-listing.ts +0 -89
- package/templates/apps/web/lib/template-listing.ts +0 -169
- package/templates/apps/web/src/lib/__tests__/lead-write.test.ts +0 -187
- package/templates/apps/web/src/lib/lead-write.ts +0 -90
- /package/templates/apps/web/{app/[locale]/contact → lib}/__tests__/site-contact-lines.test.ts +0 -0
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
// About page. Reads the AboutPage MDX frontmatter, renders sections via
|
|
2
|
-
// SectionRenderer, and emits a JSON-LD <script>.
|
|
3
|
-
//
|
|
4
|
-
// #8650 D4 — `/about` additionally lists every `Person` page in the request's
|
|
5
|
-
// locale as one generated `team` section (the `/alternatives` `withSpokes`
|
|
6
|
-
// precedent, #6878 D9), each member linking to its own `/about/<slug>` page.
|
|
7
|
-
// With zero `Person` pages the parsed sections are returned unchanged, so a
|
|
8
|
-
// fresh scaffold (which seeds no `Person` file) renders exactly as before.
|
|
9
|
-
import type {
|
|
10
|
-
getMdxSlugs as defaultGetMdxSlugs,
|
|
11
|
-
getMdxSource as defaultGetMdxSource,
|
|
12
|
-
getPageSections as defaultGetPageSections} from "@working-theory/page-renderer";
|
|
13
|
-
import {
|
|
14
|
-
getMdxSlugs as loadMdxSlugs,
|
|
15
|
-
getMdxSource as loadMdxSource,
|
|
16
|
-
getPageSections as loadPageSections,
|
|
17
|
-
renderPage,
|
|
18
|
-
renderPageMetadata
|
|
19
|
-
} from "@working-theory/page-renderer";
|
|
20
|
-
import type { Metadata } from "next";
|
|
21
|
-
import { getTranslations } from "next-intl/server";
|
|
22
|
-
import type { ReactElement } from "react";
|
|
23
|
-
|
|
24
|
-
interface Props {
|
|
25
|
-
params: Promise<{ locale: string }>;
|
|
26
|
-
getMdxSource?: typeof defaultGetMdxSource;
|
|
27
|
-
getPageSections?: typeof defaultGetPageSections;
|
|
28
|
-
getMdxSlugs?: typeof defaultGetMdxSlugs;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
type Section = Awaited<ReturnType<typeof defaultGetPageSections>>[number];
|
|
32
|
-
|
|
33
|
-
export async function generateMetadata({
|
|
34
|
-
params,
|
|
35
|
-
}: Pick<Props, "params">): Promise<Metadata> {
|
|
36
|
-
const { locale } = await params;
|
|
37
|
-
return renderPageMetadata({ type: "AboutPage", slug: "about", locale });
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export default async function Page({
|
|
41
|
-
params,
|
|
42
|
-
getMdxSource,
|
|
43
|
-
getPageSections,
|
|
44
|
-
getMdxSlugs,
|
|
45
|
-
}: Props): Promise<ReactElement> {
|
|
46
|
-
const { locale } = await params;
|
|
47
|
-
const loadSections = getPageSections ?? loadPageSections;
|
|
48
|
-
const loadSlugs = getMdxSlugs ?? loadMdxSlugs;
|
|
49
|
-
const loadSource = getMdxSource ?? loadMdxSource;
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Append one generated `team` section listing every `Person` page (C3) —
|
|
53
|
-
* the same "the visible list and the sections that feed JSON-LD always
|
|
54
|
-
* agree" property `withSpokes` gives `/alternatives` (#6878 D9), since
|
|
55
|
-
* `renderPage` builds both the body and the JSON-LD from these sections.
|
|
56
|
-
* Returns `declared` unchanged whenever there is nothing to list, so a
|
|
57
|
-
* site with no `Person` page renders byte-identical to today (AC-4, C5).
|
|
58
|
-
*/
|
|
59
|
-
async function withPeople(frontmatter: unknown): Promise<Section[]> {
|
|
60
|
-
const declared = await loadSections(frontmatter);
|
|
61
|
-
const slugs = [...(await loadSlugs("Person", locale))].sort();
|
|
62
|
-
if (slugs.length === 0) return declared;
|
|
63
|
-
|
|
64
|
-
const t = await getTranslations({ locale, namespace: "about" });
|
|
65
|
-
const label = t("viewProfile");
|
|
66
|
-
|
|
67
|
-
const sources = await Promise.all(
|
|
68
|
-
slugs.map((slug) => loadSource("Person", slug, locale)),
|
|
69
|
-
);
|
|
70
|
-
|
|
71
|
-
const members = sources.flatMap((source, i) => {
|
|
72
|
-
if (source === null) return [];
|
|
73
|
-
const slug = slugs[i]!;
|
|
74
|
-
const fm = source.frontmatter as {
|
|
75
|
-
title: string;
|
|
76
|
-
description?: string;
|
|
77
|
-
image?: string;
|
|
78
|
-
schema?: { name?: string; jobTitle?: string };
|
|
79
|
-
};
|
|
80
|
-
const name =
|
|
81
|
-
typeof fm.schema?.name === "string" ? fm.schema.name : fm.title;
|
|
82
|
-
const role =
|
|
83
|
-
typeof fm.schema?.jobTitle === "string" ? fm.schema.jobTitle : "";
|
|
84
|
-
return [
|
|
85
|
-
{
|
|
86
|
-
name,
|
|
87
|
-
role,
|
|
88
|
-
...(typeof fm.description === "string" && {
|
|
89
|
-
bio: fm.description,
|
|
90
|
-
}),
|
|
91
|
-
...(typeof fm.image === "string" && {
|
|
92
|
-
avatar: { src: fm.image, alt: name },
|
|
93
|
-
}),
|
|
94
|
-
links: [{ type: "page" as const, url: `/about/${slug}`, label }],
|
|
95
|
-
},
|
|
96
|
-
];
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
if (members.length === 0) return declared;
|
|
100
|
-
|
|
101
|
-
const people: Section = {
|
|
102
|
-
type: "team" as const,
|
|
103
|
-
id: "people",
|
|
104
|
-
data: { variant: "with-large-images" as const, members },
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
const last = declared.at(-1);
|
|
108
|
-
if (last !== undefined && last.type === "cta") {
|
|
109
|
-
return [...declared.slice(0, -1), people, last];
|
|
110
|
-
}
|
|
111
|
-
return [...declared, people];
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
return renderPage({
|
|
115
|
-
type: "AboutPage",
|
|
116
|
-
slug: "about",
|
|
117
|
-
locale,
|
|
118
|
-
translationsNamespace: "about",
|
|
119
|
-
getPageSections: withPeople,
|
|
120
|
-
...(getMdxSource !== undefined && { getMdxSource }),
|
|
121
|
-
});
|
|
122
|
-
}
|
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tests for /alternatives (#6878 D9) — the ComparisonsList hub.
|
|
3
|
-
*
|
|
4
|
-
* `renderPage`/`renderPageMetadata`/`getMdxSlugs` are mocked at the
|
|
5
|
-
* `@working-theory/page-renderer` boundary so this suite can assert on the
|
|
6
|
-
* exact input `renderPage` receives — in particular the injected
|
|
7
|
-
* `getPageSections` override that appends the generated spoke list (AC-7:
|
|
8
|
-
* "the hub links each /vs spoke"). `getMdxSource` and `getPageSections`
|
|
9
|
-
* (the hub's own declared sections) are supplied per-call through the
|
|
10
|
-
* route's DI props, as every other page in this app does.
|
|
11
|
-
*/
|
|
12
|
-
// The mock return value is never rendered — every assertion below inspects
|
|
13
|
-
// `mockRenderPage.mock.calls` directly — so it carries no `ReactElement`
|
|
14
|
-
// cast; `renderPage`'s real return type is `Promise<ReactElement>` in
|
|
15
|
-
// production, unaffected by this mock's loose type here.
|
|
16
|
-
const mockRenderPage = jest.fn(async (..._args: unknown[]) => "<rendered/>");
|
|
17
|
-
const mockRenderPageMetadata = jest.fn((..._args: unknown[]) => undefined);
|
|
18
|
-
const mockGetMdxSlugs = jest.fn((..._args: unknown[]) => Promise.resolve<string[]>([]));
|
|
19
|
-
const mockNotFound = jest.fn(() => {
|
|
20
|
-
throw new Error("NEXT_NOT_FOUND");
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
jest.mock("next/navigation", () => ({
|
|
24
|
-
__esModule: true,
|
|
25
|
-
notFound: () => mockNotFound(),
|
|
26
|
-
}));
|
|
27
|
-
|
|
28
|
-
jest.mock("@working-theory/page-renderer", () => ({
|
|
29
|
-
__esModule: true,
|
|
30
|
-
getMdxSlugs: (...args: unknown[]) => mockGetMdxSlugs(...args),
|
|
31
|
-
renderPage: (...args: unknown[]) => mockRenderPage(...args),
|
|
32
|
-
renderPageMetadata: (...args: unknown[]) => mockRenderPageMetadata(...args),
|
|
33
|
-
// Never reached — every call in this suite passes both via DI props.
|
|
34
|
-
getMdxSource: jest.fn(),
|
|
35
|
-
getPageSections: jest.fn(),
|
|
36
|
-
}));
|
|
37
|
-
|
|
38
|
-
import AlternativesPage, { generateMetadata } from "../page";
|
|
39
|
-
|
|
40
|
-
const HUB_SOURCE = {
|
|
41
|
-
frontmatter: {
|
|
42
|
-
type: "ComparisonsList",
|
|
43
|
-
slug: "alternatives",
|
|
44
|
-
title: "Alternatives",
|
|
45
|
-
description: "How we compare.",
|
|
46
|
-
},
|
|
47
|
-
body: "",
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
beforeEach(() => jest.clearAllMocks());
|
|
51
|
-
|
|
52
|
-
describe("AlternativesPage — hub seed absent", () => {
|
|
53
|
-
it("calls notFound() and never reaches renderPage", async () => {
|
|
54
|
-
const getMdxSource = jest.fn().mockResolvedValue(null);
|
|
55
|
-
|
|
56
|
-
await expect(
|
|
57
|
-
AlternativesPage({
|
|
58
|
-
params: Promise.resolve({ locale: "en" }),
|
|
59
|
-
getMdxSource,
|
|
60
|
-
getPageSections: jest.fn(),
|
|
61
|
-
}),
|
|
62
|
-
).rejects.toThrow("NEXT_NOT_FOUND");
|
|
63
|
-
|
|
64
|
-
expect(mockNotFound).toHaveBeenCalledTimes(1);
|
|
65
|
-
expect(mockRenderPage).not.toHaveBeenCalled();
|
|
66
|
-
});
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
describe("AlternativesPage — metadata", () => {
|
|
70
|
-
it("resolves ComparisonsList slug alternatives", async () => {
|
|
71
|
-
await generateMetadata({ params: Promise.resolve({ locale: "en" }) });
|
|
72
|
-
expect(mockRenderPageMetadata).toHaveBeenCalledWith({
|
|
73
|
-
type: "ComparisonsList",
|
|
74
|
-
slug: "alternatives",
|
|
75
|
-
locale: "en",
|
|
76
|
-
});
|
|
77
|
-
});
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
describe("AlternativesPage — generated spoke list (D9)", () => {
|
|
81
|
-
it("appends one items section entry per ComparisonPage spoke, each linking /vs/<slug>", async () => {
|
|
82
|
-
mockGetMdxSlugs.mockResolvedValue(["acme", "globex"]);
|
|
83
|
-
const spokeSources: Record<string, unknown> = {
|
|
84
|
-
acme: {
|
|
85
|
-
frontmatter: { title: "vs. Acme", description: "How we compare to Acme." },
|
|
86
|
-
body: "",
|
|
87
|
-
},
|
|
88
|
-
globex: {
|
|
89
|
-
frontmatter: { title: "vs. Globex", description: "How we compare to Globex." },
|
|
90
|
-
body: "",
|
|
91
|
-
},
|
|
92
|
-
};
|
|
93
|
-
const getMdxSource = jest
|
|
94
|
-
.fn()
|
|
95
|
-
.mockImplementation((type: string, slug: string) => {
|
|
96
|
-
if (type === "ComparisonsList") return Promise.resolve(HUB_SOURCE);
|
|
97
|
-
return Promise.resolve(spokeSources[slug] ?? null);
|
|
98
|
-
});
|
|
99
|
-
const getPageSections = jest
|
|
100
|
-
.fn()
|
|
101
|
-
.mockResolvedValue([{ id: "hero", type: "hero", data: {} }]);
|
|
102
|
-
|
|
103
|
-
await AlternativesPage({
|
|
104
|
-
params: Promise.resolve({ locale: "en" }),
|
|
105
|
-
getMdxSource,
|
|
106
|
-
getPageSections,
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
expect(mockRenderPage).toHaveBeenCalledTimes(1);
|
|
110
|
-
const passedInput = mockRenderPage.mock.calls[0]?.[0] as {
|
|
111
|
-
type: string;
|
|
112
|
-
slug: string;
|
|
113
|
-
getPageSections: (frontmatter: unknown) => Promise<unknown[]>;
|
|
114
|
-
};
|
|
115
|
-
expect(passedInput.type).toBe("ComparisonsList");
|
|
116
|
-
expect(passedInput.slug).toBe("alternatives");
|
|
117
|
-
|
|
118
|
-
const sections = await passedInput.getPageSections({});
|
|
119
|
-
expect(sections).toEqual([
|
|
120
|
-
{ id: "hero", type: "hero", data: {} },
|
|
121
|
-
{
|
|
122
|
-
type: "items",
|
|
123
|
-
id: "comparison-spokes",
|
|
124
|
-
data: {
|
|
125
|
-
items: [
|
|
126
|
-
{
|
|
127
|
-
title: "vs. Acme",
|
|
128
|
-
description: "How we compare to Acme.",
|
|
129
|
-
link: { label: "Read the comparison", href: "/vs/acme" },
|
|
130
|
-
},
|
|
131
|
-
{
|
|
132
|
-
title: "vs. Globex",
|
|
133
|
-
description: "How we compare to Globex.",
|
|
134
|
-
link: { label: "Read the comparison", href: "/vs/globex" },
|
|
135
|
-
},
|
|
136
|
-
],
|
|
137
|
-
},
|
|
138
|
-
},
|
|
139
|
-
]);
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
it("omits the generated section entirely with zero spokes (the hub's own sections render alone)", async () => {
|
|
143
|
-
mockGetMdxSlugs.mockResolvedValue([]);
|
|
144
|
-
const getMdxSource = jest.fn().mockResolvedValue(HUB_SOURCE);
|
|
145
|
-
const getPageSections = jest
|
|
146
|
-
.fn()
|
|
147
|
-
.mockResolvedValue([{ id: "hero", type: "hero", data: {} }]);
|
|
148
|
-
|
|
149
|
-
await AlternativesPage({
|
|
150
|
-
params: Promise.resolve({ locale: "en" }),
|
|
151
|
-
getMdxSource,
|
|
152
|
-
getPageSections,
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
const passedInput = mockRenderPage.mock.calls[0]?.[0] as {
|
|
156
|
-
getPageSections: (frontmatter: unknown) => Promise<unknown[]>;
|
|
157
|
-
};
|
|
158
|
-
const sections = await passedInput.getPageSections({});
|
|
159
|
-
expect(sections).toEqual([{ id: "hero", type: "hero", data: {} }]);
|
|
160
|
-
});
|
|
161
|
-
});
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
// ComparisonsList hub (#6878 D9) — the /alternatives page. Reads
|
|
2
|
-
// ComparisonsList MDX via the content adapter, injects a generated `items`
|
|
3
|
-
// section listing every ComparisonPage spoke (so the visible card grid and
|
|
4
|
-
// the CollectionPage's ItemList JSON-LD — built from the same sections —
|
|
5
|
-
// always agree, D9), and emits via the dispatcher.
|
|
6
|
-
//
|
|
7
|
-
// notFound() when the hub seed is absent, so no empty hub is ever served
|
|
8
|
-
// (unlike the /for hub's empty-state branch): an add-page run always writes
|
|
9
|
-
// the seed alongside the first spoke (D11), so a fresh scaffold — which
|
|
10
|
-
// excludes this gated surface entirely — never reaches this branch in
|
|
11
|
-
// production, only a mis-authored site would.
|
|
12
|
-
//
|
|
13
|
-
// Gated off by default (surfaces.ts `alternatives` surface): no roster names
|
|
14
|
-
// this route, so a fresh scaffold excludes it.
|
|
15
|
-
import type {
|
|
16
|
-
getMdxSource as defaultGetMdxSource,
|
|
17
|
-
getPageSections as defaultGetPageSections,
|
|
18
|
-
} from "@working-theory/page-renderer";
|
|
19
|
-
import {
|
|
20
|
-
getMdxSlugs,
|
|
21
|
-
getMdxSource as loadMdxSource,
|
|
22
|
-
getPageSections as loadPageSections,
|
|
23
|
-
renderPage,
|
|
24
|
-
renderPageMetadata,
|
|
25
|
-
} from "@working-theory/page-renderer";
|
|
26
|
-
import type { Metadata } from "next";
|
|
27
|
-
import { notFound } from "next/navigation";
|
|
28
|
-
import type { ReactElement } from "react";
|
|
29
|
-
|
|
30
|
-
import { honourNavOnly } from "../../../lib/hub-children";
|
|
31
|
-
|
|
32
|
-
interface Props {
|
|
33
|
-
params: Promise<{ locale: string }>;
|
|
34
|
-
getMdxSource?: typeof defaultGetMdxSource;
|
|
35
|
-
getPageSections?: typeof defaultGetPageSections;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
type Section = Awaited<ReturnType<typeof defaultGetPageSections>>[number];
|
|
39
|
-
|
|
40
|
-
export async function generateMetadata({
|
|
41
|
-
params,
|
|
42
|
-
}: Pick<Props, "params">): Promise<Metadata> {
|
|
43
|
-
const { locale } = await params;
|
|
44
|
-
return renderPageMetadata({
|
|
45
|
-
type: "ComparisonsList",
|
|
46
|
-
slug: "alternatives",
|
|
47
|
-
locale,
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export default async function Page({
|
|
52
|
-
params,
|
|
53
|
-
getMdxSource,
|
|
54
|
-
getPageSections,
|
|
55
|
-
}: Props): Promise<ReactElement> {
|
|
56
|
-
const { locale } = await params;
|
|
57
|
-
const load = getMdxSource ?? loadMdxSource;
|
|
58
|
-
const loadSections = getPageSections ?? loadPageSections;
|
|
59
|
-
|
|
60
|
-
const source = await load("ComparisonsList", "alternatives", locale);
|
|
61
|
-
if (source === null) {
|
|
62
|
-
notFound();
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
const slugs = await getMdxSlugs("ComparisonPage", locale);
|
|
66
|
-
honourNavOnly(
|
|
67
|
-
source.frontmatter,
|
|
68
|
-
locale,
|
|
69
|
-
slugs.map((slug) => `/vs/${slug}`),
|
|
70
|
-
);
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Append one generated `items` section listing every ComparisonPage spoke
|
|
74
|
-
* — D9's "the visible list and the CollectionPage's ItemList always
|
|
75
|
-
* agree" property, since `renderPage` builds JSON-LD from these same
|
|
76
|
-
* sections. Absent when there are zero spokes: the hub still renders its
|
|
77
|
-
* own authored sections and answers 200 on its seed alone.
|
|
78
|
-
*/
|
|
79
|
-
async function withSpokes(frontmatter: unknown): Promise<Section[]> {
|
|
80
|
-
const declared = await loadSections(frontmatter);
|
|
81
|
-
if (slugs.length === 0) return declared;
|
|
82
|
-
|
|
83
|
-
const items = await Promise.all(
|
|
84
|
-
slugs.map(async (slug) => {
|
|
85
|
-
const spoke = await load("ComparisonPage", slug, locale);
|
|
86
|
-
const fm = (spoke?.frontmatter ?? {}) as {
|
|
87
|
-
title?: string;
|
|
88
|
-
description?: string;
|
|
89
|
-
};
|
|
90
|
-
return {
|
|
91
|
-
title: fm.title ?? slug,
|
|
92
|
-
description: fm.description ?? "",
|
|
93
|
-
link: { label: "Read the comparison", href: `/vs/${slug}` },
|
|
94
|
-
};
|
|
95
|
-
}),
|
|
96
|
-
);
|
|
97
|
-
|
|
98
|
-
return [
|
|
99
|
-
...declared,
|
|
100
|
-
{ type: "items" as const, id: "comparison-spokes", data: { items } },
|
|
101
|
-
];
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
return renderPage({
|
|
105
|
-
type: "ComparisonsList",
|
|
106
|
-
slug: "alternatives",
|
|
107
|
-
locale,
|
|
108
|
-
translationsNamespace: "alternatives",
|
|
109
|
-
getPageSections: withSpokes,
|
|
110
|
-
...(getMdxSource !== undefined && { getMdxSource }),
|
|
111
|
-
});
|
|
112
|
-
}
|
|
@@ -1,244 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* /[locale]/careers/[slug]/apply on a site without the `signal-collectors`
|
|
3
|
-
* module — the Free apply page (#8849 D7). Lead capture is never-gate, so a
|
|
4
|
-
* posting takes an application on every tier.
|
|
5
|
-
*
|
|
6
|
-
* Where the module is present, its static `careers/[slug]/apply/page.tsx`
|
|
7
|
-
* (#8840 D11, the multi-step walk) wins over this dynamic segment — the
|
|
8
|
-
* `[slug]/[detail]` idiom. Every `action` but `apply` is a 404, so
|
|
9
|
-
* `/careers/<slug>/<anything else>` 404s as before. Core, owned by no module:
|
|
10
|
-
* it imports no `flows/` or module file.
|
|
11
|
-
*
|
|
12
|
-
* The segments are checked before any read (SEC-8849-A): `action` must be
|
|
13
|
-
* `apply` and `slug` must match the apply action's own slug rule, then the
|
|
14
|
-
* posting must exist. The form is the posting page's former `#apply` section,
|
|
15
|
-
* moved without change in behaviour (#8746 D1, D5): the workspace's Job
|
|
16
|
-
* application magnet's field step from `flows.get("job-application")` (the
|
|
17
|
-
* public flow read), else the built-in form, as the shared `LeadCaptureForm`
|
|
18
|
-
* bound to the apply action with the posting's slug as the lead's hidden
|
|
19
|
-
* `job`. When the API says this deployment accepts no lead, the page shows the
|
|
20
|
-
* site's contact email instead. Its two hub reads (capture status, the magnet)
|
|
21
|
-
* are shared across requests for 15 seconds per server instance, as
|
|
22
|
-
* /contact's are (#8731). Full-screen (`isMagnetWalkPath` matches the path),
|
|
23
|
-
* so it draws its own back arrow, and `noindex, follow` like the walk.
|
|
24
|
-
*
|
|
25
|
-
* #10054 D4 — a posting may name its magnet (`applicationFlow`). The page
|
|
26
|
-
* reads it through the same shared read, keyed per flow (the keys are only
|
|
27
|
-
* slugs content names: the posting must exist before any read), and renders
|
|
28
|
-
* its step 1 when it maps; the submission then records the flow beside the
|
|
29
|
-
* posting (`apply.actions.ts` D6). A flow the hub answers absent — any non-ok
|
|
30
|
-
* answer below 500, as the walk's `readMagnet` reads it — or whose step 1
|
|
31
|
-
* does not map falls back to the Job application and is logged with the two
|
|
32
|
-
* slugs. A failed read (5xx, a throw) falls back silently, as a down hub
|
|
33
|
-
* always has.
|
|
34
|
-
*/
|
|
35
|
-
import { flows, leads } from "@working-theory/api-client";
|
|
36
|
-
import { flowRouteMetadata } from "@working-theory/metadata";
|
|
37
|
-
import {
|
|
38
|
-
ContactFallback,
|
|
39
|
-
Container,
|
|
40
|
-
Heading,
|
|
41
|
-
LeadCaptureForm,
|
|
42
|
-
localeHref,
|
|
43
|
-
} from "@working-theory/ui";
|
|
44
|
-
import { NavBackLink } from "@working-theory/ui/chrome";
|
|
45
|
-
import {
|
|
46
|
-
flowSlugSchema,
|
|
47
|
-
JOB_APPLICATION_FLOW_SLUG,
|
|
48
|
-
type FlowConfig,
|
|
49
|
-
} from "@working-theory/validation";
|
|
50
|
-
import type { Metadata } from "next";
|
|
51
|
-
import { notFound } from "next/navigation";
|
|
52
|
-
import { getTranslations } from "next-intl/server";
|
|
53
|
-
import type { ReactElement } from "react";
|
|
54
|
-
|
|
55
|
-
import { postingForApply, type ApplyPosting } from "../../../../../lib/posting-title";
|
|
56
|
-
import { contactFormText } from "../../../contact/contact-form-text";
|
|
57
|
-
import { readSiteContactEmail } from "../../../contact/site-contact-email";
|
|
58
|
-
import { captureLeadAction } from "../apply.actions";
|
|
59
|
-
import {
|
|
60
|
-
jobApplicationFormFallback,
|
|
61
|
-
jobApplicationFormFromConfig,
|
|
62
|
-
} from "../job-application-form";
|
|
63
|
-
|
|
64
|
-
// #8746 D5 — the page is rendered on every request.
|
|
65
|
-
export const dynamic = "force-dynamic";
|
|
66
|
-
|
|
67
|
-
interface Props {
|
|
68
|
-
params: Promise<{ locale: string; slug: string; action: string }>;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* `apply.actions.ts`'s slug rule, restated: a `"use server"` module may export
|
|
73
|
-
* only async functions.
|
|
74
|
-
*/
|
|
75
|
-
const POSTING_SLUG_RE = /^[a-z0-9][a-z0-9-]{0,127}$/;
|
|
76
|
-
|
|
77
|
-
/** How long the two hub reads are shared across requests (/contact's #8731 value). */
|
|
78
|
-
const HUB_READ_TTL_MS = 15_000;
|
|
79
|
-
|
|
80
|
-
const hubReads = new Map<string, { at: number; read: Promise<unknown> }>();
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* `read()`'s result, shared per instance for HUB_READ_TTL_MS; concurrent calls
|
|
84
|
-
* share one in-flight read, and a failed read (settled as its fallback) is
|
|
85
|
-
* shared the same way, so an unreachable hub is not retried per view.
|
|
86
|
-
*/
|
|
87
|
-
function sharedHubRead<T>(key: string, read: () => Promise<T>): Promise<T> {
|
|
88
|
-
const now = Date.now();
|
|
89
|
-
const hit = hubReads.get(key);
|
|
90
|
-
if (hit && now - hit.at < HUB_READ_TTL_MS) return hit.read as Promise<T>;
|
|
91
|
-
const fresh = read();
|
|
92
|
-
hubReads.set(key, { at: now, read: fresh });
|
|
93
|
-
return fresh;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
/** Whether the API accepts a lead; any failed read counts as accepting (as /contact). */
|
|
97
|
-
function readAccepting(): Promise<boolean> {
|
|
98
|
-
return sharedHubRead("capture-status", async () => {
|
|
99
|
-
try {
|
|
100
|
-
const res = await leads.captureStatus();
|
|
101
|
-
return res.ok && res.body.ok === true ? res.body.data.contact : true;
|
|
102
|
-
} catch {
|
|
103
|
-
return true;
|
|
104
|
-
}
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
type MagnetConfigRead =
|
|
109
|
-
| { kind: "ok"; config: FlowConfig }
|
|
110
|
-
| { kind: "absent" }
|
|
111
|
-
| { kind: "failed" };
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* A served magnet's config: `absent` for a non-ok answer below 500, `failed`
|
|
115
|
-
* for a 5xx or a throw. Never called with a slug content did not name.
|
|
116
|
-
*/
|
|
117
|
-
function readMagnetConfig(flowSlug: string): Promise<MagnetConfigRead> {
|
|
118
|
-
return sharedHubRead(`magnet:${flowSlug}`, async () => {
|
|
119
|
-
try {
|
|
120
|
-
const res = await flows.get(flowSlug);
|
|
121
|
-
if (res.ok) return { kind: "ok", config: res.body };
|
|
122
|
-
return res.status >= 500 ? { kind: "failed" } : { kind: "absent" };
|
|
123
|
-
} catch {
|
|
124
|
-
return { kind: "failed" };
|
|
125
|
-
}
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
type ApplicationForm = ReturnType<typeof jobApplicationFormFallback>;
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* The form a posting's page draws (D4), and the flow it records when that is
|
|
133
|
-
* the posting's own; with none named, exactly the Job application path.
|
|
134
|
-
*/
|
|
135
|
-
async function applicationForm(
|
|
136
|
-
slug: string,
|
|
137
|
-
{ applicationFlow: named }: ApplyPosting,
|
|
138
|
-
locale: string,
|
|
139
|
-
): Promise<{ view: ApplicationForm; applicationFlow?: string }> {
|
|
140
|
-
if (named !== undefined && named !== JOB_APPLICATION_FLOW_SLUG) {
|
|
141
|
-
const read: MagnetConfigRead = flowSlugSchema.safeParse(named).success
|
|
142
|
-
? await readMagnetConfig(named)
|
|
143
|
-
: { kind: "absent" };
|
|
144
|
-
const view = read.kind === "ok" ? jobApplicationFormFromConfig(read.config, locale) : null;
|
|
145
|
-
if (view) return { view, applicationFlow: named };
|
|
146
|
-
if (read.kind !== "failed") {
|
|
147
|
-
console.warn("[careers] application flow unavailable — falling back to job-application", {
|
|
148
|
-
posting: slug,
|
|
149
|
-
flow: named,
|
|
150
|
-
reason: read.kind === "ok" ? "unmappable" : "absent",
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
const read = await readMagnetConfig(JOB_APPLICATION_FLOW_SLUG);
|
|
155
|
-
return {
|
|
156
|
-
view:
|
|
157
|
-
(read.kind === "ok" ? jobApplicationFormFromConfig(read.config, locale) : null) ??
|
|
158
|
-
jobApplicationFormFallback(locale),
|
|
159
|
-
};
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
/** The posting, or `null` for a segment pair this page does not serve. */
|
|
163
|
-
async function postingFor(
|
|
164
|
-
slug: string,
|
|
165
|
-
action: string,
|
|
166
|
-
locale: string,
|
|
167
|
-
): Promise<ApplyPosting | null> {
|
|
168
|
-
if (action !== "apply" || !POSTING_SLUG_RE.test(slug)) return null;
|
|
169
|
-
return postingForApply(slug, locale);
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
export async function generateMetadata({ params }: Props): Promise<Metadata> {
|
|
173
|
-
const { locale, slug, action } = await params;
|
|
174
|
-
const posting = await postingFor(slug, action, locale);
|
|
175
|
-
return posting === null ? flowRouteMetadata() : flowRouteMetadata({ title: posting.title });
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
export default async function Page({ params }: Props): Promise<ReactElement> {
|
|
179
|
-
const { locale, slug, action } = await params;
|
|
180
|
-
const posting = await postingFor(slug, action, locale);
|
|
181
|
-
if (posting === null) notFound();
|
|
182
|
-
const { title } = posting;
|
|
183
|
-
|
|
184
|
-
const [accepting, t, tCareers, tFlow, { view, applicationFlow }] = await Promise.all([
|
|
185
|
-
readAccepting(),
|
|
186
|
-
getTranslations({ locale, namespace: "contact" }),
|
|
187
|
-
getTranslations({ locale, namespace: "careers" }),
|
|
188
|
-
getTranslations({ locale, namespace: "flow" }),
|
|
189
|
-
applicationForm(slug, posting, locale),
|
|
190
|
-
]);
|
|
191
|
-
const text = contactFormText(t);
|
|
192
|
-
const contactEmail = readSiteContactEmail();
|
|
193
|
-
|
|
194
|
-
return (
|
|
195
|
-
<main id="main" data-testid="job-apply">
|
|
196
|
-
<div className="px-control-x pt-control-y">
|
|
197
|
-
<NavBackLink
|
|
198
|
-
href={localeHref(locale, `/careers/${slug}`)}
|
|
199
|
-
label={tFlow("back")}
|
|
200
|
-
/>
|
|
201
|
-
</div>
|
|
202
|
-
<Container className="py-section">
|
|
203
|
-
<div className="max-w-container-sm">
|
|
204
|
-
<Heading level={1} className="mb-block-tight">
|
|
205
|
-
{title}
|
|
206
|
-
</Heading>
|
|
207
|
-
{accepting ? (
|
|
208
|
-
<LeadCaptureForm
|
|
209
|
-
action={
|
|
210
|
-
applicationFlow === undefined
|
|
211
|
-
? captureLeadAction.bind(null, slug)
|
|
212
|
-
: captureLeadAction.bind(null, { job: slug, flow: applicationFlow })
|
|
213
|
-
}
|
|
214
|
-
text={
|
|
215
|
-
view.consentStatement
|
|
216
|
-
? { ...text, consentStatement: view.consentStatement }
|
|
217
|
-
: text
|
|
218
|
-
}
|
|
219
|
-
termsHref={localeHref(locale, "/terms")}
|
|
220
|
-
policies={{
|
|
221
|
-
terms: localeHref(locale, "/terms"),
|
|
222
|
-
privacy: localeHref(locale, "/privacy"),
|
|
223
|
-
working_agreement: localeHref(locale, "/working-agreement"),
|
|
224
|
-
}}
|
|
225
|
-
fallbackEmail={contactEmail}
|
|
226
|
-
fields={view.fields}
|
|
227
|
-
submitLabel={view.submitLabel}
|
|
228
|
-
successMessage={tCareers("applicationSuccess")}
|
|
229
|
-
/>
|
|
230
|
-
) : (
|
|
231
|
-
<ContactFallback
|
|
232
|
-
email={contactEmail}
|
|
233
|
-
text={{
|
|
234
|
-
heading: text.unavailableHeading,
|
|
235
|
-
body: text.unavailableBody,
|
|
236
|
-
noEmail: text.unavailableNoEmail,
|
|
237
|
-
}}
|
|
238
|
-
/>
|
|
239
|
-
)}
|
|
240
|
-
</div>
|
|
241
|
-
</Container>
|
|
242
|
-
</main>
|
|
243
|
-
);
|
|
244
|
-
}
|