|
1 | | -import { ActionIcon } from "@/components/ActionIcon" |
2 | | -import { ActionTriggerCard } from "@/components/ActionTriggerCard" |
3 | | -import { ActionCard } from "@/components/cards/ActionCard" |
| 1 | +import { PageBlocks } from "@/components/PageBlockRenderer" |
4 | 2 | import { Aurora } from "@/components/ui/Aurora" |
5 | 3 | import { LandingContainer } from "@/components/ui/LandingContainer" |
6 | | -import { LinkButton } from "@/components/ui/LinkButton" |
| 4 | +import { fetchMediaJson } from "@/lib/actionExtraction" |
7 | 5 | import { getPageLocaleAndSlug, type LocaleSlugPageParams } from "@/lib/appRoute" |
8 | | -import { extractFlowTypesFromJson, extractFunctionDefinitionsFromJson, fetchMediaJson } from "@/lib/actionExtraction" |
9 | 6 | import { getActionBySlug, getLandingPage } from "@/lib/cms" |
10 | | -import { findPageBlock } from "@/lib/pageBlocks" |
11 | 7 | import { createMetadata } from "@/lib/siteConfig" |
12 | 8 | import type { Media } from "@/payload-types" |
13 | | -import { IconArrowLeft } from "@tabler/icons-react" |
14 | 9 | import type { Metadata } from "next" |
15 | 10 | import { notFound } from "next/navigation" |
16 | | -import type { ReactNode } from "react" |
17 | 11 |
|
18 | 12 | export default async function ActionDetailPage({ params }: { params: LocaleSlugPageParams }) { |
19 | 13 | const { locale, slug } = await getPageLocaleAndSlug(params) |
20 | 14 | const action = await getActionBySlug(slug, locale) |
21 | 15 | if (!action) notFound() |
22 | | - const actionsPage = await getLandingPage("actions", locale) |
| 16 | + const actionsPage = await getLandingPage("action-details", locale) |
23 | 17 |
|
24 | 18 | const module = action.module as Media | undefined |
25 | 19 | const moduleJson = await fetchMediaJson(module).catch(() => null) |
26 | | - const extractedFlowTypes = extractFlowTypesFromJson(moduleJson) |
27 | | - const extractedFunctionDefinitions = extractFunctionDefinitionsFromJson(moduleJson) |
28 | 20 | const references = (action.references ?? []).filter((reference): reference is Exclude<typeof reference, number> => typeof reference !== "number") |
29 | 21 | const tags = (action.tags ?? []).filter((tag): tag is string => Boolean(tag)) |
30 | | - const actionsBlock = findPageBlock(actionsPage, "actions") |
31 | | - const referencesLabel = actionsBlock?.referencesLabel ?? (locale === "de" ? "Referenzen" : "References") |
32 | | - const flowTypesLabel = actionsBlock?.flowTypesLabel ?? "FlowTypes" |
33 | | - const functionDefinitionsLabel = actionsBlock?.functionDefinitionsLabel ?? "FunctionDefinitions" |
34 | 22 |
|
35 | 23 | return ( |
36 | 24 | <> |
37 | 25 | <Aurora /> |
38 | | - <LandingContainer className="pt-32"> |
39 | | - <div className="mx-auto flex w-full max-w-4xl flex-col gap-8"> |
40 | | - <LinkButton href={`/${locale}/actions`} showArrow={false} className="border-0 hover:bg-white/10 pl-2.5 pr-4 py-1 rounded-xl hover:text-white after:hidden"> |
41 | | - <IconArrowLeft size={16} /> |
42 | | - {locale === "de" ? "Zurück" : "Back"} |
43 | | - </LinkButton> |
44 | | - |
45 | | - <div className="flex flex-col gap-8"> |
46 | | - <div className="relative z-10 flex flex-col gap-12"> |
47 | | - <div className="flex flex-col gap-4 sm:flex-row sm:justify-between"> |
48 | | - <div className="flex flex-col gap-4 sm:flex-row sm:items-start"> |
49 | | - {action.icon && ( |
50 | | - <div className="flex size-20 shrink-0 items-center justify-center overflow-hidden rounded-3xl border border-white/10 bg-primary text-white"> |
51 | | - <ActionIcon icon={action.icon} size={40} /> |
52 | | - </div> |
53 | | - )} |
54 | | - |
55 | | - <div className="flex flex-col min-w-0 flex-1 gap-2"> |
56 | | - <h1 className="mt-1 text-3xl font-semibold tracking-tight text-white sm:text-4xl">{action.title}</h1> |
57 | | - {action.description && <div className="max-w-3xl whitespace-pre-line text-sm leading-6 text-secondary">{action.description}</div>} |
58 | | - </div> |
59 | | - </div> |
60 | | - </div> |
61 | | - |
62 | | - {(extractedFlowTypes.length > 0 || extractedFunctionDefinitions.length > 0) && ( |
63 | | - <div className="space-y-8"> |
64 | | - {extractedFlowTypes.length > 0 && ( |
65 | | - <ActionDefinitionGroup label={flowTypesLabel}> |
66 | | - {extractedFlowTypes.map((item) => ( |
67 | | - <ActionTriggerCard key={item.id} type="flowType" item={item} /> |
68 | | - ))} |
69 | | - </ActionDefinitionGroup> |
70 | | - )} |
71 | | - |
72 | | - {extractedFunctionDefinitions.length > 0 && ( |
73 | | - <ActionDefinitionGroup label={functionDefinitionsLabel}> |
74 | | - {extractedFunctionDefinitions.map((item) => ( |
75 | | - <ActionTriggerCard key={item.id} type="functionDefinition" item={item} /> |
76 | | - ))} |
77 | | - </ActionDefinitionGroup> |
78 | | - )} |
79 | | - </div> |
80 | | - )} |
81 | | - |
82 | | - {references.length > 0 && ( |
83 | | - <div className="space-y-4"> |
84 | | - <p className="text-sm text-tertiary">{referencesLabel}</p> |
85 | | - <div className="grid gap-4 md:grid-cols-2"> |
86 | | - {references.map((reference) => ( |
87 | | - <ActionCard key={reference.id} action={reference} locale={locale} /> |
88 | | - ))} |
89 | | - </div> |
90 | | - </div> |
91 | | - )} |
92 | | - </div> |
93 | | - </div> |
94 | | - </div> |
| 26 | + <LandingContainer className="pt-16"> |
| 27 | + <PageBlocks blocks={actionsPage?.layout} locale={locale} action={action} actionModuleJson={moduleJson} actionReferences={references as (typeof action)[]} /> |
95 | 28 | </LandingContainer> |
96 | 29 | </> |
97 | 30 | ) |
98 | 31 | } |
99 | 32 |
|
100 | | -function ActionDefinitionGroup({ label, children }: { label: string; children: ReactNode }) { |
101 | | - return ( |
102 | | - <div className="space-y-4"> |
103 | | - <p className="shrink-0 text-sm text-tertiary">{label}</p> |
104 | | - <div className="flex flex-col gap-3">{children}</div> |
105 | | - </div> |
106 | | - ) |
107 | | -} |
108 | | - |
109 | 33 | export async function generateMetadata({ params }: { params: LocaleSlugPageParams }): Promise<Metadata> { |
110 | 34 | const { locale, slug } = await params |
111 | 35 | if (!slug?.trim()) return createMetadata() |
|
0 commit comments