diff --git a/.changeset/healthy-pens-stare.md b/.changeset/healthy-pens-stare.md new file mode 100644 index 00000000..38a4d8e8 --- /dev/null +++ b/.changeset/healthy-pens-stare.md @@ -0,0 +1,5 @@ +--- +"@frameless/overige-objecten-api": patch +--- + +Zorg ervoor dat het kosten-veld beschikbaar is in de interne-veld-/overige-objecten-API. diff --git a/apps/overige-objecten-api/src/utils/createHTMLFiles.tsx b/apps/overige-objecten-api/src/utils/createHTMLFiles.tsx index 90b3230c..d3fae94a 100644 --- a/apps/overige-objecten-api/src/utils/createHTMLFiles.tsx +++ b/apps/overige-objecten-api/src/utils/createHTMLFiles.tsx @@ -4,93 +4,105 @@ import path from 'node:path'; import React from 'react'; import { renderToString } from 'react-dom/server'; import { Markdown } from '../components/Markdown'; +import type { Price } from '../strapi-product-type'; const categoryStyle = { border: '1px solid #ccc', padding: '10px', marginBottom: '10px' }; -const Category = ({ data }: { data: any }) => { +interface CategoryTypes { + [key: string]: string; +} + +interface CategoryProps { + data: CategoryTypes; + priceData: Price[]; +} + +const Category = ({ data, priceData }: CategoryProps) => { return ( <> {data?.tekst && (
Categorie - Tekst - {data?.tekst} + {data?.tekst}
)} {data?.procedureBeschrijving && (
Categorie - Procedure Beschrijving - {data?.procedureBeschrijving} + {data?.procedureBeschrijving}
)} {data?.bewijs && (
Categorie - Bewijs - {data?.bewijs} + {data?.bewijs}
)} {data?.uitvoeringsinstructies && (
Categorie - Uitvoeringsinstructies - {data?.uitvoeringsinstructies} + {data?.uitvoeringsinstructies}
)} {data?.bezwaarEnBeroep && (
Categorie - Bezwaar - {data?.bezwaarEnBeroep} + {data?.bezwaarEnBeroep}
)} {data?.vereisten && (
Categorie - Vereisten - {data?.vereisten} + {data?.vereisten}
)} {data?.kostenEnBetaalmethoden && (
Categorie - Kosten en betaalmethoden - {data?.kostenEnBetaalmethoden} + {data?.kostenEnBetaalmethoden}
)} {data?.contact && (
Categorie - Contact - {data?.contact} + {data?.contact}
)} {data?.wtdBijGeenReactie && (
Categorie - WTD Bij Geen Reactie - {data?.wtdBijGeenReactie} + {data?.wtdBijGeenReactie}
)} {data?.notice && (
Categorie - Notice - {data?.notice} + {data?.notice}
)} {data?.deskMemo && (
Categorie - Desk Memo (Interne velden) - {data?.deskMemo} + {data?.deskMemo}
)} ); }; -const PageComponent = ({ data }: { data: any }) => ( +interface PageComponentProps extends CategoryProps {} + +const PageComponent = ({ data, priceData }: PageComponentProps) => ( @@ -121,7 +133,7 @@ const PageComponent = ({ data }: { data: any }) => ( Kennisartikelen Categories - + @@ -129,12 +141,12 @@ const PageComponent = ({ data }: { data: any }) => ( ); -export const createHTMLFiles = (data: any) => { +export const createHTMLFiles = (data: CategoryTypes, priceData: Price[]) => { const outputDir = './tmp/output-html'; if (!fs.existsSync(outputDir)) { fs.mkdirSync(outputDir, { recursive: true }); } const filePath = path.join(outputDir, `preview.html`); - fs.writeFileSync(filePath, renderToString(), 'utf8'); + fs.writeFileSync(filePath, renderToString(), 'utf8'); }; diff --git a/apps/overige-objecten-api/src/utils/generateKennisartikelObject.ts b/apps/overige-objecten-api/src/utils/generateKennisartikelObject.ts index d7ba9d96..9b7edfdf 100644 --- a/apps/overige-objecten-api/src/utils/generateKennisartikelObject.ts +++ b/apps/overige-objecten-api/src/utils/generateKennisartikelObject.ts @@ -1,5 +1,11 @@ import { concatenateFieldValues } from './concatenateFieldValues'; -import { combineSimilarCategories, createHTMLFiles, normalizeCategories, processData } from './index'; +import { + combineSimilarCategories, + createHTMLFiles, + normalizeCategories, + processData, + renderMarkdownToString, +} from './index'; import { Attributes } from '../strapi-product-type'; import { components } from '../types/openapi'; interface GenerateKennisartikelObjectTypes { @@ -26,11 +32,11 @@ export const generateKennisartikelObject = ({ attributes, url, id }: GenerateKen ); const bothContentBlock = { ...sections, deskMemo }; - createHTMLFiles(bothContentBlock); + createHTMLFiles(bothContentBlock, priceData); const vertalingen = [ { ...bothContentBlock, - deskMemo, + deskMemo: renderMarkdownToString({ priceData, children: deskMemo }), trefwoorden, taal: attributes?.locale, titel: attributes?.title, diff --git a/apps/overige-objecten-api/src/utils/index.ts b/apps/overige-objecten-api/src/utils/index.ts index 9c4a140c..4be535e3 100644 --- a/apps/overige-objecten-api/src/utils/index.ts +++ b/apps/overige-objecten-api/src/utils/index.ts @@ -18,3 +18,4 @@ export { processData } from './processData'; export { convertSpotlightToHTML } from './convertSpotlightToHTML'; export { convertMultiColumnsButtonToHTML } from './convertMultiColumnsButtonToHTML'; export { createHTMLFiles } from './createHTMLFiles'; +export { renderMarkdownToString } from './renderMarkdownToString'; diff --git a/apps/overige-objecten-api/src/utils/renderMarkdownToString.tsx b/apps/overige-objecten-api/src/utils/renderMarkdownToString.tsx new file mode 100644 index 00000000..bd3f616b --- /dev/null +++ b/apps/overige-objecten-api/src/utils/renderMarkdownToString.tsx @@ -0,0 +1,8 @@ +import React from 'react'; +import { renderToString } from 'react-dom/server'; +import { Markdown, type MarkdownProps } from '../components/Markdown'; + +export interface RenderMarkdownToStringProps extends MarkdownProps {} + +export const renderMarkdownToString = ({ children, priceData }: RenderMarkdownToStringProps) => + renderToString({children});