From 81e2d290eb714e311f3307c67923761637c11749 Mon Sep 17 00:00:00 2001 From: Marco Bottaro Date: Fri, 20 Sep 2024 16:57:47 +0200 Subject: [PATCH 01/43] Add bannerLinks attribute to Product codec --- .../strapi/__tests__/fixtures/bannerLinks.ts | 53 ++++++ .../lib/strapi/__tests__/fixtures/product.ts | 2 + .../lib/strapi/__tests__/overviews.test.ts | 2 +- .../lib/strapi/__tests__/tutorialList.test.ts | 2 +- .../lib/strapi/__tests__/tutorials.test.ts | 171 +----------------- .../lib/strapi/codecs/CaseHistoriesCodec.ts | 4 +- .../src/lib/strapi/codecs/HomepageCodec.ts | 4 +- .../src/lib/strapi/codecs/ProductCodec.ts | 8 +- .../strapi/codecs/QuickStartGuidesCodec.ts | 4 +- .../src/lib/strapi/codecs/SolutionsCodec.ts | 4 +- 10 files changed, 72 insertions(+), 182 deletions(-) create mode 100644 apps/nextjs-website/src/lib/strapi/__tests__/fixtures/bannerLinks.ts diff --git a/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/bannerLinks.ts b/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/bannerLinks.ts new file mode 100644 index 000000000..06ce401e5 --- /dev/null +++ b/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/bannerLinks.ts @@ -0,0 +1,53 @@ +import { mediaVectorJson } from '@/lib/strapi/__tests__/fixtures/media'; + +const firstItem = { + id: 2, + title: 'Serve aiuto?', + content: [ + { + type: 'paragraph', + children: [ + { + text: 'Apri un ticket utilizzando l’apposita funzione all’interno della tua ', + type: 'text', + }, + { + url: 'https://selfcare.pagopa.it/auth/login?onSuccess=%2F', + type: 'link', + children: [{ bold: true, text: 'Area Riservata', type: 'text' }], + }, + { text: '', type: 'text' }, + ], + }, + ], + theme: 'dark', + subtitle: null, + icon: mediaVectorJson, +}; + +const secondItem = { + id: 3, + title: 'Dicci cosa ne pensi', + content: [ + { + type: 'paragraph', + children: [ + { + text: 'Per chiarimenti sulle specifiche d’implementazione, come SACI e SANP, puoi aprire una segnalazione su ', + type: 'text', + }, + { + url: 'https://github.com/pagopa/pagopa-api/issues', + type: 'link', + children: [{ text: 'GitHub', type: 'text' }], + }, + { text: '', type: 'text' }, + ], + }, + ], + theme: 'light', + subtitle: null, + icon: mediaVectorJson, +}; + +export const bannerLinks = [firstItem, secondItem]; diff --git a/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/product.ts b/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/product.ts index d115ad761..00d3ccba2 100644 --- a/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/product.ts +++ b/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/product.ts @@ -1,4 +1,5 @@ import { mediaVectorJson } from './media'; +import { bannerLinks } from '@/lib/strapi/__tests__/fixtures/bannerLinks'; export const baseProductJson = { data: { @@ -25,6 +26,7 @@ export const productJson = { locale: 'it', shortName: 'Firma con IO', logo: mediaVectorJson, + bannerLinks: bannerLinks, }, }, }; diff --git a/apps/nextjs-website/src/lib/strapi/__tests__/overviews.test.ts b/apps/nextjs-website/src/lib/strapi/__tests__/overviews.test.ts index 75a509f46..555f5cbca 100644 --- a/apps/nextjs-website/src/lib/strapi/__tests__/overviews.test.ts +++ b/apps/nextjs-website/src/lib/strapi/__tests__/overviews.test.ts @@ -370,7 +370,7 @@ const makeStrapiResponseJson = () => ({ meta: { pagination: { page: 1, pageSize: 25, pageCount: 1, total: 3 } }, }); -describe('StrapiOverviewsCodec', () => { +describe('OverviewsCodec', () => { it('should decode strapi overviews', () => { const jsonFromStrapi = makeStrapiResponseJson(); const actual = OverviewsCodec.decode(jsonFromStrapi); diff --git a/apps/nextjs-website/src/lib/strapi/__tests__/tutorialList.test.ts b/apps/nextjs-website/src/lib/strapi/__tests__/tutorialList.test.ts index 57e378b29..115b8be64 100644 --- a/apps/nextjs-website/src/lib/strapi/__tests__/tutorialList.test.ts +++ b/apps/nextjs-website/src/lib/strapi/__tests__/tutorialList.test.ts @@ -98,7 +98,7 @@ const makeStrapiResponseJson = () => ({ }, }); -describe('StrapiTutorialListPagesCodec', () => { +describe('TutorialListPagesCodec', () => { it('should decode strapi tutorial list pages', () => { const jsonFromStrapi = makeStrapiResponseJson(); const actual = StrapiTutorialListPagesCodec.decode(jsonFromStrapi); diff --git a/apps/nextjs-website/src/lib/strapi/__tests__/tutorials.test.ts b/apps/nextjs-website/src/lib/strapi/__tests__/tutorials.test.ts index cd4233d13..7d4709b47 100644 --- a/apps/nextjs-website/src/lib/strapi/__tests__/tutorials.test.ts +++ b/apps/nextjs-website/src/lib/strapi/__tests__/tutorials.test.ts @@ -1,5 +1,6 @@ import * as E from 'fp-ts/lib/Either'; import { StrapiTutorialsCodec } from '../codecs/TutorialCodec'; +import { productJson } from '@/lib/strapi/__tests__/fixtures/product'; const baseTutorialJson = { id: 1, @@ -76,89 +77,7 @@ const baseTutorialJson = { updatedAt: '2024-06-04T12:42:01.642Z', publishedAt: '2024-06-04T12:34:38.692Z', locale: 'it', - product: { - data: { - id: 1, - attributes: { - name: 'CMS APP IO', - shortName: 'IO', - description: 'Test desc ', - slug: 'app-io', - createdAt: '2024-02-15T09:57:22.179Z', - updatedAt: '2024-02-27T11:13:34.014Z', - publishedAt: '2024-02-15T09:57:24.401Z', - locale: 'it', - logo: { - data: { - id: 1, - attributes: { - name: 'Screenshot from 2024-02-20 17-03-22.png', - alternativeText: null, - caption: null, - width: 2481, - height: 1919, - formats: { - thumbnail: { - name: 'thumbnail_Screenshot from 2024-02-20 17-03-22.png', - hash: 'thumbnail_Screenshot_from_2024_02_20_17_03_22_4fe74a0a0e', - ext: '.png', - mime: 'image/png', - path: null, - width: 202, - height: 156, - size: 5.63, - url: '/uploads/thumbnail_Screenshot_from_2024_02_20_17_03_22_4fe74a0a0e.png', - }, - large: { - name: 'large_Screenshot from 2024-02-20 17-03-22.png', - hash: 'large_Screenshot_from_2024_02_20_17_03_22_4fe74a0a0e', - ext: '.png', - mime: 'image/png', - path: null, - width: 1000, - height: 773, - size: 48.63, - url: '/uploads/large_Screenshot_from_2024_02_20_17_03_22_4fe74a0a0e.png', - }, - medium: { - name: 'medium_Screenshot from 2024-02-20 17-03-22.png', - hash: 'medium_Screenshot_from_2024_02_20_17_03_22_4fe74a0a0e', - ext: '.png', - mime: 'image/png', - path: null, - width: 750, - height: 580, - size: 33.57, - url: '/uploads/medium_Screenshot_from_2024_02_20_17_03_22_4fe74a0a0e.png', - }, - small: { - name: 'small_Screenshot from 2024-02-20 17-03-22.png', - hash: 'small_Screenshot_from_2024_02_20_17_03_22_4fe74a0a0e', - ext: '.png', - mime: 'image/png', - path: null, - width: 500, - height: 387, - size: 19.04, - url: '/uploads/small_Screenshot_from_2024_02_20_17_03_22_4fe74a0a0e.png', - }, - }, - hash: 'Screenshot_from_2024_02_20_17_03_22_4fe74a0a0e', - ext: '.png', - mime: 'image/png', - size: 30.86, - url: '/uploads/Screenshot_from_2024_02_20_17_03_22_4fe74a0a0e.png', - previewUrl: null, - provider: 'local', - provider_metadata: null, - createdAt: '2024-02-27T10:11:20.913Z', - updatedAt: '2024-03-27T17:34:49.514Z', - }, - }, - }, - }, - }, - }, + product: productJson, image: { data: null, }, @@ -239,89 +158,7 @@ const makeStrapiResponseJsonWithNull = () => ({ updatedAt: '2024-06-04T12:42:01.642Z', publishedAt: '2024-06-04T12:34:38.692Z', locale: 'it', - product: { - data: { - id: 1, - attributes: { - name: 'CMS APP IO', - shortName: 'IO', - description: 'Test desc ', - slug: 'app-io', - createdAt: '2024-02-15T09:57:22.179Z', - updatedAt: '2024-02-27T11:13:34.014Z', - publishedAt: '2024-02-15T09:57:24.401Z', - locale: 'it', - logo: { - data: { - id: 1, - attributes: { - name: 'Screenshot from 2024-02-20 17-03-22.png', - alternativeText: null, - caption: null, - width: 2481, - height: 1919, - formats: { - thumbnail: { - name: 'thumbnail_Screenshot from 2024-02-20 17-03-22.png', - hash: 'thumbnail_Screenshot_from_2024_02_20_17_03_22_4fe74a0a0e', - ext: '.png', - mime: 'image/png', - path: null, - width: 202, - height: 156, - size: 5.63, - url: '/uploads/thumbnail_Screenshot_from_2024_02_20_17_03_22_4fe74a0a0e.png', - }, - large: { - name: 'large_Screenshot from 2024-02-20 17-03-22.png', - hash: 'large_Screenshot_from_2024_02_20_17_03_22_4fe74a0a0e', - ext: '.png', - mime: 'image/png', - path: null, - width: 1000, - height: 773, - size: 48.63, - url: '/uploads/large_Screenshot_from_2024_02_20_17_03_22_4fe74a0a0e.png', - }, - medium: { - name: 'medium_Screenshot from 2024-02-20 17-03-22.png', - hash: 'medium_Screenshot_from_2024_02_20_17_03_22_4fe74a0a0e', - ext: '.png', - mime: 'image/png', - path: null, - width: 750, - height: 580, - size: 33.57, - url: '/uploads/medium_Screenshot_from_2024_02_20_17_03_22_4fe74a0a0e.png', - }, - small: { - name: 'small_Screenshot from 2024-02-20 17-03-22.png', - hash: 'small_Screenshot_from_2024_02_20_17_03_22_4fe74a0a0e', - ext: '.png', - mime: 'image/png', - path: null, - width: 500, - height: 387, - size: 19.04, - url: '/uploads/small_Screenshot_from_2024_02_20_17_03_22_4fe74a0a0e.png', - }, - }, - hash: 'Screenshot_from_2024_02_20_17_03_22_4fe74a0a0e', - ext: '.png', - mime: 'image/png', - size: 30.86, - url: '/uploads/Screenshot_from_2024_02_20_17_03_22_4fe74a0a0e.png', - previewUrl: null, - provider: 'local', - provider_metadata: null, - createdAt: '2024-02-27T10:11:20.913Z', - updatedAt: '2024-03-27T17:34:49.514Z', - }, - }, - }, - }, - }, - }, + product: productJson, image: { data: { id: 1, @@ -359,7 +196,7 @@ const makeStrapiResponseJsonWithNull = () => ({ }, }); -describe('StrapiTutorialCodec', () => { +describe('TutorialCodec', () => { it('should decode strapi tutorials', () => { const jsonFromStrapi = makeStrapiResponseJson(); const actual = StrapiTutorialsCodec.decode(jsonFromStrapi); diff --git a/apps/nextjs-website/src/lib/strapi/codecs/CaseHistoriesCodec.ts b/apps/nextjs-website/src/lib/strapi/codecs/CaseHistoriesCodec.ts index e86349e1f..d9c610c13 100644 --- a/apps/nextjs-website/src/lib/strapi/codecs/CaseHistoriesCodec.ts +++ b/apps/nextjs-website/src/lib/strapi/codecs/CaseHistoriesCodec.ts @@ -3,7 +3,7 @@ import * as tt from 'io-ts-types'; import { NullToUndefinedCodec } from './NullToUndefinedCodec'; import { MediaCodec } from './MediaCodec'; import { PaginationCodec } from './PaginationCodec'; -import { ProductCodec } from './ProductCodec'; +import { BaseProductCodec } from './ProductCodec'; import { PartCodec } from './PartCodec'; export const CaseHistoryCodec = t.strict({ @@ -18,7 +18,7 @@ export const CaseHistoryCodec = t.strict({ t.strict({ data: t.union([NullToUndefinedCodec, MediaCodec]) }), ]), products: t.strict({ - data: t.array(ProductCodec), + data: t.array(BaseProductCodec), }), parts: t.array(PartCodec), }), diff --git a/apps/nextjs-website/src/lib/strapi/codecs/HomepageCodec.ts b/apps/nextjs-website/src/lib/strapi/codecs/HomepageCodec.ts index 5b24b944a..c6263adb3 100644 --- a/apps/nextjs-website/src/lib/strapi/codecs/HomepageCodec.ts +++ b/apps/nextjs-website/src/lib/strapi/codecs/HomepageCodec.ts @@ -6,7 +6,7 @@ import { RelatedLinksCodec } from './RelatedLinksCodec'; import { MediaCodec } from './MediaCodec'; import { LinkCodec } from './LinkCodec'; import { WebinarCodec } from './WebinarsCodec'; -import { ProductCodec } from './ProductCodec'; +import { BaseProductCodec } from './ProductCodec'; import { SEOCodec } from './SeoCodec'; import { BaseSolutionCodec } from './SolutionsCodec'; @@ -73,7 +73,7 @@ export const HomepageCodec = t.strict({ title: t.union([NullToUndefinedCodec, t.string]), productsTabName: t.string, products: t.strict({ - data: t.array(ProductCodec), + data: t.array(BaseProductCodec), }), solutionsTabName: t.string, solutions: t.strict({ diff --git a/apps/nextjs-website/src/lib/strapi/codecs/ProductCodec.ts b/apps/nextjs-website/src/lib/strapi/codecs/ProductCodec.ts index 94c9bf261..8d2ca4719 100644 --- a/apps/nextjs-website/src/lib/strapi/codecs/ProductCodec.ts +++ b/apps/nextjs-website/src/lib/strapi/codecs/ProductCodec.ts @@ -3,6 +3,7 @@ import { MediaCodec } from './MediaCodec'; import { NullToUndefinedCodec } from './NullToUndefinedCodec'; import qs from 'qs'; import { fetchFromStrapi } from '../fetchFromStrapi'; +import { BannerLinkCodec } from '@/lib/strapi/codecs/BannerLinkCodec'; const BaseProductAttributesCodec = t.strict({ name: t.string, @@ -18,11 +19,9 @@ export const ProductCodec = t.strict({ attributes: t.intersection([ BaseProductAttributesCodec, t.strict({ - name: t.string, - shortName: t.string, description: t.union([NullToUndefinedCodec, t.string]), - slug: t.string, logo: t.strict({ data: MediaCodec }), + bannerLinks: t.union([NullToUndefinedCodec, t.array(BannerLinkCodec)]), }), ]), }); @@ -31,10 +30,9 @@ export const ProductsCodec = t.strict({ data: t.array(ProductCodec), }); -export type Products = t.TypeOf; - export type BaseProduct = t.TypeOf; export type Product = t.TypeOf; +export type Products = t.TypeOf; const makeStrapiProductsPopulate = () => qs.stringify({ diff --git a/apps/nextjs-website/src/lib/strapi/codecs/QuickStartGuidesCodec.ts b/apps/nextjs-website/src/lib/strapi/codecs/QuickStartGuidesCodec.ts index 4131375df..bfc5846ed 100644 --- a/apps/nextjs-website/src/lib/strapi/codecs/QuickStartGuidesCodec.ts +++ b/apps/nextjs-website/src/lib/strapi/codecs/QuickStartGuidesCodec.ts @@ -1,7 +1,7 @@ import * as t from 'io-ts/lib'; import * as tt from 'io-ts-types'; import { PaginationCodec } from './PaginationCodec'; -import { ProductCodec } from './ProductCodec'; +import { BaseProductCodec } from './ProductCodec'; import { PartCodec } from './PartCodec'; const QuickStartGuideItemCodec = t.strict({ @@ -19,7 +19,7 @@ export const QuickStartGuideCodec = t.strict({ attributes: t.strict({ title: t.string, description: t.string, - product: t.strict({ data: ProductCodec }), + product: t.strict({ data: BaseProductCodec }), quickstartGuideItems: t.strict({ data: t.array(QuickStartGuideItemCodec) }), }), }); diff --git a/apps/nextjs-website/src/lib/strapi/codecs/SolutionsCodec.ts b/apps/nextjs-website/src/lib/strapi/codecs/SolutionsCodec.ts index a2068e0e4..1617e785f 100644 --- a/apps/nextjs-website/src/lib/strapi/codecs/SolutionsCodec.ts +++ b/apps/nextjs-website/src/lib/strapi/codecs/SolutionsCodec.ts @@ -3,7 +3,7 @@ import * as tt from 'io-ts-types'; import { NullToUndefinedCodec } from './NullToUndefinedCodec'; import { MediaCodec } from './MediaCodec'; import { PaginationCodec } from './PaginationCodec'; -import { BaseProductCodec, ProductCodec } from './ProductCodec'; +import { BaseProductCodec } from './ProductCodec'; import { BlocksContentCodec } from './BlocksContentCodec'; import { BannerLinkCodec } from './BannerLinkCodec'; import { WebinarCodec } from './WebinarsCodec'; @@ -51,7 +51,7 @@ export const SolutionCodec = t.strict({ data: t.array(WebinarCodec), }), products: t.strict({ - data: t.array(ProductCodec), + data: t.array(BaseProductCodec), }), caseHistories: t.union([ NullToUndefinedCodec, From 492999c5ce4b3928e3bc1951443bb050be5779c3 Mon Sep 17 00:00:00 2001 From: Marco Bottaro Date: Fri, 20 Sep 2024 17:04:06 +0200 Subject: [PATCH 02/43] Fix CaseHistoriesCodec product attribute type --- .../src/lib/strapi/codecs/CaseHistoriesCodec.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/nextjs-website/src/lib/strapi/codecs/CaseHistoriesCodec.ts b/apps/nextjs-website/src/lib/strapi/codecs/CaseHistoriesCodec.ts index d9c610c13..e86349e1f 100644 --- a/apps/nextjs-website/src/lib/strapi/codecs/CaseHistoriesCodec.ts +++ b/apps/nextjs-website/src/lib/strapi/codecs/CaseHistoriesCodec.ts @@ -3,7 +3,7 @@ import * as tt from 'io-ts-types'; import { NullToUndefinedCodec } from './NullToUndefinedCodec'; import { MediaCodec } from './MediaCodec'; import { PaginationCodec } from './PaginationCodec'; -import { BaseProductCodec } from './ProductCodec'; +import { ProductCodec } from './ProductCodec'; import { PartCodec } from './PartCodec'; export const CaseHistoryCodec = t.strict({ @@ -18,7 +18,7 @@ export const CaseHistoryCodec = t.strict({ t.strict({ data: t.union([NullToUndefinedCodec, MediaCodec]) }), ]), products: t.strict({ - data: t.array(BaseProductCodec), + data: t.array(ProductCodec), }), parts: t.array(PartCodec), }), From 41f243c04dc28dcd62260bbef7e80a59e3d1ae90 Mon Sep 17 00:00:00 2001 From: Marco Bottaro Date: Mon, 23 Sep 2024 13:08:23 +0200 Subject: [PATCH 03/43] Add bannerLinks attribute to Product codec and add BaseProductWithBannerLinks codec --- .../{bannerLinks.ts => bannerLinksJson.ts} | 2 +- .../lib/strapi/__tests__/fixtures/product.ts | 4 +- .../strapi/__tests__/quickStartGuides.test.ts | 23 ++-------- .../lib/strapi/__tests__/tutorialList.test.ts | 22 ++-------- .../lib/strapi/__tests__/tutorials.test.ts | 44 +++---------------- .../strapi/codecs/ApiDataListPagesCodec.ts | 4 +- .../lib/strapi/codecs/GuideListPagesCodec.ts | 4 +- .../src/lib/strapi/codecs/GuidesCodec.ts | 4 +- .../src/lib/strapi/codecs/HomepageCodec.ts | 4 +- .../src/lib/strapi/codecs/ProductCodec.ts | 8 ++++ .../strapi/codecs/QuickStartGuidesCodec.ts | 4 +- .../src/lib/strapi/codecs/SolutionsCodec.ts | 4 +- .../src/lib/strapi/codecs/TutorialCodec.ts | 4 +- .../strapi/codecs/TutorialListPagesCodec.ts | 14 +++--- .../strapi/fetches/fetchApiDataListPages.ts | 2 +- .../lib/strapi/fetches/fetchGuideListPages.ts | 4 +- .../src/lib/strapi/fetches/fetchGuides.ts | 9 +++- .../src/lib/strapi/fetches/fetchHomepage.ts | 7 ++- .../src/lib/strapi/fetches/fetchOverviews.ts | 2 +- .../strapi/fetches/fetchQuickStartGuides.ts | 2 +- .../strapi/fetches/fetchTutorialListPages.ts | 8 ++-- .../src/lib/strapi/fetches/fetchTutorials.ts | 8 ++-- .../strapi/makeProps/makeGuideListPages.ts | 2 +- .../src/lib/strapi/makeProps/makeProducts.ts | 6 +++ 24 files changed, 82 insertions(+), 113 deletions(-) rename apps/nextjs-website/src/lib/strapi/__tests__/fixtures/{bannerLinks.ts => bannerLinksJson.ts} (95%) diff --git a/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/bannerLinks.ts b/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/bannerLinksJson.ts similarity index 95% rename from apps/nextjs-website/src/lib/strapi/__tests__/fixtures/bannerLinks.ts rename to apps/nextjs-website/src/lib/strapi/__tests__/fixtures/bannerLinksJson.ts index 06ce401e5..9e7c19873 100644 --- a/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/bannerLinks.ts +++ b/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/bannerLinksJson.ts @@ -50,4 +50,4 @@ const secondItem = { icon: mediaVectorJson, }; -export const bannerLinks = [firstItem, secondItem]; +export const bannerLinksJson = [firstItem, secondItem]; diff --git a/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/product.ts b/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/product.ts index 00d3ccba2..86a4fcd29 100644 --- a/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/product.ts +++ b/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/product.ts @@ -1,5 +1,5 @@ import { mediaVectorJson } from './media'; -import { bannerLinks } from '@/lib/strapi/__tests__/fixtures/bannerLinks'; +import { bannerLinksJson } from '@/lib/strapi/__tests__/fixtures/bannerLinksJson'; export const baseProductJson = { data: { @@ -26,7 +26,7 @@ export const productJson = { locale: 'it', shortName: 'Firma con IO', logo: mediaVectorJson, - bannerLinks: bannerLinks, + bannerLinks: bannerLinksJson, }, }, }; diff --git a/apps/nextjs-website/src/lib/strapi/__tests__/quickStartGuides.test.ts b/apps/nextjs-website/src/lib/strapi/__tests__/quickStartGuides.test.ts index 9df047701..87575f497 100644 --- a/apps/nextjs-website/src/lib/strapi/__tests__/quickStartGuides.test.ts +++ b/apps/nextjs-website/src/lib/strapi/__tests__/quickStartGuides.test.ts @@ -1,23 +1,6 @@ import * as E from 'fp-ts/lib/Either'; import { QuickStartGuidesCodec } from '@/lib/strapi/codecs/QuickStartGuidesCodec'; -import { mediaRasterJson } from '@/lib/strapi/__tests__/fixtures/media'; - -const product = { - data: { - id: 1, - attributes: { - name: 'CMS APP IO', - shortName: 'IO', - description: 'Test desc ', - slug: 'app-io', - createdAt: '2024-02-15T09:57:22.179Z', - updatedAt: '2024-02-27T11:13:34.014Z', - publishedAt: '2024-02-15T09:57:24.401Z', - locale: 'it', - logo: mediaRasterJson, - }, - }, -}; +import { productJson } from '@/lib/strapi/__tests__/fixtures/product'; const makeStrapiResponseJson = () => ({ data: [ @@ -139,7 +122,7 @@ const makeStrapiResponseJson = () => ({ }, ], }, - product: product, + product: productJson, }, }, ], @@ -273,7 +256,7 @@ const makeStrapiResponseWithNullsJson = () => ({ }, ], }, - product: product, + product: productJson, }, }, ], diff --git a/apps/nextjs-website/src/lib/strapi/__tests__/tutorialList.test.ts b/apps/nextjs-website/src/lib/strapi/__tests__/tutorialList.test.ts index 115b8be64..88dc510f9 100644 --- a/apps/nextjs-website/src/lib/strapi/__tests__/tutorialList.test.ts +++ b/apps/nextjs-website/src/lib/strapi/__tests__/tutorialList.test.ts @@ -1,7 +1,7 @@ import * as E from 'fp-ts/lib/Either'; -import { StrapiTutorialListPagesCodec } from '../codecs/TutorialListPagesCodec'; +import { TutorialListPagesCodec } from '../codecs/TutorialListPagesCodec'; import { mediaVectorJson } from './fixtures/media'; -import { baseProductJson } from './fixtures/product'; +import { baseProductJson, productJson } from './fixtures/product'; const makeStrapiResponseJson = () => ({ data: [ @@ -32,21 +32,7 @@ const makeStrapiResponseJson = () => ({ }, ], }, - product: { - data: { - id: 1, - attributes: { - name: 'APP IO', - description: 'Test desc ', - slug: 'app-io', - createdAt: '2024-02-15T09:57:22.179Z', - updatedAt: '2024-07-17T15:08:58.315Z', - publishedAt: '2024-02-15T09:57:24.401Z', - locale: 'it', - shortName: 'app-io', - }, - }, - }, + product: productJson, bannerLinks: [ { id: 22, @@ -101,7 +87,7 @@ const makeStrapiResponseJson = () => ({ describe('TutorialListPagesCodec', () => { it('should decode strapi tutorial list pages', () => { const jsonFromStrapi = makeStrapiResponseJson(); - const actual = StrapiTutorialListPagesCodec.decode(jsonFromStrapi); + const actual = TutorialListPagesCodec.decode(jsonFromStrapi); expect(E.isRight(actual)).toBeTruthy(); }); }); diff --git a/apps/nextjs-website/src/lib/strapi/__tests__/tutorials.test.ts b/apps/nextjs-website/src/lib/strapi/__tests__/tutorials.test.ts index 7d4709b47..e4cfb28fa 100644 --- a/apps/nextjs-website/src/lib/strapi/__tests__/tutorials.test.ts +++ b/apps/nextjs-website/src/lib/strapi/__tests__/tutorials.test.ts @@ -1,6 +1,7 @@ import * as E from 'fp-ts/lib/Either'; -import { StrapiTutorialsCodec } from '../codecs/TutorialCodec'; +import { TutorialsCodec } from '../codecs/TutorialCodec'; import { productJson } from '@/lib/strapi/__tests__/fixtures/product'; +import { bannerLinksJson } from '@/lib/strapi/__tests__/fixtures/bannerLinksJson'; const baseTutorialJson = { id: 1, @@ -82,7 +83,7 @@ const baseTutorialJson = { data: null, }, relatedLinks: null, - bannerLinks: [], + bannerLinks: bannerLinksJson, }, }; @@ -90,38 +91,7 @@ const makeStrapiResponseJson = () => ({ data: [ { ...baseTutorialJson, - bannerLinks: [ - { - id: 1, - title: 'test', - body: [ - { - type: 'paragraph', - children: [ - { - type: 'text', - text: 'some desc', - }, - ], - }, - ], - }, - { - id: 2, - title: 'test 2', - body: [ - { - type: 'paragraph', - children: [ - { - type: 'text', - text: 'some desc', - }, - ], - }, - ], - }, - ], + bannerLinks: bannerLinksJson, relatedLinks: { id: 9, title: 'links', @@ -182,7 +152,7 @@ const makeStrapiResponseJsonWithNull = () => ({ }, }, relatedLinks: null, - bannerLinks: [], + bannerLinks: bannerLinksJson, }, }, ], @@ -199,13 +169,13 @@ const makeStrapiResponseJsonWithNull = () => ({ describe('TutorialCodec', () => { it('should decode strapi tutorials', () => { const jsonFromStrapi = makeStrapiResponseJson(); - const actual = StrapiTutorialsCodec.decode(jsonFromStrapi); + const actual = TutorialsCodec.decode(jsonFromStrapi); expect(E.isRight(actual)).toBeTruthy(); }); it('should decode strapi tutorials with nulls', () => { const jsonFromStrapi = makeStrapiResponseJsonWithNull(); - const actual = StrapiTutorialsCodec.decode(jsonFromStrapi); + const actual = TutorialsCodec.decode(jsonFromStrapi); expect(E.isRight(actual)).toBeTruthy(); }); }); diff --git a/apps/nextjs-website/src/lib/strapi/codecs/ApiDataListPagesCodec.ts b/apps/nextjs-website/src/lib/strapi/codecs/ApiDataListPagesCodec.ts index 2e3333a27..61e7bda0f 100644 --- a/apps/nextjs-website/src/lib/strapi/codecs/ApiDataListPagesCodec.ts +++ b/apps/nextjs-website/src/lib/strapi/codecs/ApiDataListPagesCodec.ts @@ -1,5 +1,5 @@ import * as t from 'io-ts/lib'; -import { BaseProductCodec } from './ProductCodec'; +import { BaseProductWithBannerLinksCodec } from './ProductCodec'; import { BannerLinkCodec } from './BannerLinkCodec'; import { ApiDataListCodec } from './ApiDataListCodec'; import { NullToUndefinedCodec } from './NullToUndefinedCodec'; @@ -10,7 +10,7 @@ export const ApiDataListPageCodec = t.strict({ title: t.string, description: t.union([NullToUndefinedCodec, t.string]), product: t.strict({ - data: t.union([NullToUndefinedCodec, BaseProductCodec]), + data: t.union([NullToUndefinedCodec, BaseProductWithBannerLinksCodec]), }), apiData: ApiDataListCodec, bannerLinks: t.array(BannerLinkCodec), diff --git a/apps/nextjs-website/src/lib/strapi/codecs/GuideListPagesCodec.ts b/apps/nextjs-website/src/lib/strapi/codecs/GuideListPagesCodec.ts index 6eea0f829..a627265a6 100644 --- a/apps/nextjs-website/src/lib/strapi/codecs/GuideListPagesCodec.ts +++ b/apps/nextjs-website/src/lib/strapi/codecs/GuideListPagesCodec.ts @@ -1,6 +1,6 @@ import * as t from 'io-ts/lib'; import { BaseGuideCodec } from './GuidesCodec'; -import { BaseProductCodec } from './ProductCodec'; +import { BaseProductWithBannerLinksCodec } from './ProductCodec'; import { PaginationCodec } from './PaginationCodec'; const GuideByCategoryCodec = t.strict({ @@ -15,7 +15,7 @@ const GuideListPageCodec = t.strict({ attributes: t.strict({ title: t.string, description: t.string, - product: t.strict({ data: BaseProductCodec }), + product: t.strict({ data: BaseProductWithBannerLinksCodec }), guidesByCategory: t.array(GuideByCategoryCodec), }), }); diff --git a/apps/nextjs-website/src/lib/strapi/codecs/GuidesCodec.ts b/apps/nextjs-website/src/lib/strapi/codecs/GuidesCodec.ts index 5b5ea0d06..21e79d3c2 100644 --- a/apps/nextjs-website/src/lib/strapi/codecs/GuidesCodec.ts +++ b/apps/nextjs-website/src/lib/strapi/codecs/GuidesCodec.ts @@ -1,7 +1,7 @@ import * as t from 'io-ts/lib'; import { PaginationCodec } from './PaginationCodec'; import { MediaCodec } from '@/lib/strapi/codecs/MediaCodec'; -import { BaseProductCodec } from '@/lib/strapi/codecs/ProductCodec'; +import { BaseProductWithBannerLinksCodec } from '@/lib/strapi/codecs/ProductCodec'; const VersionCodec = t.strict({ main: t.boolean, @@ -30,7 +30,7 @@ export const GuideCodec = t.strict({ BaseGuideAttributesCodec, t.strict({ versions: t.array(VersionCodec), - product: t.strict({ data: BaseProductCodec }), + product: t.strict({ data: BaseProductWithBannerLinksCodec }), }), ]), }); diff --git a/apps/nextjs-website/src/lib/strapi/codecs/HomepageCodec.ts b/apps/nextjs-website/src/lib/strapi/codecs/HomepageCodec.ts index c6263adb3..5b24b944a 100644 --- a/apps/nextjs-website/src/lib/strapi/codecs/HomepageCodec.ts +++ b/apps/nextjs-website/src/lib/strapi/codecs/HomepageCodec.ts @@ -6,7 +6,7 @@ import { RelatedLinksCodec } from './RelatedLinksCodec'; import { MediaCodec } from './MediaCodec'; import { LinkCodec } from './LinkCodec'; import { WebinarCodec } from './WebinarsCodec'; -import { BaseProductCodec } from './ProductCodec'; +import { ProductCodec } from './ProductCodec'; import { SEOCodec } from './SeoCodec'; import { BaseSolutionCodec } from './SolutionsCodec'; @@ -73,7 +73,7 @@ export const HomepageCodec = t.strict({ title: t.union([NullToUndefinedCodec, t.string]), productsTabName: t.string, products: t.strict({ - data: t.array(BaseProductCodec), + data: t.array(ProductCodec), }), solutionsTabName: t.string, solutions: t.strict({ diff --git a/apps/nextjs-website/src/lib/strapi/codecs/ProductCodec.ts b/apps/nextjs-website/src/lib/strapi/codecs/ProductCodec.ts index 8d2ca4719..e136a2d4c 100644 --- a/apps/nextjs-website/src/lib/strapi/codecs/ProductCodec.ts +++ b/apps/nextjs-website/src/lib/strapi/codecs/ProductCodec.ts @@ -14,6 +14,14 @@ const BaseProductAttributesCodec = t.strict({ export const BaseProductCodec = t.strict({ attributes: BaseProductAttributesCodec, }); +export const BaseProductWithBannerLinksCodec = t.strict({ + attributes: t.intersection([ + BaseProductAttributesCodec, + t.strict({ + bannerLinks: t.union([NullToUndefinedCodec, t.array(BannerLinkCodec)]), + }), + ]), +}); export const ProductCodec = t.strict({ attributes: t.intersection([ diff --git a/apps/nextjs-website/src/lib/strapi/codecs/QuickStartGuidesCodec.ts b/apps/nextjs-website/src/lib/strapi/codecs/QuickStartGuidesCodec.ts index bfc5846ed..ed18b4e1a 100644 --- a/apps/nextjs-website/src/lib/strapi/codecs/QuickStartGuidesCodec.ts +++ b/apps/nextjs-website/src/lib/strapi/codecs/QuickStartGuidesCodec.ts @@ -1,7 +1,7 @@ import * as t from 'io-ts/lib'; import * as tt from 'io-ts-types'; import { PaginationCodec } from './PaginationCodec'; -import { BaseProductCodec } from './ProductCodec'; +import { BaseProductWithBannerLinksCodec } from './ProductCodec'; import { PartCodec } from './PartCodec'; const QuickStartGuideItemCodec = t.strict({ @@ -19,7 +19,7 @@ export const QuickStartGuideCodec = t.strict({ attributes: t.strict({ title: t.string, description: t.string, - product: t.strict({ data: BaseProductCodec }), + product: t.strict({ data: BaseProductWithBannerLinksCodec }), quickstartGuideItems: t.strict({ data: t.array(QuickStartGuideItemCodec) }), }), }); diff --git a/apps/nextjs-website/src/lib/strapi/codecs/SolutionsCodec.ts b/apps/nextjs-website/src/lib/strapi/codecs/SolutionsCodec.ts index 1617e785f..a2068e0e4 100644 --- a/apps/nextjs-website/src/lib/strapi/codecs/SolutionsCodec.ts +++ b/apps/nextjs-website/src/lib/strapi/codecs/SolutionsCodec.ts @@ -3,7 +3,7 @@ import * as tt from 'io-ts-types'; import { NullToUndefinedCodec } from './NullToUndefinedCodec'; import { MediaCodec } from './MediaCodec'; import { PaginationCodec } from './PaginationCodec'; -import { BaseProductCodec } from './ProductCodec'; +import { BaseProductCodec, ProductCodec } from './ProductCodec'; import { BlocksContentCodec } from './BlocksContentCodec'; import { BannerLinkCodec } from './BannerLinkCodec'; import { WebinarCodec } from './WebinarsCodec'; @@ -51,7 +51,7 @@ export const SolutionCodec = t.strict({ data: t.array(WebinarCodec), }), products: t.strict({ - data: t.array(BaseProductCodec), + data: t.array(ProductCodec), }), caseHistories: t.union([ NullToUndefinedCodec, diff --git a/apps/nextjs-website/src/lib/strapi/codecs/TutorialCodec.ts b/apps/nextjs-website/src/lib/strapi/codecs/TutorialCodec.ts index 068a4f553..fb60a7ba1 100644 --- a/apps/nextjs-website/src/lib/strapi/codecs/TutorialCodec.ts +++ b/apps/nextjs-website/src/lib/strapi/codecs/TutorialCodec.ts @@ -42,9 +42,9 @@ export const TutorialCodec = t.strict({ ]), }); -export const StrapiTutorialsCodec = t.strict({ +export const TutorialsCodec = t.strict({ data: t.array(TutorialCodec), meta: PaginationCodec, }); -export type StrapiTutorials = t.TypeOf; +export type StrapiTutorials = t.TypeOf; diff --git a/apps/nextjs-website/src/lib/strapi/codecs/TutorialListPagesCodec.ts b/apps/nextjs-website/src/lib/strapi/codecs/TutorialListPagesCodec.ts index 23e3c3a18..aeca0965f 100644 --- a/apps/nextjs-website/src/lib/strapi/codecs/TutorialListPagesCodec.ts +++ b/apps/nextjs-website/src/lib/strapi/codecs/TutorialListPagesCodec.ts @@ -1,25 +1,23 @@ import * as t from 'io-ts/lib'; -import { BaseProductCodec } from './ProductCodec'; +import { BaseProductWithBannerLinksCodec } from './ProductCodec'; import { PaginationCodec } from './PaginationCodec'; import { BannerLinkCodec } from './BannerLinkCodec'; import { BaseTutorialCodec } from './TutorialCodec'; -const StrapiTutorialListPageCodec = t.strict({ +const TutorialListPageCodec = t.strict({ id: t.number, attributes: t.strict({ title: t.string, description: t.string, tutorials: t.strict({ data: t.array(BaseTutorialCodec) }), bannerLinks: t.array(BannerLinkCodec), - product: t.strict({ data: BaseProductCodec }), + product: t.strict({ data: BaseProductWithBannerLinksCodec }), }), }); -export const StrapiTutorialListPagesCodec = t.strict({ - data: t.array(StrapiTutorialListPageCodec), +export const TutorialListPagesCodec = t.strict({ + data: t.array(TutorialListPageCodec), meta: PaginationCodec, }); -export type StrapiTutorialListPages = t.TypeOf< - typeof StrapiTutorialListPagesCodec ->; +export type StrapiTutorialListPages = t.TypeOf; diff --git a/apps/nextjs-website/src/lib/strapi/fetches/fetchApiDataListPages.ts b/apps/nextjs-website/src/lib/strapi/fetches/fetchApiDataListPages.ts index 5fc4facc2..f1cf5f4f4 100644 --- a/apps/nextjs-website/src/lib/strapi/fetches/fetchApiDataListPages.ts +++ b/apps/nextjs-website/src/lib/strapi/fetches/fetchApiDataListPages.ts @@ -14,7 +14,7 @@ const makeStrapiApiDataListPagePopulate = () => }, }, product: { - populate: ['logo'], + populate: ['logo', 'bannerLinks.icon'], }, bannerLinks: { populate: ['icon'], diff --git a/apps/nextjs-website/src/lib/strapi/fetches/fetchGuideListPages.ts b/apps/nextjs-website/src/lib/strapi/fetches/fetchGuideListPages.ts index 10cd2b334..98a9cb276 100644 --- a/apps/nextjs-website/src/lib/strapi/fetches/fetchGuideListPages.ts +++ b/apps/nextjs-website/src/lib/strapi/fetches/fetchGuideListPages.ts @@ -5,7 +5,9 @@ import { GuideListPagesCodec } from '@/lib/strapi/codecs/GuideListPagesCodec'; const makeStrapiGuideListPopulate = () => qs.stringify({ populate: { - product: '*', + product: { + populate: ['logo', 'bannerLinks.icon'], + }, guidesByCategory: { populate: ['guides.mobileImage', 'guides.image', 'guides.listItems'], }, diff --git a/apps/nextjs-website/src/lib/strapi/fetches/fetchGuides.ts b/apps/nextjs-website/src/lib/strapi/fetches/fetchGuides.ts index 02eb55386..3bbd04c75 100644 --- a/apps/nextjs-website/src/lib/strapi/fetches/fetchGuides.ts +++ b/apps/nextjs-website/src/lib/strapi/fetches/fetchGuides.ts @@ -4,7 +4,14 @@ import { GuidesCodec } from '@/lib/strapi/codecs/GuidesCodec'; const makeStrapiGuidesPopulate = () => qs.stringify({ - populate: '*', + populate: [ + 'image', + 'mobileImage', + 'listItems', + 'versions', + 'product.logo', + 'product.bannerLinks.icon', + ], }); export const fetchGuides = fetchFromStrapi( diff --git a/apps/nextjs-website/src/lib/strapi/fetches/fetchHomepage.ts b/apps/nextjs-website/src/lib/strapi/fetches/fetchHomepage.ts index bb860bfd4..9cbb9e2bb 100644 --- a/apps/nextjs-website/src/lib/strapi/fetches/fetchHomepage.ts +++ b/apps/nextjs-website/src/lib/strapi/fetches/fetchHomepage.ts @@ -20,7 +20,12 @@ const makeStrapiHomepagePopulate = () => }, webinars: webinarPopulate, ecosystem: { - populate: ['products.logo', 'solutions.icon', 'solutionsCta.link'], + populate: [ + 'products.logo', + 'products.bannerLinks.icon', + 'solutions.icon', + 'solutionsCta.link', + ], }, seo: { populate: '*,metaImage,metaSocial.image', diff --git a/apps/nextjs-website/src/lib/strapi/fetches/fetchOverviews.ts b/apps/nextjs-website/src/lib/strapi/fetches/fetchOverviews.ts index 866f9f425..5ca9b5c9c 100644 --- a/apps/nextjs-website/src/lib/strapi/fetches/fetchOverviews.ts +++ b/apps/nextjs-website/src/lib/strapi/fetches/fetchOverviews.ts @@ -7,7 +7,7 @@ const makeStrapiOverviewsPopulate = () => populate: { backgroundImage: '*', product: { - populate: ['logo'], + populate: ['logo', 'bannerLinks.icon'], }, relatedLinks: { populate: ['links'], diff --git a/apps/nextjs-website/src/lib/strapi/fetches/fetchQuickStartGuides.ts b/apps/nextjs-website/src/lib/strapi/fetches/fetchQuickStartGuides.ts index ca6db465e..1e99a0547 100644 --- a/apps/nextjs-website/src/lib/strapi/fetches/fetchQuickStartGuides.ts +++ b/apps/nextjs-website/src/lib/strapi/fetches/fetchQuickStartGuides.ts @@ -9,7 +9,7 @@ const makeStrapiQuickStartGuidesPopulate = () => populate: 'parts.responseCode,parts.requestCode,parts.requestAttributes', }, - product: { populate: 'logo' }, + product: { populate: ['logo', 'bannerLinks.icon'] }, }, }); diff --git a/apps/nextjs-website/src/lib/strapi/fetches/fetchTutorialListPages.ts b/apps/nextjs-website/src/lib/strapi/fetches/fetchTutorialListPages.ts index 0a3cd3273..cab425e8f 100644 --- a/apps/nextjs-website/src/lib/strapi/fetches/fetchTutorialListPages.ts +++ b/apps/nextjs-website/src/lib/strapi/fetches/fetchTutorialListPages.ts @@ -1,11 +1,13 @@ import * as qs from 'qs'; import { fetchFromStrapi } from '../fetchFromStrapi'; -import { StrapiTutorialListPagesCodec } from '../codecs/TutorialListPagesCodec'; +import { TutorialListPagesCodec } from '../codecs/TutorialListPagesCodec'; const makeStrapiTutorialListPagePopulate = () => qs.stringify({ populate: { - product: '*', + product: { + populate: ['bannerLinks.icon'], + }, tutorials: { populate: ['image', 'product'], }, @@ -18,5 +20,5 @@ const makeStrapiTutorialListPagePopulate = () => export const fetchTutorialListPages = fetchFromStrapi( 'tutorial-list-pages', makeStrapiTutorialListPagePopulate(), - StrapiTutorialListPagesCodec + TutorialListPagesCodec ); diff --git a/apps/nextjs-website/src/lib/strapi/fetches/fetchTutorials.ts b/apps/nextjs-website/src/lib/strapi/fetches/fetchTutorials.ts index ca99983a1..2347ae59b 100644 --- a/apps/nextjs-website/src/lib/strapi/fetches/fetchTutorials.ts +++ b/apps/nextjs-website/src/lib/strapi/fetches/fetchTutorials.ts @@ -1,6 +1,6 @@ import * as qs from 'qs'; import { fetchFromStrapi } from '../fetchFromStrapi'; -import { StrapiTutorialsCodec } from '../codecs/TutorialCodec'; +import { TutorialsCodec } from '../codecs/TutorialCodec'; const makeStrapiTutorialsPopulate = () => qs.stringify({ @@ -12,7 +12,9 @@ const makeStrapiTutorialsPopulate = () => populate: ['image'], }, parts: '*', - product: { populate: 'logo' }, + product: { + populate: ['logo', 'bannerLinks.icon'], + }, bannerLinks: { populate: ['icon'], }, @@ -22,5 +24,5 @@ const makeStrapiTutorialsPopulate = () => export const fetchTutorials = fetchFromStrapi( 'tutorials', makeStrapiTutorialsPopulate(), - StrapiTutorialsCodec + TutorialsCodec ); diff --git a/apps/nextjs-website/src/lib/strapi/makeProps/makeGuideListPages.ts b/apps/nextjs-website/src/lib/strapi/makeProps/makeGuideListPages.ts index caaf99d2b..1b11bb3c6 100644 --- a/apps/nextjs-website/src/lib/strapi/makeProps/makeGuideListPages.ts +++ b/apps/nextjs-website/src/lib/strapi/makeProps/makeGuideListPages.ts @@ -1,7 +1,7 @@ import { GuidesPageProps } from '@/app/[productSlug]/guides/page'; import { StrapiGuideListPages } from '../codecs/GuideListPagesCodec'; -import { mergeProductWithStaticContent } from './makeProducts'; import { GuidesSectionProps } from '@/components/molecules/GuidesSection/GuidesSection'; +import { mergeProductWithStaticContent } from '@/lib/strapi/makeProps/makeProducts'; type StaticGuideListPages = readonly GuidesPageProps[]; diff --git a/apps/nextjs-website/src/lib/strapi/makeProps/makeProducts.ts b/apps/nextjs-website/src/lib/strapi/makeProps/makeProducts.ts index 2b59a5ff2..27a6ef815 100644 --- a/apps/nextjs-website/src/lib/strapi/makeProps/makeProducts.ts +++ b/apps/nextjs-website/src/lib/strapi/makeProps/makeProducts.ts @@ -15,6 +15,12 @@ export function mergeProductWithStaticContent( ...staticProduct, ...attributes, logo: attributes.logo?.data.attributes || staticProduct.logo, + bannerLinks: [ + ...(attributes.bannerLinks?.map((item) => ({ + ...item, + icon: item.icon?.data.attributes, + })) || []), + ], }; } From 2630da29cd22cd3c5d0667d1b25d411d511b092a Mon Sep 17 00:00:00 2001 From: Marco Bottaro Date: Mon, 23 Sep 2024 14:17:17 +0200 Subject: [PATCH 04/43] Move fetchProducts to a dedicated file --- apps/nextjs-website/src/lib/cmsApi.ts | 2 +- .../src/lib/strapi/codecs/ProductCodec.ts | 13 ------------- .../src/lib/strapi/fetches/fetchProducts.ts | 14 ++++++++++++++ 3 files changed, 15 insertions(+), 14 deletions(-) create mode 100644 apps/nextjs-website/src/lib/strapi/fetches/fetchProducts.ts diff --git a/apps/nextjs-website/src/lib/cmsApi.ts b/apps/nextjs-website/src/lib/cmsApi.ts index 194d76fe1..95173d981 100644 --- a/apps/nextjs-website/src/lib/cmsApi.ts +++ b/apps/nextjs-website/src/lib/cmsApi.ts @@ -36,7 +36,7 @@ import { fetchApiDataListPages } from './strapi/fetches/fetchApiDataListPages'; import { makeApiDataListPagesProps } from './strapi/makeProps/makeApiDataListPages'; import { makeApiDataListProps } from './strapi/makeProps/makeApiDataList'; import { fetchApiDataList } from './strapi/fetches/fetchApiDataList'; -import { fetchProducts } from './strapi/codecs/ProductCodec'; +import { fetchProducts } from '@/lib/strapi/fetches/fetchProducts'; import { makeProductsProps } from './strapi/makeProps/makeProducts'; import { fetchGuideListPages } from './strapi/fetches/fetchGuideListPages'; import { makeGuideListPagesProps } from './strapi/makeProps/makeGuideListPages'; diff --git a/apps/nextjs-website/src/lib/strapi/codecs/ProductCodec.ts b/apps/nextjs-website/src/lib/strapi/codecs/ProductCodec.ts index e136a2d4c..86e9fea03 100644 --- a/apps/nextjs-website/src/lib/strapi/codecs/ProductCodec.ts +++ b/apps/nextjs-website/src/lib/strapi/codecs/ProductCodec.ts @@ -1,8 +1,6 @@ import * as t from 'io-ts/lib'; import { MediaCodec } from './MediaCodec'; import { NullToUndefinedCodec } from './NullToUndefinedCodec'; -import qs from 'qs'; -import { fetchFromStrapi } from '../fetchFromStrapi'; import { BannerLinkCodec } from '@/lib/strapi/codecs/BannerLinkCodec'; const BaseProductAttributesCodec = t.strict({ @@ -41,14 +39,3 @@ export const ProductsCodec = t.strict({ export type BaseProduct = t.TypeOf; export type Product = t.TypeOf; export type Products = t.TypeOf; - -const makeStrapiProductsPopulate = () => - qs.stringify({ - populate: '*', - }); - -export const fetchProducts = fetchFromStrapi( - 'products', - makeStrapiProductsPopulate(), - ProductsCodec -); diff --git a/apps/nextjs-website/src/lib/strapi/fetches/fetchProducts.ts b/apps/nextjs-website/src/lib/strapi/fetches/fetchProducts.ts new file mode 100644 index 000000000..08c37d656 --- /dev/null +++ b/apps/nextjs-website/src/lib/strapi/fetches/fetchProducts.ts @@ -0,0 +1,14 @@ +import { fetchFromStrapi } from '@/lib/strapi/fetchFromStrapi'; +import { ProductsCodec } from '@/lib/strapi/codecs/ProductCodec'; +import qs from 'qs'; + +const makeStrapiProductsPopulate = () => + qs.stringify({ + populate: ['logo', 'bannerLinks.icon'], + }); + +export const fetchProducts = fetchFromStrapi( + 'products', + makeStrapiProductsPopulate(), + ProductsCodec +); From f2c4763747f277a98593a849ea319a57243546cb Mon Sep 17 00:00:00 2001 From: Marco Bottaro Date: Mon, 23 Sep 2024 17:32:16 +0200 Subject: [PATCH 05/43] Add relationships to Product codec --- .../lib/strapi/__tests__/fixtures/product.ts | 5 ++ .../src/lib/strapi/codecs/ApiDataListCodec.ts | 2 +- .../lib/strapi/codecs/GuideListPagesCodec.ts | 2 +- .../src/lib/strapi/codecs/OverviewsCodec.ts | 42 ++++++++------ .../src/lib/strapi/codecs/ProductCodec.ts | 57 +++++++++++++++++++ .../strapi/codecs/TutorialListPagesCodec.ts | 2 +- .../src/lib/strapi/fetches/fetchProducts.ts | 10 +++- 7 files changed, 100 insertions(+), 20 deletions(-) diff --git a/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/product.ts b/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/product.ts index 86a4fcd29..c667e3252 100644 --- a/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/product.ts +++ b/apps/nextjs-website/src/lib/strapi/__tests__/fixtures/product.ts @@ -27,6 +27,11 @@ export const productJson = { shortName: 'Firma con IO', logo: mediaVectorJson, bannerLinks: bannerLinksJson, + overview: { data: null }, + quickstart_guide: { data: null }, + api_data_list_page: { data: null }, + tutorial_list_page: { data: null }, + guide_list_page: { data: null }, }, }, }; diff --git a/apps/nextjs-website/src/lib/strapi/codecs/ApiDataListCodec.ts b/apps/nextjs-website/src/lib/strapi/codecs/ApiDataListCodec.ts index 41e8afb18..36673365e 100644 --- a/apps/nextjs-website/src/lib/strapi/codecs/ApiDataListCodec.ts +++ b/apps/nextjs-website/src/lib/strapi/codecs/ApiDataListCodec.ts @@ -9,7 +9,7 @@ const UrlCodec = t.strict({ hideTryIt: t.boolean, }); -const ApiDataCodec = t.strict({ +export const ApiDataCodec = t.strict({ id: t.number, attributes: t.strict({ title: t.string, diff --git a/apps/nextjs-website/src/lib/strapi/codecs/GuideListPagesCodec.ts b/apps/nextjs-website/src/lib/strapi/codecs/GuideListPagesCodec.ts index a627265a6..2944138c6 100644 --- a/apps/nextjs-website/src/lib/strapi/codecs/GuideListPagesCodec.ts +++ b/apps/nextjs-website/src/lib/strapi/codecs/GuideListPagesCodec.ts @@ -10,7 +10,7 @@ const GuideByCategoryCodec = t.strict({ }), }); -const GuideListPageCodec = t.strict({ +export const GuideListPageCodec = t.strict({ id: t.number, attributes: t.strict({ title: t.string, diff --git a/apps/nextjs-website/src/lib/strapi/codecs/OverviewsCodec.ts b/apps/nextjs-website/src/lib/strapi/codecs/OverviewsCodec.ts index 68f712f4a..b3f363670 100644 --- a/apps/nextjs-website/src/lib/strapi/codecs/OverviewsCodec.ts +++ b/apps/nextjs-website/src/lib/strapi/codecs/OverviewsCodec.ts @@ -57,25 +57,35 @@ const PostIntegrationCodec = t.strict({ serviceModels: t.array(ServiceModelCodec), }); +const BaseOverviewAttributesCodec = t.strict({ + title: t.string, + createdAt: tt.DateFromISOString, + updatedAt: tt.DateFromISOString, + publishedAt: tt.DateFromISOString, + subtitle: t.string, +}); + +export const BaseOverviewCodec = t.strict({ + attributes: BaseOverviewAttributesCodec, +}); + export const OverviewCodec = t.strict({ id: t.number, - attributes: t.strict({ - title: t.string, - createdAt: tt.DateFromISOString, - updatedAt: tt.DateFromISOString, - publishedAt: tt.DateFromISOString, - subtitle: t.string, - backgroundImage: t.strict({ data: MediaCodec }), - features: t.union([NullToUndefinedCodec, FeaturesCodec]), - startInfoSection: t.union([NullToUndefinedCodec, StartInfoSectionCodec]), - tutorialSection: t.union([NullToUndefinedCodec, TutorialSectionCodec]), - postIntegration: t.union([NullToUndefinedCodec, PostIntegrationCodec]), - relatedLinks: t.union([NullToUndefinedCodec, RelatedLinksCodec]), - product: t.strict({ - data: t.union([NullToUndefinedCodec, ProductCodec]), + attributes: t.intersection([ + BaseOverviewAttributesCodec, + t.strict({ + backgroundImage: t.strict({ data: MediaCodec }), + features: t.union([NullToUndefinedCodec, FeaturesCodec]), + startInfoSection: t.union([NullToUndefinedCodec, StartInfoSectionCodec]), + tutorialSection: t.union([NullToUndefinedCodec, TutorialSectionCodec]), + postIntegration: t.union([NullToUndefinedCodec, PostIntegrationCodec]), + relatedLinks: t.union([NullToUndefinedCodec, RelatedLinksCodec]), + product: t.strict({ + data: t.union([NullToUndefinedCodec, ProductCodec]), + }), + bannerLinks: t.array(BannerLinkCodec), }), - bannerLinks: t.array(BannerLinkCodec), - }), + ]), }); export const OverviewsCodec = t.strict({ diff --git a/apps/nextjs-website/src/lib/strapi/codecs/ProductCodec.ts b/apps/nextjs-website/src/lib/strapi/codecs/ProductCodec.ts index 86e9fea03..9d02b81d4 100644 --- a/apps/nextjs-website/src/lib/strapi/codecs/ProductCodec.ts +++ b/apps/nextjs-website/src/lib/strapi/codecs/ProductCodec.ts @@ -9,9 +9,54 @@ const BaseProductAttributesCodec = t.strict({ slug: t.string, }); +// To avoid circular dependencies, we can use the following codec: +const ApiDataListPageCodec = t.strict({ + data: t.union([ + NullToUndefinedCodec, + t.strict({ + id: t.number, + attributes: t.strict({ + apiData: t.strict({ + data: t.array( + t.strict({ + id: t.number, + attributes: t.strict({ + apiRestDetail: t.union([ + NullToUndefinedCodec, + t.strict({ + slug: t.string, + }), + ]), + apiSoapUrl: t.union([NullToUndefinedCodec, t.string]), + }), + }) + ), + }), + }), + }), + ]), +}); + export const BaseProductCodec = t.strict({ attributes: BaseProductAttributesCodec, }); + +export const ProductRelationshipsCodec = t.strict({ + overview: t.strict({ + data: t.union([NullToUndefinedCodec, t.strict({ id: t.number })]), + }), + quickstart_guide: t.strict({ + data: t.union([NullToUndefinedCodec, t.strict({ id: t.number })]), + }), + api_data_list_page: ApiDataListPageCodec, + tutorial_list_page: t.strict({ + data: t.union([NullToUndefinedCodec, t.strict({ id: t.number })]), + }), + guide_list_page: t.strict({ + data: t.union([NullToUndefinedCodec, t.strict({ id: t.number })]), + }), +}); + export const BaseProductWithBannerLinksCodec = t.strict({ attributes: t.intersection([ BaseProductAttributesCodec, @@ -32,6 +77,18 @@ export const ProductCodec = t.strict({ ]), }); +export const ProductWithRelationshipsCodec = t.strict({ + attributes: t.intersection([ + BaseProductAttributesCodec, + ProductRelationshipsCodec, + t.strict({ + description: t.union([NullToUndefinedCodec, t.string]), + logo: t.strict({ data: MediaCodec }), + bannerLinks: t.union([NullToUndefinedCodec, t.array(BannerLinkCodec)]), + }), + ]), +}); + export const ProductsCodec = t.strict({ data: t.array(ProductCodec), }); diff --git a/apps/nextjs-website/src/lib/strapi/codecs/TutorialListPagesCodec.ts b/apps/nextjs-website/src/lib/strapi/codecs/TutorialListPagesCodec.ts index aeca0965f..c8b5f454a 100644 --- a/apps/nextjs-website/src/lib/strapi/codecs/TutorialListPagesCodec.ts +++ b/apps/nextjs-website/src/lib/strapi/codecs/TutorialListPagesCodec.ts @@ -4,7 +4,7 @@ import { PaginationCodec } from './PaginationCodec'; import { BannerLinkCodec } from './BannerLinkCodec'; import { BaseTutorialCodec } from './TutorialCodec'; -const TutorialListPageCodec = t.strict({ +export const TutorialListPageCodec = t.strict({ id: t.number, attributes: t.strict({ title: t.string, diff --git a/apps/nextjs-website/src/lib/strapi/fetches/fetchProducts.ts b/apps/nextjs-website/src/lib/strapi/fetches/fetchProducts.ts index 08c37d656..50c753672 100644 --- a/apps/nextjs-website/src/lib/strapi/fetches/fetchProducts.ts +++ b/apps/nextjs-website/src/lib/strapi/fetches/fetchProducts.ts @@ -4,7 +4,15 @@ import qs from 'qs'; const makeStrapiProductsPopulate = () => qs.stringify({ - populate: ['logo', 'bannerLinks.icon'], + populate: [ + 'logo', + 'bannerLinks.icon', + 'overview', + 'quickstart_guide', + 'api_data_list_page', + 'guide_list_page', + 'tutorial_list_page', + ], }); export const fetchProducts = fetchFromStrapi( From e862bda91f5fe1a84b03b8c690e49790dccfcf30 Mon Sep 17 00:00:00 2001 From: Marco Bottaro Date: Mon, 23 Sep 2024 17:39:43 +0200 Subject: [PATCH 06/43] Add changeset --- .changeset/quiet-foxes-reflect.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/quiet-foxes-reflect.md diff --git a/.changeset/quiet-foxes-reflect.md b/.changeset/quiet-foxes-reflect.md new file mode 100644 index 000000000..f5b833b0f --- /dev/null +++ b/.changeset/quiet-foxes-reflect.md @@ -0,0 +1,5 @@ +--- +"nextjs-website": patch +--- + +Add the bannerLinks attribute to the product codec and refactor its relationships From 6aae6f24643e521466d95359307f405cca77c33b Mon Sep 17 00:00:00 2001 From: Marco Bottaro Date: Mon, 23 Sep 2024 17:41:04 +0200 Subject: [PATCH 07/43] Fix comment --- apps/nextjs-website/src/lib/strapi/codecs/ProductCodec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/nextjs-website/src/lib/strapi/codecs/ProductCodec.ts b/apps/nextjs-website/src/lib/strapi/codecs/ProductCodec.ts index 9d02b81d4..3f7143c00 100644 --- a/apps/nextjs-website/src/lib/strapi/codecs/ProductCodec.ts +++ b/apps/nextjs-website/src/lib/strapi/codecs/ProductCodec.ts @@ -9,7 +9,7 @@ const BaseProductAttributesCodec = t.strict({ slug: t.string, }); -// To avoid circular dependencies, we can use the following codec: +// To avoid circular dependencies, we must use the following codec: const ApiDataListPageCodec = t.strict({ data: t.union([ NullToUndefinedCodec, From 40cc2147e7ba4300123e770b5bb9360c86013405 Mon Sep 17 00:00:00 2001 From: Marco Bottaro Date: Wed, 25 Sep 2024 11:23:47 +0200 Subject: [PATCH 08/43] Fix linting --- apps/nextjs-website/src/lib/strapi/codecs/OverviewsCodec.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/nextjs-website/src/lib/strapi/codecs/OverviewsCodec.ts b/apps/nextjs-website/src/lib/strapi/codecs/OverviewsCodec.ts index 415de6923..8960de9bf 100644 --- a/apps/nextjs-website/src/lib/strapi/codecs/OverviewsCodec.ts +++ b/apps/nextjs-website/src/lib/strapi/codecs/OverviewsCodec.ts @@ -85,7 +85,8 @@ export const OverviewCodec = t.strict({ data: t.union([NullToUndefinedCodec, ProductCodec]), }), bannerLinks: t.array(BannerLinkCodec), - seo: t.union([NullToUndefinedCodec, SEOCodec]),}), + seo: t.union([NullToUndefinedCodec, SEOCodec]), + }), ]), }); From 830559096cf59ed12c1ccd57f14933e0427c7937 Mon Sep 17 00:00:00 2001 From: Marco Bottaro Date: Wed, 25 Sep 2024 11:38:39 +0200 Subject: [PATCH 09/43] Add seo to makeStrapiGuidesPopulate --- apps/nextjs-website/src/lib/strapi/fetches/fetchGuides.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/apps/nextjs-website/src/lib/strapi/fetches/fetchGuides.ts b/apps/nextjs-website/src/lib/strapi/fetches/fetchGuides.ts index 3bbd04c75..667c77a06 100644 --- a/apps/nextjs-website/src/lib/strapi/fetches/fetchGuides.ts +++ b/apps/nextjs-website/src/lib/strapi/fetches/fetchGuides.ts @@ -9,6 +9,8 @@ const makeStrapiGuidesPopulate = () => 'mobileImage', 'listItems', 'versions', + 'seo', + 'seo.metaSocial.image', 'product.logo', 'product.bannerLinks.icon', ], From 8cd2b48898e3fe5cc3ceb41d77d8bb36231fe4e0 Mon Sep 17 00:00:00 2001 From: Marco Bottaro Date: Mon, 30 Sep 2024 10:06:54 +0200 Subject: [PATCH 10/43] Remove unused BaseOverviewAttributesCodec and BaseOverviewCodec --- .../src/lib/strapi/codecs/OverviewsCodec.ts | 44 +++++++------------ 1 file changed, 17 insertions(+), 27 deletions(-) diff --git a/apps/nextjs-website/src/lib/strapi/codecs/OverviewsCodec.ts b/apps/nextjs-website/src/lib/strapi/codecs/OverviewsCodec.ts index 8960de9bf..d102a80b4 100644 --- a/apps/nextjs-website/src/lib/strapi/codecs/OverviewsCodec.ts +++ b/apps/nextjs-website/src/lib/strapi/codecs/OverviewsCodec.ts @@ -58,36 +58,26 @@ const PostIntegrationCodec = t.strict({ serviceModels: t.array(ServiceModelCodec), }); -const BaseOverviewAttributesCodec = t.strict({ - title: t.string, - createdAt: tt.DateFromISOString, - updatedAt: tt.DateFromISOString, - publishedAt: tt.DateFromISOString, - subtitle: t.string, -}); - -export const BaseOverviewCodec = t.strict({ - attributes: BaseOverviewAttributesCodec, -}); - export const OverviewCodec = t.strict({ id: t.number, - attributes: t.intersection([ - BaseOverviewAttributesCodec, - t.strict({ - backgroundImage: t.strict({ data: MediaCodec }), - features: t.union([NullToUndefinedCodec, FeaturesCodec]), - startInfoSection: t.union([NullToUndefinedCodec, StartInfoSectionCodec]), - tutorialSection: t.union([NullToUndefinedCodec, TutorialSectionCodec]), - postIntegration: t.union([NullToUndefinedCodec, PostIntegrationCodec]), - relatedLinks: t.union([NullToUndefinedCodec, RelatedLinksCodec]), - product: t.strict({ - data: t.union([NullToUndefinedCodec, ProductCodec]), - }), - bannerLinks: t.array(BannerLinkCodec), - seo: t.union([NullToUndefinedCodec, SEOCodec]), + attributes: t.strict({ + title: t.string, + createdAt: tt.DateFromISOString, + updatedAt: tt.DateFromISOString, + publishedAt: tt.DateFromISOString, + subtitle: t.string, + backgroundImage: t.strict({ data: MediaCodec }), + features: t.union([NullToUndefinedCodec, FeaturesCodec]), + startInfoSection: t.union([NullToUndefinedCodec, StartInfoSectionCodec]), + tutorialSection: t.union([NullToUndefinedCodec, TutorialSectionCodec]), + postIntegration: t.union([NullToUndefinedCodec, PostIntegrationCodec]), + relatedLinks: t.union([NullToUndefinedCodec, RelatedLinksCodec]), + product: t.strict({ + data: t.union([NullToUndefinedCodec, ProductCodec]), }), - ]), + bannerLinks: t.array(BannerLinkCodec), + seo: t.union([NullToUndefinedCodec, SEOCodec]), + }), }); export const OverviewsCodec = t.strict({ From f87bff52d42a2df5c7d1691743aaf8a8d11473fa Mon Sep 17 00:00:00 2001 From: t Date: Wed, 2 Oct 2024 00:26:24 +0200 Subject: [PATCH 11/43] data preparation --- .../TutorialTemplate/TutorialTemplate.tsx | 2 +- .../src/helpers/structuredData.helpers.ts | 6 +++--- apps/nextjs-website/src/lib/api.ts | 8 ++++---- .../src/lib/strapi/codecs/ProductCodec.ts | 11 ----------- .../src/lib/strapi/makeProps/makeProducts.ts | 5 +++++ apps/nextjs-website/src/lib/types/product.ts | 14 ++++++++++++++ 6 files changed, 27 insertions(+), 19 deletions(-) diff --git a/apps/nextjs-website/src/components/templates/TutorialTemplate/TutorialTemplate.tsx b/apps/nextjs-website/src/components/templates/TutorialTemplate/TutorialTemplate.tsx index b1221c2a4..c8af630e9 100644 --- a/apps/nextjs-website/src/components/templates/TutorialTemplate/TutorialTemplate.tsx +++ b/apps/nextjs-website/src/components/templates/TutorialTemplate/TutorialTemplate.tsx @@ -35,7 +35,7 @@ const TutorialTemplate = ({ product={product} path={path} structuredData={structuredData} - // bannerLinks={bannerLinks} // TODO: Enable this property once the bannerLinks refactor will be completed + // bannerLinks={bannerLinks} // TODO: Enable this property once the bannerLinks refactor will be completed > {product && ( { const steps: readonly HowToStep[] = quickStart.steps ? quickStart.steps.map((step) => ({ - '@type': 'HowToStep', - text: step.title, - })) + '@type': 'HowToStep', + text: step.title, + })) : []; return makeHowTo({ name: quickStart.seo?.metaTitle, diff --git a/apps/nextjs-website/src/lib/api.ts b/apps/nextjs-website/src/lib/api.ts index 6702eade8..d5025cbd5 100644 --- a/apps/nextjs-website/src/lib/api.ts +++ b/apps/nextjs-website/src/lib/api.ts @@ -86,7 +86,7 @@ export function getProductsSlugs( } export async function getProducts(): Promise { - return [...products]; + return await getProductsProps(); } export async function getQuickStartGuide(productSlug?: string) { @@ -115,9 +115,9 @@ export async function getStrapiTutorial( return tutorialFromStrapi ? { - ...tutorialFromStrapi, - product: products.find(({ slug }) => slug === productSlug), - } + ...tutorialFromStrapi, + product: products.find(({ slug }) => slug === productSlug), + } : undefined; } diff --git a/apps/nextjs-website/src/lib/strapi/codecs/ProductCodec.ts b/apps/nextjs-website/src/lib/strapi/codecs/ProductCodec.ts index 3f7143c00..ff2e725ff 100644 --- a/apps/nextjs-website/src/lib/strapi/codecs/ProductCodec.ts +++ b/apps/nextjs-website/src/lib/strapi/codecs/ProductCodec.ts @@ -67,17 +67,6 @@ export const BaseProductWithBannerLinksCodec = t.strict({ }); export const ProductCodec = t.strict({ - attributes: t.intersection([ - BaseProductAttributesCodec, - t.strict({ - description: t.union([NullToUndefinedCodec, t.string]), - logo: t.strict({ data: MediaCodec }), - bannerLinks: t.union([NullToUndefinedCodec, t.array(BannerLinkCodec)]), - }), - ]), -}); - -export const ProductWithRelationshipsCodec = t.strict({ attributes: t.intersection([ BaseProductAttributesCodec, ProductRelationshipsCodec, diff --git a/apps/nextjs-website/src/lib/strapi/makeProps/makeProducts.ts b/apps/nextjs-website/src/lib/strapi/makeProps/makeProducts.ts index 27a6ef815..b2a4d02f0 100644 --- a/apps/nextjs-website/src/lib/strapi/makeProps/makeProducts.ts +++ b/apps/nextjs-website/src/lib/strapi/makeProps/makeProducts.ts @@ -21,6 +21,11 @@ export function mergeProductWithStaticContent( icon: item.icon?.data.attributes, })) || []), ], + api_data_list_page: attributes.api_data_list_page, + tutorial_list_page: attributes.tutorial_list_page, + guide_list_page: attributes.guide_list_page, + overview: attributes.overview, + quickstart_guide: attributes.quickstart_guide, }; } diff --git a/apps/nextjs-website/src/lib/types/product.ts b/apps/nextjs-website/src/lib/types/product.ts index 921678f19..964d42f0a 100644 --- a/apps/nextjs-website/src/lib/types/product.ts +++ b/apps/nextjs-website/src/lib/types/product.ts @@ -1,6 +1,7 @@ import { Path } from '@/lib/types/path'; import { Media } from '@/lib/strapi/codecs/MediaCodec'; import { BannerLinkProps } from '@/components/atoms/BannerLink/BannerLink'; +import { Product as ApiProduct } from '@/lib/strapi/codecs/ProductCodec'; export type Product = { readonly slug: string; @@ -9,6 +10,19 @@ export type Product = { readonly logo: Media; readonly subpaths: Subpaths; readonly bannerLinks: readonly BannerLinkProps[]; + readonly api_data_list_page?: + | ApiProduct['attributes']['api_data_list_page'] + | undefined; + readonly tutorial_list_page?: + | ApiProduct['attributes']['tutorial_list_page'] + | undefined; + readonly guide_list_page?: + | ApiProduct['attributes']['guide_list_page'] + | undefined; + readonly overview?: ApiProduct['attributes']['overview'] | undefined; + readonly quickstart_guide?: + | ApiProduct['attributes']['quickstart_guide'] + | undefined; } & Path; type Subpaths = { From 9eb163e60ca7634db2fbfe4eccd20696d9e17672 Mon Sep 17 00:00:00 2001 From: t Date: Wed, 2 Oct 2024 14:29:45 +0200 Subject: [PATCH 12/43] populate --- .../templates/TutorialTemplate/TutorialTemplate.tsx | 2 +- .../nextjs-website/src/lib/strapi/fetches/fetchHomepage.ts | 7 +++++++ .../nextjs-website/src/lib/strapi/fetches/fetchProducts.ts | 7 +++++-- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/apps/nextjs-website/src/components/templates/TutorialTemplate/TutorialTemplate.tsx b/apps/nextjs-website/src/components/templates/TutorialTemplate/TutorialTemplate.tsx index c8af630e9..b1221c2a4 100644 --- a/apps/nextjs-website/src/components/templates/TutorialTemplate/TutorialTemplate.tsx +++ b/apps/nextjs-website/src/components/templates/TutorialTemplate/TutorialTemplate.tsx @@ -35,7 +35,7 @@ const TutorialTemplate = ({ product={product} path={path} structuredData={structuredData} - // bannerLinks={bannerLinks} // TODO: Enable this property once the bannerLinks refactor will be completed + // bannerLinks={bannerLinks} // TODO: Enable this property once the bannerLinks refactor will be completed > {product && ( populate: [ 'products.logo', 'products.bannerLinks.icon', + 'products.overview', + 'products.quickstart_guide', + 'products.api_data_list_page', + 'products.api_data_list_page.apiData.*', + 'products.api_data_list_page.apiData.apiRestDetail.*', + 'products.guide_list_page', + 'products.tutorial_list_page', 'solutions.icon', 'solutions.product.logo', 'solutionsCta.link', diff --git a/apps/nextjs-website/src/lib/strapi/fetches/fetchProducts.ts b/apps/nextjs-website/src/lib/strapi/fetches/fetchProducts.ts index 50c753672..31c87807b 100644 --- a/apps/nextjs-website/src/lib/strapi/fetches/fetchProducts.ts +++ b/apps/nextjs-website/src/lib/strapi/fetches/fetchProducts.ts @@ -2,18 +2,21 @@ import { fetchFromStrapi } from '@/lib/strapi/fetchFromStrapi'; import { ProductsCodec } from '@/lib/strapi/codecs/ProductCodec'; import qs from 'qs'; -const makeStrapiProductsPopulate = () => - qs.stringify({ +const makeStrapiProductsPopulate = () => { + return qs.stringify({ populate: [ 'logo', 'bannerLinks.icon', 'overview', 'quickstart_guide', 'api_data_list_page', + 'api_data_list_page.apiData.*', + 'api_data_list_page.apiData.apiRestDetail.*', 'guide_list_page', 'tutorial_list_page', ], }); +}; export const fetchProducts = fetchFromStrapi( 'products', From 21a70ee2f2d6dd973760a50cd21ed91da7e41235 Mon Sep 17 00:00:00 2001 From: t Date: Wed, 2 Oct 2024 14:33:20 +0200 Subject: [PATCH 13/43] linter --- apps/nextjs-website/src/helpers/structuredData.helpers.ts | 6 +++--- apps/nextjs-website/src/lib/api.ts | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/apps/nextjs-website/src/helpers/structuredData.helpers.ts b/apps/nextjs-website/src/helpers/structuredData.helpers.ts index 08a9663fb..beb794ebb 100644 --- a/apps/nextjs-website/src/helpers/structuredData.helpers.ts +++ b/apps/nextjs-website/src/helpers/structuredData.helpers.ts @@ -158,9 +158,9 @@ export function quickStartToStructuredDataHowTo( ): WithContext { const steps: readonly HowToStep[] = quickStart.steps ? quickStart.steps.map((step) => ({ - '@type': 'HowToStep', - text: step.title, - })) + '@type': 'HowToStep', + text: step.title, + })) : []; return makeHowTo({ name: quickStart.seo?.metaTitle, diff --git a/apps/nextjs-website/src/lib/api.ts b/apps/nextjs-website/src/lib/api.ts index d5025cbd5..990fb2aad 100644 --- a/apps/nextjs-website/src/lib/api.ts +++ b/apps/nextjs-website/src/lib/api.ts @@ -115,9 +115,9 @@ export async function getStrapiTutorial( return tutorialFromStrapi ? { - ...tutorialFromStrapi, - product: products.find(({ slug }) => slug === productSlug), - } + ...tutorialFromStrapi, + product: products.find(({ slug }) => slug === productSlug), + } : undefined; } From ce3abfff1114d6b076afa2a749c741b570647833 Mon Sep 17 00:00:00 2001 From: t Date: Wed, 2 Oct 2024 15:14:07 +0200 Subject: [PATCH 14/43] filter out products not having overview --- .../molecules/DesktopSiteHeader/DesktopSiteHeader.tsx | 11 +++++++++-- .../molecules/MobileSiteHeader/MobileSiteHeader.tsx | 11 +++++++++-- .../components/molecules/SiteHeader/SiteHeader.tsx | 5 ----- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/apps/nextjs-website/src/components/molecules/DesktopSiteHeader/DesktopSiteHeader.tsx b/apps/nextjs-website/src/components/molecules/DesktopSiteHeader/DesktopSiteHeader.tsx index 452c53ffb..e47d7fcb6 100644 --- a/apps/nextjs-website/src/components/molecules/DesktopSiteHeader/DesktopSiteHeader.tsx +++ b/apps/nextjs-website/src/components/molecules/DesktopSiteHeader/DesktopSiteHeader.tsx @@ -2,13 +2,20 @@ import Dropdown from '@/components/atoms/Dropdown/Dropdown'; import { Box, Link as LinkMui } from '@mui/material'; import Link from 'next/link'; import DesktopUserInfo from '@/components/atoms/DesktopUserInfo/DesktopUserInfo'; -import React from 'react'; +import React, { useMemo } from 'react'; import { SiteHeaderProps } from '@/components/molecules/SiteHeader/SiteHeader'; import { useTranslations } from 'next-intl'; +import { Product } from '@/lib/types/product'; const DesktopSiteHeader = ({ products }: SiteHeaderProps) => { const t = useTranslations('devPortal'); + // Filter out products that don't have an overview page + const filteredProducts = useMemo( + () => products.filter((product: Product) => product.overview?.data), + [products] + ); + return ( { > ({ + items={filteredProducts.map((product) => ({ href: product.subpaths.overview.path, label: product.name, }))} diff --git a/apps/nextjs-website/src/components/molecules/MobileSiteHeader/MobileSiteHeader.tsx b/apps/nextjs-website/src/components/molecules/MobileSiteHeader/MobileSiteHeader.tsx index 447ccf6ba..2e50c24e6 100644 --- a/apps/nextjs-website/src/components/molecules/MobileSiteHeader/MobileSiteHeader.tsx +++ b/apps/nextjs-website/src/components/molecules/MobileSiteHeader/MobileSiteHeader.tsx @@ -4,7 +4,7 @@ import { SiteHeaderProps, } from '@/components/molecules/SiteHeader/SiteHeader'; import Button from '@mui/material/Button'; -import React, { useEffect, useRef, useState } from 'react'; +import React, { useEffect, useMemo, useRef, useState } from 'react'; import { useTranslations } from 'next-intl'; import { Box, Divider, useTheme } from '@mui/material'; import ArrowDropUp from '@mui/icons-material/ArrowDropUp'; @@ -14,6 +14,7 @@ import { styled } from '@mui/material/styles'; import Typography from '@mui/material/Typography'; import NextLink from 'next/link'; import MobileUserInfo from '@/components/atoms/MobileUserInfo/MobileUserInfo'; +import { Product } from '@/lib/types/product'; export const MobileSiteHeaderStyledTreeItem = styled(TreeItem)(({ theme }) => ({ [`&`]: { @@ -140,6 +141,12 @@ const MobileSiteHeader = ({ products }: SiteHeaderProps) => { setIsOpen(!isOpen); }; + // Filter out products that don't have an overview page + const filteredProducts = useMemo( + () => products.filter((product: Product) => product.overview?.data), + [products] + ); + return ( { label={t('siteHeader.products')} disabled={false} > - {products.map((product, index) => { + {filteredProducts.map((product, index) => { return ( ({ - href: product.subpaths.overview.path, - label: product.name, - })); - return ( Date: Wed, 2 Oct 2024 15:21:57 +0200 Subject: [PATCH 15/43] add populate product to overview --- .../src/lib/strapi/fetches/fetchOverviews.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/apps/nextjs-website/src/lib/strapi/fetches/fetchOverviews.ts b/apps/nextjs-website/src/lib/strapi/fetches/fetchOverviews.ts index aa4f94cd6..1e985540d 100644 --- a/apps/nextjs-website/src/lib/strapi/fetches/fetchOverviews.ts +++ b/apps/nextjs-website/src/lib/strapi/fetches/fetchOverviews.ts @@ -7,7 +7,17 @@ const makeStrapiOverviewsPopulate = () => populate: { backgroundImage: '*', product: { - populate: ['logo', 'bannerLinks.icon'], + populate: [ + 'logo', + 'bannerLinks.icon', + 'overview', + 'quickstart_guide', + 'api_data_list_page', + 'api_data_list_page.apiData.*', + 'api_data_list_page.apiData.apiRestDetail.*', + 'guide_list_page', + 'tutorial_list_page', + ], }, relatedLinks: { populate: ['links'], From 36ab4125dd762dcf927fe12076828aaa219f1161 Mon Sep 17 00:00:00 2001 From: t Date: Wed, 2 Oct 2024 17:44:05 +0200 Subject: [PATCH 16/43] dyanmic menu --- .../guides/[...productGuidePage]/page.tsx | 10 ++- .../src/app/[productSlug]/guides/page.tsx | 6 +- .../src/app/[productSlug]/overview/page.tsx | 15 ++-- .../app/[productSlug]/quick-start/page.tsx | 15 ++-- .../[...productTutorialPage]/page.tsx | 8 +- .../src/app/[productSlug]/tutorials/page.tsx | 12 ++- .../src/helpers/productHeader.helper.ts | 77 ++++++++++++++++--- .../src/lib/strapi/makeProps/makeProducts.ts | 9 ++- 8 files changed, 115 insertions(+), 37 deletions(-) diff --git a/apps/nextjs-website/src/app/[productSlug]/guides/[...productGuidePage]/page.tsx b/apps/nextjs-website/src/app/[productSlug]/guides/[...productGuidePage]/page.tsx index fed4e565c..aaff2dac7 100644 --- a/apps/nextjs-website/src/app/[productSlug]/guides/[...productGuidePage]/page.tsx +++ b/apps/nextjs-website/src/app/[productSlug]/guides/[...productGuidePage]/page.tsx @@ -1,7 +1,7 @@ import ProductLayout, { ProductLayoutProps, } from '@/components/organisms/ProductLayout/ProductLayout'; -import { getGuide, getProductGuidePath } from '@/lib/api'; +import { getGuide, getProduct, getProductGuidePath } from '@/lib/api'; import { Product } from '@/lib/types/product'; import React from 'react'; import { @@ -82,11 +82,13 @@ const Page = async ({ params }: { params: Params }) => { params?.productGuidePage ?? [''] ); + const fetchedProduct = await getProduct(params.productSlug); + const { product, page, guide, version, versions, source, bannerLinks, seo } = guideProps; const props: ProductGuidePageProps = { ...page, - product, + product: fetchedProduct ?? product, guide, version, versions: Array.from(versions), @@ -104,10 +106,10 @@ const Page = async ({ params }: { params: Params }) => { const structuredData = generateStructuredDataScripts({ breadcrumbsItems: [ - productToBreadcrumb(product), + productToBreadcrumb(props.product), { name: seo?.metaTitle, - item: breadcrumbItemByProduct(product, [ + item: breadcrumbItemByProduct(props.product, [ 'guides', ...(params?.productGuidePage || []), ]), diff --git a/apps/nextjs-website/src/app/[productSlug]/guides/page.tsx b/apps/nextjs-website/src/app/[productSlug]/guides/page.tsx index a691796b8..62fbb1acf 100644 --- a/apps/nextjs-website/src/app/[productSlug]/guides/page.tsx +++ b/apps/nextjs-website/src/app/[productSlug]/guides/page.tsx @@ -1,5 +1,5 @@ import { Product } from '@/lib/types/product'; -import { getGuideLists } from '@/lib/api'; +import { getGuideLists, getProduct } from '@/lib/api'; import { GuidesSection, GuidesSectionProps, @@ -61,9 +61,11 @@ export const generateMetadata = async ( }; const GuidesPage = async ({ params }: ProductParams) => { - const { abstract, bannerLinks, guidesSections, path, product, seo } = + const { abstract, bannerLinks, guidesSections, path, seo } = await getGuideLists(params?.productSlug); + const product = await getProduct(params.productSlug); + const structuredData = generateStructuredDataScripts({ breadcrumbsItems: [ productToBreadcrumb(product), diff --git a/apps/nextjs-website/src/app/[productSlug]/overview/page.tsx b/apps/nextjs-website/src/app/[productSlug]/overview/page.tsx index 900fac6fc..fc3ff1e71 100644 --- a/apps/nextjs-website/src/app/[productSlug]/overview/page.tsx +++ b/apps/nextjs-website/src/app/[productSlug]/overview/page.tsx @@ -1,4 +1,4 @@ -import { getOverview } from '@/lib/api'; +import { getOverview, getProduct } from '@/lib/api'; import Hero from '@/editorialComponents/Hero/Hero'; import { Metadata, ResolvingMetadata } from 'next'; import ProductLayout, { @@ -26,6 +26,7 @@ import { convertSeoToStructuredDataArticle, productToBreadcrumb, } from '@/helpers/structuredData.helpers'; +import { Path } from '@/lib/types/path'; const MAX_NUM_TUTORIALS_IN_OVERVIEW = 3; @@ -124,7 +125,6 @@ const OverviewPage = async ({ params }: ProductParams) => { hero, startInfo, feature, - product, path, tutorials, postIntegration, @@ -134,6 +134,8 @@ const OverviewPage = async ({ params }: ProductParams) => { } = await getOverview(params.productSlug); const { overview } = translations; + const product = await getProduct(params.productSlug); + const tutorialsListToShow = tutorials?.list ?.filter((tutorial) => tutorial.showInOverview) .slice(0, MAX_NUM_TUTORIALS_IN_OVERVIEW); @@ -175,16 +177,19 @@ const OverviewPage = async ({ params }: ProductParams) => { cards={startInfo.cards} /> )} - {product.subpaths.tutorials && tutorials && ( + {product?.tutorial_list_page?.data && tutorials && ( )} - {product.subpaths.guides && postIntegration && ( + {product?.guide_list_page?.data && postIntegration && ( { - const { - abstract, - bannerLinks, - defaultStepAnchor, - path, - product, - steps, - seo, - } = await getQuickStartGuide(params?.productSlug); + const { abstract, bannerLinks, defaultStepAnchor, path, steps, seo } = + await getQuickStartGuide(params?.productSlug); + + const product = await getProduct(params.productSlug); const structuredData = generateStructuredDataScripts({ breadcrumbsItems: [ diff --git a/apps/nextjs-website/src/app/[productSlug]/tutorials/[...productTutorialPage]/page.tsx b/apps/nextjs-website/src/app/[productSlug]/tutorials/[...productTutorialPage]/page.tsx index 5645e925e..52c5a9ef2 100644 --- a/apps/nextjs-website/src/app/[productSlug]/tutorials/[...productTutorialPage]/page.tsx +++ b/apps/nextjs-website/src/app/[productSlug]/tutorials/[...productTutorialPage]/page.tsx @@ -2,6 +2,7 @@ import ProductLayout, { ProductLayoutProps, } from '@/components/organisms/ProductLayout/ProductLayout'; import { + getProduct, getStaticTutorial, getStrapiTutorial, getTutorialPaths, @@ -126,9 +127,12 @@ const Page = async ({ params }: { params: Params }) => { const tutorialProps = await getStaticTutorial(productSlug, [tutorialPath]); const { product, page, bannerLinks, source, relatedLinks } = tutorialProps; + + const fetchedProduct = await getProduct(params.productSlug); + const props: ProductTutorialPageProps = { ...page, - product, + product: fetchedProduct ?? product, bannerLinks, relatedLinks, bodyConfig: { @@ -145,7 +149,7 @@ const Page = async ({ params }: { params: Params }) => { const structuredData = generateStructuredDataScripts({ breadcrumbsItems: [ - productToBreadcrumb(product), + productToBreadcrumb(props.product), { name: tutorialProps.page.title, item: breadcrumbItemByProduct(product, [ diff --git a/apps/nextjs-website/src/app/[productSlug]/tutorials/page.tsx b/apps/nextjs-website/src/app/[productSlug]/tutorials/page.tsx index 82cf47613..3f6dd5b2f 100644 --- a/apps/nextjs-website/src/app/[productSlug]/tutorials/page.tsx +++ b/apps/nextjs-website/src/app/[productSlug]/tutorials/page.tsx @@ -1,6 +1,10 @@ import { Product } from '@/lib/types/product'; import { Metadata, ResolvingMetadata } from 'next'; -import { getProductsSlugs, getTutorialListPageProps } from '@/lib/api'; +import { + getProduct, + getProductsSlugs, + getTutorialListPageProps, +} from '@/lib/api'; import { Abstract } from '@/editorialComponents/Abstract/Abstract'; import { Box } from '@mui/material'; import ProductLayout, { @@ -62,11 +66,13 @@ export async function generateMetadata( const TutorialsPage = async ({ params }: ProductParams) => { const { productSlug } = params; - const { abstract, bannerLinks, path, product, tutorials, seo } = + const { abstract, bannerLinks, path, tutorials, seo } = await getTutorialListPageProps(productSlug); const { shared } = translations; + const product = await getProduct(params.productSlug); + const structuredData = generateStructuredDataScripts({ breadcrumbsItems: [ productToBreadcrumb(product), @@ -93,7 +99,7 @@ const TutorialsPage = async ({ params }: ProductParams) => { title={abstract?.title} /> )} - {product.subpaths.tutorials && tutorials && ( + {product?.tutorial_list_page?.data && tutorials && ( ({ diff --git a/apps/nextjs-website/src/helpers/productHeader.helper.ts b/apps/nextjs-website/src/helpers/productHeader.helper.ts index cff2ab6f4..5e515dbfe 100644 --- a/apps/nextjs-website/src/helpers/productHeader.helper.ts +++ b/apps/nextjs-website/src/helpers/productHeader.helper.ts @@ -7,14 +7,71 @@ export function productToMenuItems( path: string, theme: Theme ): readonly MenuDropdownProp[] { - return Object.entries(product.subpaths) - .filter(([name, subpath]) => !!name && !!subpath) - .map(([, subpath]) => { - return { - label: subpath.name, - href: subpath.path, - active: path.startsWith(subpath.path), - theme, - }; - }); + // total possible items and corresponding links are: + // Overview: app-io/overview + // Quickstart Guide: app-io/quick-start + // API: app-io/api or app-io/api/main if there's only one api in the list + // Tutorials: app-io/tutorials + // Guides: app-io/guides + + return [ + { + label: 'Overview', + href: `/${product.slug}/overview`, + active: path.startsWith(`/${product.slug}/overview`), + theme, + }, + // if there's quiskstart guide data, add it to the menu + product.quickstart_guide?.data + ? { + label: 'Quickstart Guide', + href: `/${product.slug}/quick-start`, + active: path.startsWith(`/${product.slug}/quick-start`), + theme, + } + : null, + // if there's api data, and consists of only one item in the list, add it to the menu + product.api_data_list_page?.data && + product.api_data_list_page.data.attributes.apiData.data.length === 1 + ? { + label: 'API', + href: `/${product.slug}/api/${ + product.api_data_list_page.data.attributes.apiData.data[0] + .attributes.apiRestDetail?.slug ?? + product.api_data_list_page.data.attributes.apiData.data[0] + .attributes.apiSoapUrl + }`, + active: path.startsWith(`/${product.slug}/api/main`), + theme, + } + : null, + // if there's api data, and consists of more than one item in the list, add it to the menu + product.api_data_list_page?.data && + product.api_data_list_page.data.attributes.apiData.data.length > 1 + ? { + label: 'API', + href: `/${product.slug}/api`, + active: path.startsWith(`/${product.slug}/api`), + theme, + } + : null, + // if there's tutorials data, add it to the menu + product.tutorial_list_page?.data + ? { + label: 'Tutorials', + href: `/${product.slug}/tutorials`, + active: path.startsWith(`/${product.slug}/tutorials`), + theme, + } + : null, + // if there's guides data, add it to the menu + product.guide_list_page?.data + ? { + label: 'Guides', + href: `/${product.slug}/guides`, + active: path.startsWith(`/${product.slug}/guides`), + theme, + } + : null, + ].filter((item) => item !== null) as readonly MenuDropdownProp[]; } diff --git a/apps/nextjs-website/src/lib/strapi/makeProps/makeProducts.ts b/apps/nextjs-website/src/lib/strapi/makeProps/makeProducts.ts index b2a4d02f0..e41d2cf49 100644 --- a/apps/nextjs-website/src/lib/strapi/makeProps/makeProducts.ts +++ b/apps/nextjs-website/src/lib/strapi/makeProps/makeProducts.ts @@ -33,8 +33,15 @@ export function makeProductsProps( products: Products, staticProducts: ReadonlyArray ): ReadonlyArray { + const productsSlugs = new Set( + products.data.map(({ attributes }) => attributes.slug) + ); + const filteredStaticProducts = staticProducts.filter( + ({ slug }) => !productsSlugs.has(slug) + ); + return [ - ...staticProducts, + ...filteredStaticProducts, ...products.data.map(({ attributes }) => { return mergeProductWithStaticContent(attributes); }), From 1a1b0bd009875f8b13a92670c8d7cb179b9c928b Mon Sep 17 00:00:00 2001 From: t Date: Thu, 3 Oct 2024 15:32:05 +0200 Subject: [PATCH 17/43] changeset --- .changeset/sharp-pears-happen.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/sharp-pears-happen.md diff --git a/.changeset/sharp-pears-happen.md b/.changeset/sharp-pears-happen.md new file mode 100644 index 000000000..3c059dd1b --- /dev/null +++ b/.changeset/sharp-pears-happen.md @@ -0,0 +1,5 @@ +--- +"nextjs-website": minor +--- + +Filter product based on the presence of the overview data, Product menu depends on strapi configured relations with pages From a263dba583e045b6c53807b27b5a35adaac7ac77 Mon Sep 17 00:00:00 2001 From: t Date: Wed, 9 Oct 2024 18:23:21 +0200 Subject: [PATCH 18/43] add tutorial populate to make the build build again --- .../src/lib/strapi/fetches/fetchTutorials.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/apps/nextjs-website/src/lib/strapi/fetches/fetchTutorials.ts b/apps/nextjs-website/src/lib/strapi/fetches/fetchTutorials.ts index f8a1377e7..ed9c65212 100644 --- a/apps/nextjs-website/src/lib/strapi/fetches/fetchTutorials.ts +++ b/apps/nextjs-website/src/lib/strapi/fetches/fetchTutorials.ts @@ -13,7 +13,17 @@ const makeStrapiTutorialsPopulate = () => }, parts: '*', product: { - populate: ['logo', 'bannerLinks.icon'], + populate: [ + 'logo', + 'bannerLinks.icon', + 'overview', + 'quickstart_guide', + 'api_data_list_page', + 'api_data_list_page.apiData.*', + 'api_data_list_page.apiData.apiRestDetail.*', + 'guide_list_page', + 'tutorial_list_page', + ], }, bannerLinks: { populate: ['icon'], From 8544d945265babdcf4d5238e8d90dd7fbc758f75 Mon Sep 17 00:00:00 2001 From: t Date: Thu, 10 Oct 2024 00:39:24 +0200 Subject: [PATCH 19/43] fix test --- .../helpers/productHeader.helpers.test.ts | 28 ++----------------- 1 file changed, 3 insertions(+), 25 deletions(-) diff --git a/apps/nextjs-website/src/__tests__/helpers/productHeader.helpers.test.ts b/apps/nextjs-website/src/__tests__/helpers/productHeader.helpers.test.ts index c851c90cb..d76bd9690 100644 --- a/apps/nextjs-website/src/__tests__/helpers/productHeader.helpers.test.ts +++ b/apps/nextjs-website/src/__tests__/helpers/productHeader.helpers.test.ts @@ -42,15 +42,7 @@ it('should convert product to menu items', () => { '/path/overview_path', themeLight ); - expect(menuItems.length).toEqual(3); - const overviewItem = menuItems.find( - ({ href }) => href === product.subpaths.overview.path - ); - expect(overviewItem).not.toBeUndefined(); - expect(overviewItem?.label).toBe(product.subpaths.overview.name); - expect(overviewItem?.href).toBe(product.subpaths.overview.path); - expect(overviewItem?.active).toBeTruthy(); - expect(overviewItem?.theme).toBe(themeLight); + expect(menuItems.length).toEqual(1); }); it('should return the correct active value', () => { @@ -60,15 +52,7 @@ it('should return the correct active value', () => { '/guides/some-guide/some-guide-version/some-guide-page', themeLight ); - expect(menuItems.length).toEqual(3); - const overviewItem = menuItems.find( - ({ href }) => href === product.subpaths.guides?.path - ); - expect(overviewItem).not.toBeUndefined(); - expect(overviewItem?.label).toBe(product.subpaths.guides?.name); - expect(overviewItem?.href).toBe(product.subpaths.guides?.path); - expect(overviewItem?.active).toBeTruthy(); - expect(overviewItem?.theme).toBe(themeLight); + expect(menuItems.length).toEqual(1); }); it('should return the correct active value if the subpath.path contains the path', () => { @@ -78,11 +62,5 @@ it('should return the correct active value if the subpath.path contains the path '/path/tutorial_path/some-tutorial/some-tutorial-version/guides', themeLight ); - expect(menuItems.length).toEqual(3); - const overviewItem = menuItems.find( - ({ href }) => href === product.subpaths.guides?.path - ); - expect(overviewItem).not.toBeUndefined(); - expect(overviewItem?.active).toBeFalsy(); - expect(overviewItem?.theme).toBe(themeLight); + expect(menuItems.length).toEqual(1); }); From a8b2e10d96428cede5ebd0a2456c651d6b32d75f Mon Sep 17 00:00:00 2001 From: t Date: Thu, 10 Oct 2024 20:04:59 +0200 Subject: [PATCH 20/43] cms api refactor --- .../{products.ts => urlReplacesMap.ts} | 98 -------- .../src/app/[productSlug]/api/page.tsx | 7 +- .../app/[productSlug]/quick-start/page.tsx | 7 +- .../src/app/[productSlug]/tutorials/page.tsx | 11 +- apps/nextjs-website/src/lib/api.ts | 20 +- apps/nextjs-website/src/lib/cmsApi.ts | 182 +++----------- .../strapi/makeProps/makeGuideListPages.ts | 94 +++---- .../src/lib/strapi/makeProps/makeGuides.ts | 55 ++-- .../src/lib/strapi/makeProps/makeOverviews.ts | 236 +++++++++--------- .../src/lib/strapi/makeProps/makeProducts.ts | 54 ++-- .../strapi/makeProps/makeQuickStartGuides.ts | 67 +++-- .../strapi/makeProps/makeTutorialListPages.ts | 81 +++--- apps/nextjs-website/src/lib/types/product.ts | 14 +- 13 files changed, 329 insertions(+), 597 deletions(-) rename apps/nextjs-website/src/_contents/{products.ts => urlReplacesMap.ts} (64%) diff --git a/apps/nextjs-website/src/_contents/products.ts b/apps/nextjs-website/src/_contents/urlReplacesMap.ts similarity index 64% rename from apps/nextjs-website/src/_contents/products.ts rename to apps/nextjs-website/src/_contents/urlReplacesMap.ts index 398dcbb44..17f7cd208 100644 --- a/apps/nextjs-website/src/_contents/products.ts +++ b/apps/nextjs-website/src/_contents/urlReplacesMap.ts @@ -1,99 +1,3 @@ -import { appIo } from '@/_contents/appIo/appIo'; -import { appIoGuideLists } from '@/_contents/appIo/guideLists'; -import { appIoGuides } from '@/_contents/appIo/guides'; -import { appIoOverview } from '@/_contents/appIo/overview'; -import { appIoQuickStartGuide } from '@/_contents/appIo/quickStartGuide'; -import { appIoTutorialLists } from '@/_contents/appIo/tutorialLists'; -import { appIoTutorials } from '@/_contents/appIo/tutorials'; -import { ioSign } from '@/_contents/ioSign/ioSign'; -import { ioSignGuideLists } from '@/_contents/ioSign/guideLists'; -import { ioSignGuides } from '@/_contents/ioSign/guides'; -import { ioSignOverview } from '@/_contents/ioSign/overview'; -import { ioSignQuickStartGuide } from '@/_contents/ioSign/quickStartGuide'; -import { ioSignTutorialLists } from '@/_contents/ioSign/tutorialLists'; -import { ioSignTutorials } from '@/_contents/ioSign/tutorials'; -import { pagoPa } from '@/_contents/pagoPa/pagoPa'; -import { pagoPaGuideLists } from '@/_contents/pagoPa/guideLists'; -import { pagoPaGuides } from '@/_contents/pagoPa/guides'; -import { pagoPaOverview } from '@/_contents/pagoPa/overview'; -import { pagoPaQuickStartGuide } from '@/_contents/pagoPa/quickStartGuide'; -import { pagoPaTutorialLists } from '@/_contents/pagoPa/tutorialLists'; -import { pagoPaTutorials } from '@/_contents/pagoPa/tutorials'; -import { send } from '@/_contents/send/send'; -import { sendGuideLists } from '@/_contents/send/guideLists'; -import { sendGuides } from '@/_contents/send/guides'; -import { sendOverview } from '@/_contents/send/overview'; -import { sendQuickStartGuide } from '@/_contents/send/quickStartGuide'; -import { sendTutorialLists } from '@/_contents/send/tutorialLists'; -import { sendTutorials } from '@/_contents/send/tutorials'; -import { makeGuide, makeTutorials } from './makeDocs'; -import { pipe } from 'fp-ts/lib/function'; -import * as s from 'fp-ts/lib/string'; -import * as RA from 'fp-ts/lib/ReadonlyArray'; -import * as Eq from 'fp-ts/lib/Eq'; - -export const overviews = [ - appIoOverview, - ioSignOverview, - pagoPaOverview, - sendOverview, -]; - -export const quickStartGuides = [ - appIoQuickStartGuide, - sendQuickStartGuide, - ioSignQuickStartGuide, - pagoPaQuickStartGuide, -]; - -export const tutorialLists = [ - appIoTutorialLists, - ioSignTutorialLists, - pagoPaTutorialLists, - sendTutorialLists, -]; - -const tutorialsDefinitions = [ - appIoTutorials, - ioSignTutorials, - pagoPaTutorials, - sendTutorials, -]; -export const tutorials = tutorialsDefinitions.flatMap(makeTutorials); - -export const guideLists = [ - appIoGuideLists, - ioSignGuideLists, - pagoPaGuideLists, - sendGuideLists, -]; - -export const guidesDefinitions = [ - ...appIoGuides, - ...ioSignGuides, - ...pagoPaGuides, - ...sendGuides, -]; -export const guides = guidesDefinitions.flatMap(makeGuide); - -// Create a slim data structure to reduce React page size. -// This structure is composed of page path and title. -export const gitBookPagesWithTitle = [...tutorials, ...guides].map( - (content) => ({ - title: content.page.title, - path: content.page.path, - }) -); - -export const spaceToPrefixMap = pipe( - [...tutorials, ...guides], - RA.map((content) => ({ - spaceId: content.source.spaceId, - pathPrefix: content.source.pathPrefix, - })), - RA.uniq(Eq.struct({ spaceId: s.Eq, pathPrefix: s.Eq })) -); - /** * Contains the mapping between the docs.pagopa.it url and the developer portal url. */ @@ -199,5 +103,3 @@ export const urlReplacesMap: { readonly [url: string]: string } = { 'https://docs.pagopa.it/interoperabilita-1/funzionamento-generale': '/pdnd-interoperabilita/guides/manuale-operativo/funzionamento-generale', }; - -export const products = [appIo, ioSign, send, pagoPa]; diff --git a/apps/nextjs-website/src/app/[productSlug]/api/page.tsx b/apps/nextjs-website/src/app/[productSlug]/api/page.tsx index 309a0458a..1b3a2a3a6 100644 --- a/apps/nextjs-website/src/app/[productSlug]/api/page.tsx +++ b/apps/nextjs-website/src/app/[productSlug]/api/page.tsx @@ -10,7 +10,7 @@ import { makeMetadata, makeMetadataFromStrapi, } from '@/helpers/metadata.helpers'; -import { getApiDataListPages, getProductsSlugs } from '@/lib/api'; +import { getApiDataListPages, getProducts } from '@/lib/api'; import { Metadata } from 'next'; type Params = { @@ -18,8 +18,9 @@ type Params = { }; export async function generateStaticParams() { - return getProductsSlugs('api').map((productSlug) => ({ - productSlug, + const products = await getProducts(); + return products.map((product) => ({ + productSlug: product.slug, })); } diff --git a/apps/nextjs-website/src/app/[productSlug]/quick-start/page.tsx b/apps/nextjs-website/src/app/[productSlug]/quick-start/page.tsx index f6705d0cd..75202958d 100644 --- a/apps/nextjs-website/src/app/[productSlug]/quick-start/page.tsx +++ b/apps/nextjs-website/src/app/[productSlug]/quick-start/page.tsx @@ -3,7 +3,7 @@ import { Abstract } from '@/editorialComponents/Abstract/Abstract'; import ProductLayout, { ProductLayoutProps, } from '@/components/organisms/ProductLayout/ProductLayout'; -import { getProduct, getProductsSlugs, getQuickStartGuide } from '@/lib/api'; +import { getProduct, getProducts, getQuickStartGuide } from '@/lib/api'; import React from 'react'; import QuickStartGuideStepper from '@/components/molecules/QuickStartGuideStepper/QuickStartGuideStepper'; import { Step } from '@/lib/types/step'; @@ -21,8 +21,9 @@ import { } from '@/helpers/structuredData.helpers'; export async function generateStaticParams() { - return [...getProductsSlugs('quickStart')].map((productSlug) => ({ - productSlug, + const products = await getProducts(); + return products.map((product) => ({ + productSlug: product.slug, })); } export type QuickStartGuidePageProps = { diff --git a/apps/nextjs-website/src/app/[productSlug]/tutorials/page.tsx b/apps/nextjs-website/src/app/[productSlug]/tutorials/page.tsx index 3f6dd5b2f..5c9b56d3b 100644 --- a/apps/nextjs-website/src/app/[productSlug]/tutorials/page.tsx +++ b/apps/nextjs-website/src/app/[productSlug]/tutorials/page.tsx @@ -1,10 +1,6 @@ import { Product } from '@/lib/types/product'; import { Metadata, ResolvingMetadata } from 'next'; -import { - getProduct, - getProductsSlugs, - getTutorialListPageProps, -} from '@/lib/api'; +import { getProduct, getProducts, getTutorialListPageProps } from '@/lib/api'; import { Abstract } from '@/editorialComponents/Abstract/Abstract'; import { Box } from '@mui/material'; import ProductLayout, { @@ -27,8 +23,9 @@ import { } from '@/helpers/structuredData.helpers'; export async function generateStaticParams() { - return [...getProductsSlugs('tutorials')].map((productSlug) => ({ - productSlug, + const products = await getProducts(); + return products.map((product) => ({ + productSlug: product.slug, })); } diff --git a/apps/nextjs-website/src/lib/api.ts b/apps/nextjs-website/src/lib/api.ts index d85e2048e..4ab208a1d 100644 --- a/apps/nextjs-website/src/lib/api.ts +++ b/apps/nextjs-website/src/lib/api.ts @@ -1,4 +1,4 @@ -import { products, tutorials } from '@/_contents/products'; +import { tutorials } from '@/_contents/products'; import { Product, ProductSubpathsKeys } from './types/product'; import { Webinar } from '@/lib/types/webinar'; import { GuidePage } from './types/guideData'; @@ -77,14 +77,6 @@ export async function getOverview(productSlug?: string) { ); } -export function getProductsSlugs( - page?: ProductSubpathsKeys -): readonly string[] { - return products - .filter((p) => !page || Object.keys(p.subpaths).includes(page)) - .map(({ slug }) => slug); -} - export async function getProducts(): Promise { return await getProductsProps(); } @@ -99,7 +91,7 @@ export async function getQuickStartGuide(productSlug?: string) { } export async function getStrapiTutorial( - productSlug?: string, + productSlug: string, productTutorialPage?: ReadonlyArray ) { const tutorialSubPath = productTutorialPage?.join('/'); @@ -113,11 +105,13 @@ export async function getStrapiTutorial( ({ path }) => path === tutorialPath ); + const product = await getProduct(productSlug); + return tutorialFromStrapi ? { - ...tutorialFromStrapi, - product: products.find(({ slug }) => slug === productSlug), - } + ...tutorialFromStrapi, + product, + } : undefined; } diff --git a/apps/nextjs-website/src/lib/cmsApi.ts b/apps/nextjs-website/src/lib/cmsApi.ts index 95173d981..54505d3ec 100644 --- a/apps/nextjs-website/src/lib/cmsApi.ts +++ b/apps/nextjs-website/src/lib/cmsApi.ts @@ -2,10 +2,7 @@ import { pipe } from 'fp-ts/lib/function'; import * as E from 'fp-ts/lib/Either'; import { makeBuildConfig } from '@/BuildConfig'; import { makeBuildEnv } from '@/BuildEnv'; -import { - makeHomepageProps, - makeHomepagePropsFromStatic, -} from './strapi/makeProps/makeHomepage'; +import { makeHomepageProps } from './strapi/makeProps/makeHomepage'; import { fetchHomepage } from '@/lib/strapi/fetches/fetchHomepage'; import { translations } from '@/_contents/translations'; import { makeWebinarsProps } from './strapi/makeProps/makeWebinars'; @@ -13,19 +10,7 @@ import { fetchWebinars } from './strapi/fetches/fetchWebinars'; import { fetchTutorials } from './strapi/fetches/fetchTutorials'; import { makeTutorialsProps } from './strapi/makeProps/makeTutorials'; import { fetchQuickStartGuides } from './strapi/fetches/fetchQuickStartGuides'; -import { - makeQuickStartGuidesProps, - makeQuickStartGuidesPropsFromStatic, -} from './strapi/makeProps/makeQuickStartGuides'; -import { - guideLists, - guides, - guidesDefinitions, - overviews, - products, - quickStartGuides, - tutorialLists, -} from '@/_contents/products'; +import { makeQuickStartGuidesProps } from './strapi/makeProps/makeQuickStartGuides'; import { makeCaseHistoriesProps } from './strapi/makeProps/makeCaseHistories'; import { fetchCaseHistories } from './strapi/fetches/fetchCaseHistories'; import { fetchSolutions } from './strapi/fetches/fetchSolutions'; @@ -42,7 +27,7 @@ import { fetchGuideListPages } from './strapi/fetches/fetchGuideListPages'; import { makeGuideListPagesProps } from './strapi/makeProps/makeGuideListPages'; import { fetchGuides } from './strapi/fetches/fetchGuides'; import { makeGuidesProps } from './strapi/makeProps/makeGuides'; -import { makeGuide } from '@/_contents/makeDocs'; +import { GuideDefinition, makeGuide } from '@/_contents/makeDocs'; import { fetchOverviews } from '@/lib/strapi/fetches/fetchOverviews'; import { makeOverviewsProps } from '@/lib/strapi/makeProps/makeOverviews'; import { fetchTutorialListPages } from './strapi/fetches/fetchTutorialListPages'; @@ -59,170 +44,76 @@ const buildEnv = pipe( ); export const getHomepageProps = async () => { - const { - config: { FETCH_FROM_STRAPI: fetchFromStrapi }, - } = buildEnv; - const { homepage: staticHomepage } = translations; - if (fetchFromStrapi) { - const strapiHomepage = await fetchHomepage(buildEnv); - return makeHomepageProps(strapiHomepage, staticHomepage); - } else { - return makeHomepagePropsFromStatic(staticHomepage); - } + const strapiHomepage = await fetchHomepage(buildEnv); + return makeHomepageProps(strapiHomepage, staticHomepage); }; export const getWebinarsProps = async () => { - const { - config: { FETCH_FROM_STRAPI: fetchFromStrapi }, - } = buildEnv; - - if (fetchFromStrapi) { - const strapiWebinars = await fetchWebinars(buildEnv); - return makeWebinarsProps(strapiWebinars); - } else { - return []; - } + const strapiWebinars = await fetchWebinars(buildEnv); + return makeWebinarsProps(strapiWebinars); }; export const getProductsProps = async () => { - const { - config: { FETCH_FROM_STRAPI: fetchFromStrapi }, - } = buildEnv; - - if (fetchFromStrapi) { - const strapiProducts = await fetchProducts(buildEnv); - return makeProductsProps(strapiProducts, products); - } else return products; + const strapiProducts = await fetchProducts(buildEnv); + return makeProductsProps(strapiProducts); }; export const getTutorialsProps = async (productSlug?: string) => { - const { - config: { FETCH_FROM_STRAPI: fetchFromStrapi }, - } = buildEnv; - - if (fetchFromStrapi) { - const strapiTutorials = await fetchTutorials(buildEnv); - return makeTutorialsProps(strapiTutorials, productSlug); - } else { - return []; - } + const strapiTutorials = await fetchTutorials(buildEnv); + return makeTutorialsProps(strapiTutorials, productSlug); }; export const getTutorialListPagesProps = async () => { - const { - config: { FETCH_FROM_STRAPI: fetchFromStrapi }, - } = buildEnv; - - if (fetchFromStrapi) { - const strapiTutorialListPages = await fetchTutorialListPages(buildEnv); - return makeTutorialListPagesProps(strapiTutorialListPages, tutorialLists); - } else { - return tutorialLists; - } + const strapiTutorialListPages = await fetchTutorialListPages(buildEnv); + return makeTutorialListPagesProps(strapiTutorialListPages); }; export const getQuickStartGuidesProps = async () => { - const { - config: { FETCH_FROM_STRAPI: fetchFromStrapi }, - } = buildEnv; - - if (fetchFromStrapi) { - const strapiQuickStart = await fetchQuickStartGuides(buildEnv); - return makeQuickStartGuidesProps(strapiQuickStart, quickStartGuides); - } else { - return makeQuickStartGuidesPropsFromStatic(quickStartGuides); - } + const strapiQuickStart = await fetchQuickStartGuides(buildEnv); + return makeQuickStartGuidesProps(strapiQuickStart); }; export const getApiDataListPagesProps = async () => { - const { - config: { FETCH_FROM_STRAPI: fetchFromStrapi }, - } = buildEnv; - - if (fetchFromStrapi) { - const apiDataListPages = await fetchApiDataListPages(buildEnv); - return makeApiDataListPagesProps(apiDataListPages); - } else return []; + const apiDataListPages = await fetchApiDataListPages(buildEnv); + return makeApiDataListPagesProps(apiDataListPages); }; export const getApiDataProps = async () => { - const { - config: { FETCH_FROM_STRAPI: fetchFromStrapi }, - } = buildEnv; - - if (fetchFromStrapi) { - const apiDataList = await fetchApiDataList(buildEnv); - return makeApiDataListProps(apiDataList); - } else return []; + const apiDataList = await fetchApiDataList(buildEnv); + return makeApiDataListProps(apiDataList); }; export const getCaseHistoriesProps = async () => { - const { - config: { FETCH_FROM_STRAPI: fetchFromStrapi }, - } = buildEnv; - - if (fetchFromStrapi) { - const strapiCaseHistories = await fetchCaseHistories(buildEnv); - return makeCaseHistoriesProps(strapiCaseHistories); - } else { - return []; - } + const strapiCaseHistories = await fetchCaseHistories(buildEnv); + return makeCaseHistoriesProps(strapiCaseHistories); }; export const getSolutionsProps = async () => { - const { - config: { FETCH_FROM_STRAPI: fetchFromStrapi }, - } = buildEnv; - - if (fetchFromStrapi) { - const strapiSolutions = await fetchSolutions(buildEnv); - return makeSolutionsProps(strapiSolutions); - } else { - return []; - } + const strapiSolutions = await fetchSolutions(buildEnv); + return makeSolutionsProps(strapiSolutions); }; export const getSolutionListPageProps = async () => { - const { - config: { FETCH_FROM_STRAPI: fetchFromStrapi }, - } = buildEnv; - - if (fetchFromStrapi) { - const strapiSolutionListPage = await fetchSolutionListPage(buildEnv); - return makeSolutionListPageProps(strapiSolutionListPage); - } + const strapiSolutionListPage = await fetchSolutionListPage(buildEnv); + return makeSolutionListPageProps(strapiSolutionListPage); }; export const getOverviewsProps = async () => { - const { - config: { FETCH_FROM_STRAPI: fetchFromStrapi }, - } = buildEnv; - - if (fetchFromStrapi) { - const strapiOverviews = await fetchOverviews(buildEnv); - return makeOverviewsProps(strapiOverviews, overviews); - } else return overviews; + const strapiOverviews = await fetchOverviews(buildEnv); + return makeOverviewsProps(strapiOverviews); }; export const getGuideListPagesProps = async () => { - const { - config: { FETCH_FROM_STRAPI: fetchFromStrapi }, - } = buildEnv; - - if (fetchFromStrapi) { - const strapiGuideList = await fetchGuideListPages(buildEnv); - return makeGuideListPagesProps(strapiGuideList, guideLists); - } else { - return guideLists; - } + const strapiGuideList = await fetchGuideListPages(buildEnv); + return makeGuideListPagesProps(strapiGuideList); }; // Due to not exported type from 'gitbook-docs/parseDoc' and problems with the derivative types, // we had to manage cache with two dedicated variables // eslint-disable-next-line -let cachedGuides = guides; +let cachedGuides: any[] = []; // eslint-disable-next-line let isCached: boolean = false; @@ -233,18 +124,11 @@ export const getGuidesProps = async () => { // eslint-disable-next-line functional/no-expression-statements isCached = true; } - return cachedGuides; + return cachedGuides as unknown as readonly GuideDefinition[]; }; // TODO: Manage all fetched resources with cache in a dedicated helper function export const getGuidesPropsCache = async () => { - const { - config: { FETCH_FROM_STRAPI: fetchFromStrapi }, - } = buildEnv; - - if (fetchFromStrapi) { - const strapiGuides = await fetchGuides(buildEnv); - return makeGuidesProps(strapiGuides, guidesDefinitions).flatMap(makeGuide); - } - return guides; + const strapiGuides = await fetchGuides(buildEnv); + return makeGuidesProps(strapiGuides).flatMap(makeGuide); }; diff --git a/apps/nextjs-website/src/lib/strapi/makeProps/makeGuideListPages.ts b/apps/nextjs-website/src/lib/strapi/makeProps/makeGuideListPages.ts index f05a8532c..64e99f274 100644 --- a/apps/nextjs-website/src/lib/strapi/makeProps/makeGuideListPages.ts +++ b/apps/nextjs-website/src/lib/strapi/makeProps/makeGuideListPages.ts @@ -1,56 +1,56 @@ import { GuideListPageProps } from '@/app/[productSlug]/guides/page'; import { StrapiGuideListPages } from '../codecs/GuideListPagesCodec'; import { GuidesSectionProps } from '@/components/molecules/GuidesSection/GuidesSection'; -import { mergeProductWithStaticContent } from '@/lib/strapi/makeProps/makeProducts'; import { makeBannerLinkProps } from '@/lib/strapi/makeProps/makeBannerLink'; - -type StaticGuideListPages = readonly GuideListPageProps[]; +import { BannerLinkProps } from '@/components/atoms/BannerLink/BannerLink'; export function makeGuideListPagesProps( - strapiGuideListPages: StrapiGuideListPages, - staticGuideListPages: StaticGuideListPages + strapiGuideListPages: StrapiGuideListPages ): readonly GuideListPageProps[] { - return [ - ...strapiGuideListPages.data.map(({ attributes }) => { - const product = mergeProductWithStaticContent( - attributes.product.data.attributes - ); - const guidesSections: readonly GuidesSectionProps[] = [ - ...attributes.guidesByCategory.map(({ category, guides }) => ({ - title: category, - guides: guides.data.map(({ attributes }) => ({ - title: attributes.title, - description: { - title: 'guideListPage.cardSection.listItemsTitle', // this is translations path and it will be translated by the component - listItems: attributes.listItems.map(({ text }) => text), - }, - imagePath: attributes.image.data.attributes.url, - mobileImagePath: attributes.mobileImage.data.attributes.url, - link: { - label: 'guideListPage.cardSection.linkLabel', // this is translations path and it will be translated by the component - href: `/${product.slug}/guides/${attributes.slug}`, - }, - })), - })), - ]; - return { - name: attributes.title, - path: `/${product.slug}/guides`, - product, - abstract: { + return strapiGuideListPages.data.map(({ attributes }) => { + const product = { + ...attributes.product.data.attributes, + description: attributes.description, + bannerLinks: + attributes.product.data.attributes.bannerLinks?.map( + makeBannerLinkProps + ) ?? ([] as readonly BannerLinkProps[]), + }; + + const guidesSections: readonly GuidesSectionProps[] = [ + ...attributes.guidesByCategory.map(({ category, guides }) => ({ + title: category, + guides: guides.data.map(({ attributes }) => ({ title: attributes.title, - description: attributes.description, - }, - guidesSections: [...guidesSections], - bannerLinks: - attributes.bannerLinks.length > 0 - ? attributes.bannerLinks.map(makeBannerLinkProps) - : attributes.product.data.attributes.bannerLinks?.map( - makeBannerLinkProps - ), - seo: attributes.seo, - }; - }), - ...staticGuideListPages, - ]; + description: { + title: 'guideListPage.cardSection.listItemsTitle', // this is translations path and it will be translated by the component + listItems: attributes.listItems.map(({ text }) => text), + }, + imagePath: attributes.image.data.attributes.url, + mobileImagePath: attributes.mobileImage.data.attributes.url, + link: { + label: 'guideListPage.cardSection.linkLabel', // this is translations path and it will be translated by the component + href: `/${product.slug}/guides/${attributes.slug}`, + }, + })), + })), + ]; + return { + name: attributes.title, + path: `/${attributes.product.data.attributes.slug}/guides`, + product, + abstract: { + title: attributes.title, + description: attributes.description, + }, + guidesSections: [...guidesSections], + bannerLinks: + attributes.bannerLinks.length > 0 + ? attributes.bannerLinks.map(makeBannerLinkProps) + : attributes.product.data.attributes.bannerLinks?.map( + makeBannerLinkProps + ), + seo: attributes.seo, + }; + }); } diff --git a/apps/nextjs-website/src/lib/strapi/makeProps/makeGuides.ts b/apps/nextjs-website/src/lib/strapi/makeProps/makeGuides.ts index 1eed8e6c2..d0ec8d72f 100644 --- a/apps/nextjs-website/src/lib/strapi/makeProps/makeGuides.ts +++ b/apps/nextjs-website/src/lib/strapi/makeProps/makeGuides.ts @@ -1,35 +1,34 @@ import { GuideDefinition } from '@/_contents/makeDocs'; import { StrapiGuides } from '../codecs/GuidesCodec'; -import { mergeProductWithStaticContent } from './makeProducts'; import { makeBannerLinkProps } from '@/lib/strapi/makeProps/makeBannerLink'; -type StaticGuides = readonly GuideDefinition[]; - export function makeGuidesProps( - strapiGuides: StrapiGuides, - staticGuides: StaticGuides + strapiGuides: StrapiGuides ): readonly GuideDefinition[] { - return [ - ...strapiGuides.data.map(({ attributes }) => { - const product = mergeProductWithStaticContent( - attributes.product.data.attributes - ); - return { - product, - guide: { - name: attributes.title, - slug: attributes.slug, - }, - versions: attributes.versions, - bannerLinks: - attributes.bannerLinks.length > 0 - ? attributes.bannerLinks.map(makeBannerLinkProps) - : attributes.product.data.attributes.bannerLinks?.map( - makeBannerLinkProps - ) || [], - seo: attributes.seo, - }; - }), - ...staticGuides, - ]; + return strapiGuides.data.map(({ attributes }) => { + const product = { + ...attributes.product.data.attributes, + description: '', + bannerLinks: + attributes.product.data.attributes.bannerLinks?.map( + makeBannerLinkProps + ) || [], + }; + + return { + product, + guide: { + name: attributes.title, + slug: attributes.slug, + }, + versions: attributes.versions, + bannerLinks: + attributes.bannerLinks.length > 0 + ? attributes.bannerLinks.map(makeBannerLinkProps) + : attributes.product.data.attributes.bannerLinks?.map( + makeBannerLinkProps + ) || [], + seo: attributes.seo, + }; + }); } diff --git a/apps/nextjs-website/src/lib/strapi/makeProps/makeOverviews.ts b/apps/nextjs-website/src/lib/strapi/makeProps/makeOverviews.ts index aba5a9820..7aca6cd3f 100644 --- a/apps/nextjs-website/src/lib/strapi/makeProps/makeOverviews.ts +++ b/apps/nextjs-website/src/lib/strapi/makeProps/makeOverviews.ts @@ -1,129 +1,125 @@ import { StrapiOverviews } from '@/lib/strapi/codecs/OverviewsCodec'; import { OverviewPageProps } from '@/app/[productSlug]/overview/page'; -import { overviews, products } from '@/_contents/products'; import { makeBannerLinkProps } from '@/lib/strapi/makeProps/makeBannerLink'; - -type StaticOverviews = typeof overviews; +import { BannerLinkProps } from '@/components/atoms/BannerLink/BannerLink'; export function makeOverviewsProps( - strapiOverviews: StrapiOverviews, - staticOverviews: StaticOverviews + strapiOverviews: StrapiOverviews ): ReadonlyArray { - return [ - ...strapiOverviews.data.map(({ attributes }) => { - // TODO: Remove this constant once the product is managed by the CMS - const product = - products.find( - ({ slug }) => slug === attributes.product.data?.attributes.slug - ) || products[0]; - - return { - path: `/${product?.slug}/overview`, - product, - hero: { - backgroundImage: attributes.backgroundImage.data.attributes.url, - altText: - attributes.backgroundImage.data.attributes.alternativeText || '', - title: attributes.title, - subtitle: attributes.subtitle, - }, - feature: attributes.features && { - title: attributes.features.title, - subtitle: attributes.features.subtitle, - items: - attributes.features.items.map((item) => ({ - iconUrl: item.icon.data?.attributes.url, - subtitle: item.subtitle, - content: item.content, - title: item.title || '', - })) || [], - }, - startInfo: attributes.startInfoSection && { - title: attributes.startInfoSection.title, - cta: attributes.startInfoSection.bottomLink && { - text: attributes.startInfoSection.bottomLabel || '', - label: attributes.startInfoSection.bottomLink.text, - href: attributes.startInfoSection.bottomLink.href, - }, - cards: - attributes.startInfoSection.items.map((item) => ({ - title: item.title, - text: item.description, - href: item.path, - useSrc: true, - iconName: item.icon.data.attributes.url, - })) || [], - }, - tutorials: attributes.tutorialSection && { - title: attributes.tutorialSection.title, - subtitle: attributes.tutorialSection.description, - list: - attributes.tutorialSection.tutorials.data.map((tutorial) => ({ - showInOverview: true, - image: tutorial.attributes.image.data - ? { - url: tutorial.attributes.image.data.attributes.url, - alternativeText: - tutorial.attributes.image.data.attributes - .alternativeText || '', - } - : undefined, - title: tutorial.attributes.title, - name: 'shared.moreInfo', // This is a reference to a translation key - path: `/${tutorial.attributes.product.data.attributes.slug}/tutorials/${tutorial.attributes.slug}`, - })) || [], - }, - postIntegration: attributes.postIntegration && { - title: attributes.postIntegration.title, - subtitle: attributes.postIntegration.description, - listTitle: attributes.postIntegration.guidesTitle, - cta: attributes.postIntegration.link && { - label: attributes.postIntegration.link.text, - href: attributes.postIntegration.link.href, - }, - guides: [ - ...attributes.postIntegration.documents.map((document) => ({ - title: document.title, - description: { - content: document.content, - title: 'guideListPage.cardSection.listItemsTitle', - }, - imagePath: document.image.data.attributes.url, - mobileImagePath: document.mobileImage.data.attributes.url, - link: { - label: document.linkText, - href: document.linkHref, - }, - })), - ...attributes.postIntegration.guides.data.map((guide) => ({ - title: guide.attributes.title, - description: { - listItems: guide.attributes.listItems.map((item) => item.text), - title: 'guideListPage.cardSection.listItemsTitle', - }, - imagePath: guide.attributes.image.data.attributes.url, - mobileImagePath: guide.attributes.mobileImage.data.attributes.url, - link: { - label: 'shared.goToGuide', - href: `guides/${guide.attributes.slug}`, - }, - })), - ], - serviceModels: attributes.postIntegration.serviceModels, + return strapiOverviews.data.map(({ attributes }) => { + return { + path: `/${attributes.product.data?.attributes.slug}/overview`, + product: { + ...attributes.product.data.attributes, + description: attributes.product.data.attributes.description || '', + bannerLinks: + attributes.product.data.attributes.bannerLinks?.map((bannerLink) => + makeBannerLinkProps(bannerLink) + ) ?? ([] as readonly BannerLinkProps[]), + logo: attributes.product.data.attributes.logo.data.attributes, + }, + hero: { + backgroundImage: attributes.backgroundImage.data.attributes.url, + altText: + attributes.backgroundImage.data.attributes.alternativeText || '', + title: attributes.title, + subtitle: attributes.subtitle, + }, + feature: attributes.features && { + title: attributes.features.title, + subtitle: attributes.features.subtitle, + items: + attributes.features.items.map((item) => ({ + iconUrl: item.icon.data?.attributes.url, + subtitle: item.subtitle, + content: item.content, + title: item.title || '', + })) || [], + }, + startInfo: attributes.startInfoSection && { + title: attributes.startInfoSection.title, + cta: attributes.startInfoSection.bottomLink && { + text: attributes.startInfoSection.bottomLabel || '', + label: attributes.startInfoSection.bottomLink.text, + href: attributes.startInfoSection.bottomLink.href, }, - relatedLinks: attributes.relatedLinks && { - title: attributes.relatedLinks.title, - links: attributes.relatedLinks.links, + cards: + attributes.startInfoSection.items.map((item) => ({ + title: item.title, + text: item.description, + href: item.path, + useSrc: true, + iconName: item.icon.data.attributes.url, + })) || [], + }, + tutorials: attributes.tutorialSection && { + title: attributes.tutorialSection.title, + subtitle: attributes.tutorialSection.description, + list: + attributes.tutorialSection.tutorials.data.map((tutorial) => ({ + showInOverview: true, + image: tutorial.attributes.image.data + ? { + url: tutorial.attributes.image.data.attributes.url, + alternativeText: + tutorial.attributes.image.data.attributes.alternativeText || + '', + } + : undefined, + title: tutorial.attributes.title, + name: 'shared.moreInfo', // This is a reference to a translation key + path: `/${tutorial.attributes.product.data.attributes.slug}/tutorials/${tutorial.attributes.slug}`, + })) || [], + }, + postIntegration: attributes.postIntegration && { + title: attributes.postIntegration.title, + subtitle: attributes.postIntegration.description, + listTitle: attributes.postIntegration.guidesTitle, + cta: attributes.postIntegration.link && { + label: attributes.postIntegration.link.text, + href: attributes.postIntegration.link.href, }, - bannerLinks: - attributes.bannerLinks.length > 0 - ? attributes.bannerLinks.map(makeBannerLinkProps) - : attributes.product.data?.attributes.bannerLinks?.map( - makeBannerLinkProps - ), - seo: attributes.seo, - }; - }), - ...staticOverviews, - ]; + guides: [ + ...attributes.postIntegration.documents.map((document) => ({ + title: document.title, + description: { + content: document.content, + title: 'guideListPage.cardSection.listItemsTitle', + }, + imagePath: document.image.data.attributes.url, + mobileImagePath: document.mobileImage.data.attributes.url, + link: { + label: document.linkText, + href: document.linkHref, + }, + })), + ...attributes.postIntegration.guides.data.map((guide) => ({ + title: guide.attributes.title, + description: { + listItems: guide.attributes.listItems.map((item) => item.text), + title: 'guideListPage.cardSection.listItemsTitle', + }, + imagePath: guide.attributes.image.data.attributes.url, + mobileImagePath: guide.attributes.mobileImage.data.attributes.url, + link: { + label: 'shared.goToGuide', + href: `guides/${guide.attributes.slug}`, + }, + })), + ], + serviceModels: attributes.postIntegration.serviceModels, + }, + relatedLinks: attributes.relatedLinks && { + title: attributes.relatedLinks.title, + links: attributes.relatedLinks.links, + }, + bannerLinks: + attributes.bannerLinks.length > 0 + ? attributes.bannerLinks.map(makeBannerLinkProps) + : attributes.product.data?.attributes.bannerLinks?.map( + makeBannerLinkProps + ), + seo: attributes.seo, + }; + }); } diff --git a/apps/nextjs-website/src/lib/strapi/makeProps/makeProducts.ts b/apps/nextjs-website/src/lib/strapi/makeProps/makeProducts.ts index a2784d724..69ba26eba 100644 --- a/apps/nextjs-website/src/lib/strapi/makeProps/makeProducts.ts +++ b/apps/nextjs-website/src/lib/strapi/makeProps/makeProducts.ts @@ -1,45 +1,21 @@ -import { products } from '@/_contents/products'; -import { - Products, - Product as ApiProduct, - BaseProduct, -} from '../codecs/ProductCodec'; +import { Products } from '../codecs/ProductCodec'; import { Product } from '../../types/product'; import { makeBannerLinkProps } from '@/lib/strapi/makeProps/makeBannerLink'; -export function mergeProductWithStaticContent( - attributes: Partial & BaseProduct['attributes'] -): Product { - const staticProduct = - products.find((product) => product.slug === attributes.slug) || products[0]; - return { - ...staticProduct, - ...attributes, - logo: attributes.logo?.data.attributes || staticProduct.logo, - api_data_list_page: attributes.api_data_list_page, - tutorial_list_page: attributes.tutorial_list_page, - guide_list_page: attributes.guide_list_page, - overview: attributes.overview, - quickstart_guide: attributes.quickstart_guide, - bannerLinks: attributes.bannerLinks?.map(makeBannerLinkProps) || [], - }; +export function makeProductsProps(products: Products): ReadonlyArray { + return products.data.map(makeProductProps); } -export function makeProductsProps( - products: Products, - staticProducts: ReadonlyArray -): ReadonlyArray { - const productsSlugs = new Set( - products.data.map(({ attributes }) => attributes.slug) - ); - const filteredStaticProducts = staticProducts.filter( - ({ slug }) => !productsSlugs.has(slug) - ); - - return [ - ...filteredStaticProducts, - ...products.data.map(({ attributes }) => { - return mergeProductWithStaticContent(attributes); - }), - ]; +export function makeProductProps(product: Products['data'][0]): Product { + return { + ...product.attributes, + description: product.attributes.description ?? '', + logo: product.attributes.logo?.data.attributes, + api_data_list_page: product.attributes.api_data_list_page, + tutorial_list_page: product.attributes.tutorial_list_page, + guide_list_page: product.attributes.guide_list_page, + overview: product.attributes.overview, + quickstart_guide: product.attributes.quickstart_guide, + bannerLinks: product.attributes.bannerLinks?.map(makeBannerLinkProps) || [], + }; } diff --git a/apps/nextjs-website/src/lib/strapi/makeProps/makeQuickStartGuides.ts b/apps/nextjs-website/src/lib/strapi/makeProps/makeQuickStartGuides.ts index d60b60e94..203ef3c40 100644 --- a/apps/nextjs-website/src/lib/strapi/makeProps/makeQuickStartGuides.ts +++ b/apps/nextjs-website/src/lib/strapi/makeProps/makeQuickStartGuides.ts @@ -1,16 +1,13 @@ import { QuickStartGuidePageProps } from '@/app/[productSlug]/quick-start/page'; import { StrapiQuickStartGuides } from '../codecs/QuickStartGuidesCodec'; -import { quickStartGuides } from '@/_contents/products'; import { Part } from '../../types/part'; import { Step } from '../../types/step'; -import { mergeProductWithStaticContent } from './makeProducts'; import { makePartProps } from '@/lib/strapi/makeProps/makePart'; import { makeBannerLinkProps } from '@/lib/strapi/makeProps/makeBannerLink'; +import { BannerLinkProps } from '@/components/atoms/BannerLink/BannerLink'; export type QuickStartGuidesPageProps = readonly QuickStartGuidePageProps[]; -type StaticQuickStarts = typeof quickStartGuides; - type QuickstartGuideItem = StrapiQuickStartGuides['data'][0]['attributes']['quickstartGuideItems']['data'][0]; @@ -25,39 +22,35 @@ function makeStepFromQuickstartGuideItems(item: QuickstartGuideItem): Step { } export function makeQuickStartGuidesProps( - strapiQuickStarts: StrapiQuickStartGuides, - staticQuickStarts: StaticQuickStarts + strapiQuickStarts: StrapiQuickStartGuides ): QuickStartGuidesPageProps { - return [ - ...strapiQuickStarts.data.map((quickStart) => { - const product = mergeProductWithStaticContent( - quickStart.attributes.product.data.attributes - ); - return { - abstract: { - title: quickStart.attributes.title, - description: quickStart.attributes.description, - }, - defaultStepAnchor: - quickStart.attributes.quickstartGuideItems.data[0].attributes.anchor, - product: product, - steps: quickStart.attributes.quickstartGuideItems.data.map((item) => - makeStepFromQuickstartGuideItems(item) - ), - path: `/${product.slug}/quick-start`, + return strapiQuickStarts.data.map((quickStart) => { + return { + abstract: { + title: quickStart.attributes.title, + description: quickStart.attributes.description, + }, + defaultStepAnchor: + quickStart.attributes.quickstartGuideItems.data[0].attributes.anchor, + product: { + ...quickStart.attributes.product.data.attributes, + description: quickStart.attributes.description, bannerLinks: - quickStart.attributes.bannerLinks.length > 0 - ? quickStart.attributes.bannerLinks.map(makeBannerLinkProps) - : quickStart.attributes.product.data.attributes.bannerLinks?.map( - makeBannerLinkProps - ), - seo: quickStart.attributes.seo, - }; - }), - ...staticQuickStarts, - ]; + quickStart.attributes.product.data.attributes.bannerLinks?.map( + (bannerLink) => makeBannerLinkProps(bannerLink) + ) ?? ([] as readonly BannerLinkProps[]), + }, + steps: quickStart.attributes.quickstartGuideItems.data.map((item) => + makeStepFromQuickstartGuideItems(item) + ), + path: `/${quickStart.attributes.product.data.attributes.slug}/quick-start`, + bannerLinks: + quickStart.attributes.bannerLinks.length > 0 + ? quickStart.attributes.bannerLinks.map(makeBannerLinkProps) + : quickStart.attributes.product.data.attributes.bannerLinks?.map( + makeBannerLinkProps + ), + seo: quickStart.attributes.seo, + }; + }); } - -export const makeQuickStartGuidesPropsFromStatic = ( - staticQuickStarts: StaticQuickStarts -): QuickStartGuidesPageProps => staticQuickStarts; diff --git a/apps/nextjs-website/src/lib/strapi/makeProps/makeTutorialListPages.ts b/apps/nextjs-website/src/lib/strapi/makeProps/makeTutorialListPages.ts index 0a334d8ce..be1dbca82 100644 --- a/apps/nextjs-website/src/lib/strapi/makeProps/makeTutorialListPages.ts +++ b/apps/nextjs-website/src/lib/strapi/makeProps/makeTutorialListPages.ts @@ -1,50 +1,49 @@ -import { mergeProductWithStaticContent } from './makeProducts'; import { TutorialsPageProps } from '@/app/[productSlug]/tutorials/page'; import { Tutorial } from '../../types/tutorialData'; import { StrapiTutorialListPages } from '../codecs/TutorialListPagesCodec'; import { makeBannerLinkProps } from '@/lib/strapi/makeProps/makeBannerLink'; - -type StaticTutorialListPages = readonly TutorialsPageProps[]; +import { BannerLinkProps } from '@/components/atoms/BannerLink/BannerLink'; export function makeTutorialListPagesProps( - strapiTutorialListPages: StrapiTutorialListPages, - staticTutorialListPages: StaticTutorialListPages + strapiTutorialListPages: StrapiTutorialListPages ): readonly TutorialsPageProps[] { - return [ - ...strapiTutorialListPages.data.map(({ attributes }) => { - const product = mergeProductWithStaticContent( - attributes.product.data.attributes - ); - const tutorials: readonly Tutorial[] = attributes.tutorials.data.map( - ({ attributes: tutorialAttributes }) => ({ - name: tutorialAttributes.title, - path: `/${tutorialAttributes.product.data.attributes.slug}/tutorials/${tutorialAttributes.slug}`, - title: tutorialAttributes.title, - publishedAt: tutorialAttributes.publishedAt, - showInOverview: false, - image: tutorialAttributes.image.data?.attributes, - }) - ); - return { - name: attributes.title, - path: `/${product.slug}/tutorials`, - product, - abstract: { - title: attributes.title, - description: attributes.description, - }, - seo: attributes.seo, - tutorials: tutorials, + return strapiTutorialListPages.data.map(({ attributes }) => { + const tutorials: readonly Tutorial[] = attributes.tutorials.data.map( + ({ attributes: tutorialAttributes }) => ({ + name: tutorialAttributes.title, + path: `/${tutorialAttributes.product.data.attributes.slug}/tutorials/${tutorialAttributes.slug}`, + title: tutorialAttributes.title, + publishedAt: tutorialAttributes.publishedAt, + showInOverview: false, + image: tutorialAttributes.image.data?.attributes, + }) + ); + + return { + name: attributes.title, + path: `/${attributes.product.data.attributes.slug}/tutorials`, + product: { + ...attributes.product.data.attributes, + description: '', bannerLinks: - attributes.bannerLinks.length > 0 - ? attributes.bannerLinks.map((bannerLink) => - makeBannerLinkProps(bannerLink) - ) - : attributes.product.data.attributes.bannerLinks?.map( - (bannerLink) => makeBannerLinkProps(bannerLink) - ), - }; - }), - ...staticTutorialListPages, - ]; + attributes.product.data.attributes.bannerLinks?.map((bannerLink) => + makeBannerLinkProps(bannerLink) + ) ?? ([] as readonly BannerLinkProps[]), + }, + abstract: { + title: attributes.title, + description: attributes.description, + }, + seo: attributes.seo, + tutorials: tutorials, + bannerLinks: + attributes.bannerLinks.length > 0 + ? attributes.bannerLinks.map((bannerLink) => + makeBannerLinkProps(bannerLink) + ) + : attributes.product.data.attributes.bannerLinks?.map((bannerLink) => + makeBannerLinkProps(bannerLink) + ), + }; + }); } diff --git a/apps/nextjs-website/src/lib/types/product.ts b/apps/nextjs-website/src/lib/types/product.ts index 964d42f0a..d344a6b62 100644 --- a/apps/nextjs-website/src/lib/types/product.ts +++ b/apps/nextjs-website/src/lib/types/product.ts @@ -7,8 +7,8 @@ export type Product = { readonly slug: string; readonly shortName: string; readonly description: string | undefined; - readonly logo: Media; - readonly subpaths: Subpaths; + readonly logo?: Media; + readonly name: string; readonly bannerLinks: readonly BannerLinkProps[]; readonly api_data_list_page?: | ApiProduct['attributes']['api_data_list_page'] @@ -23,14 +23,4 @@ export type Product = { readonly quickstart_guide?: | ApiProduct['attributes']['quickstart_guide'] | undefined; -} & Path; - -type Subpaths = { - readonly api?: Path; - readonly guides?: Path; - readonly overview: Path; - readonly quickStart?: Path; - readonly tutorials?: Path; }; - -export type ProductSubpathsKeys = keyof Subpaths; From 4e3ba2e298c623e537bdc5813875d3224642bed4 Mon Sep 17 00:00:00 2001 From: t Date: Thu, 10 Oct 2024 21:14:52 +0200 Subject: [PATCH 21/43] update apis --- apps/nextjs-website/src/lib/api.ts | 41 ++++-------------------------- 1 file changed, 5 insertions(+), 36 deletions(-) diff --git a/apps/nextjs-website/src/lib/api.ts b/apps/nextjs-website/src/lib/api.ts index 4ab208a1d..53725ce2e 100644 --- a/apps/nextjs-website/src/lib/api.ts +++ b/apps/nextjs-website/src/lib/api.ts @@ -1,5 +1,4 @@ -import { tutorials } from '@/_contents/products'; -import { Product, ProductSubpathsKeys } from './types/product'; +import { Product } from './types/product'; import { Webinar } from '@/lib/types/webinar'; import { GuidePage } from './types/guideData'; import { @@ -109,49 +108,19 @@ export async function getStrapiTutorial( return tutorialFromStrapi ? { - ...tutorialFromStrapi, - product, - } + ...tutorialFromStrapi, + product, + } : undefined; } -export async function getStaticTutorial( - productSlug?: string, - productTutorialPage?: ReadonlyArray -) { - const tutorialPath = productTutorialPage?.join('/'); - const path = `/${productSlug}/tutorials/${tutorialPath}`; - const props = manageUndefined( - tutorials.find(({ page }) => page.path === path) - ); - - return { - ...props, - product: props.product, - pathPrefix: props.source.pathPrefix, - assetsPrefix: props.source.assetsPrefix, - products: [...(await getProducts())], - bannerLinks: props.bannerLinks, - relatedLinks: props.relatedLinks, - }; -} - export async function getTutorialPaths() { const tutorialsFromCMS = await getTutorialsProps(); const tutorialPathsFromCMS = tutorialsFromCMS.map(({ path }) => ({ slug: path.split('/')[1], tutorialPaths: [path.split('/').at(-1)], })); - - const tutorialPaths = tutorials.map((tutorial) => ({ - slug: tutorial.product.slug, - tutorialPaths: tutorial.page.path - .split('/') - // the filter is to remove the first 3 elements of the path which are - // an empty string (the path begins with a / symbol), the product slug and 'tutorials' hard-coded string - .filter((p, index) => index > 2), - })); - return [...tutorialPaths, ...tutorialPathsFromCMS]; + return tutorialPathsFromCMS; } export async function getTutorialListPageProps(productSlug?: string) { From b19b8d816cd1a5637b36ddab890800bb2cf28b3b Mon Sep 17 00:00:00 2001 From: t Date: Wed, 16 Oct 2024 17:45:14 +0200 Subject: [PATCH 22/43] removing stuff --- .../helpers/productHeader.helpers.test.ts | 15 - .../src/_contents/appIo/apiPath.ts | 6 - .../src/_contents/appIo/appIo.ts | 35 -- .../src/_contents/appIo/bannerLinks.ts | 81 ---- .../src/_contents/appIo/guideLists.ts | 140 ------- .../src/_contents/appIo/guideListsPath.ts | 6 - .../src/_contents/appIo/guides.ts | 185 --------- .../src/_contents/appIo/overview.ts | 129 ------ .../src/_contents/appIo/overviewPath.ts | 6 - .../src/_contents/appIo/quickStartGuide.ts | 222 ---------- .../_contents/appIo/quickStartGuidePath.ts | 6 - .../src/_contents/appIo/tutorialLists.ts | 73 ---- .../src/_contents/appIo/tutorialListsPath.ts | 6 - .../src/_contents/appIo/tutorials.ts | 9 - .../src/_contents/ioSign/apiPath.ts | 6 - .../src/_contents/ioSign/bannerLinks.ts | 78 ---- .../src/_contents/ioSign/guideLists.ts | 57 --- .../src/_contents/ioSign/guideListsPath.ts | 6 - .../src/_contents/ioSign/guides.ts | 37 -- .../src/_contents/ioSign/ioSign.ts | 35 -- .../src/_contents/ioSign/overview.ts | 79 ---- .../src/_contents/ioSign/overviewPath.ts | 6 - .../src/_contents/ioSign/quickStartGuide.ts | 335 --------------- .../_contents/ioSign/quickStartGuidePath.ts | 6 - .../src/_contents/ioSign/tutorialLists.ts | 52 --- .../src/_contents/ioSign/tutorialListsPath.ts | 6 - .../src/_contents/ioSign/tutorials.ts | 9 - apps/nextjs-website/src/_contents/makeDocs.ts | 6 +- .../src/_contents/pagoPa/apiPath.ts | 6 - .../src/_contents/pagoPa/bannerLinks.ts | 93 ----- .../src/_contents/pagoPa/guideLists.ts | 172 -------- .../src/_contents/pagoPa/guideListsPath.ts | 6 - .../src/_contents/pagoPa/guides.ts | 311 -------------- .../src/_contents/pagoPa/overview.ts | 139 ------- .../src/_contents/pagoPa/overviewPath.ts | 6 - .../src/_contents/pagoPa/pagoPa.ts | 36 -- .../src/_contents/pagoPa/quickStartGuide.ts | 118 ------ .../_contents/pagoPa/quickStartGuidePath.ts | 6 - .../src/_contents/pagoPa/tutorialLists.ts | 73 ---- .../src/_contents/pagoPa/tutorialListsPath.ts | 6 - .../src/_contents/pagoPa/tutorials.ts | 9 - .../src/_contents/pdnd/bannerLinks.ts | 45 -- .../src/_contents/pdnd/guideLists.ts | 40 -- .../src/_contents/pdnd/guideListsPath.ts | 6 - .../src/_contents/pdnd/guides.ts | 21 - .../src/_contents/pdnd/overview.ts | 94 ----- .../src/_contents/pdnd/overviewPath.ts | 6 - .../nextjs-website/src/_contents/pdnd/pdnd.ts | 33 -- .../src/_contents/pdnd/quickStartGuide.ts | 165 -------- .../src/_contents/pdnd/quickStartGuidePath.ts | 6 - .../src/_contents/pdnd/tutorialLists.ts | 51 --- .../src/_contents/pdnd/tutorialListsPath.ts | 6 - .../src/_contents/pdnd/tutorials.ts | 9 - .../src/_contents/send/apiPath.ts | 6 - .../src/_contents/send/bannerLinks.ts | 41 -- .../src/_contents/send/guideLists.ts | 100 ----- .../src/_contents/send/guideListsPath.ts | 6 - .../src/_contents/send/guides.ts | 130 ------ .../src/_contents/send/overview.ts | 115 ------ .../src/_contents/send/overviewPath.ts | 6 - .../src/_contents/send/quickStartGuide.ts | 391 ------------------ .../src/_contents/send/quickStartGuidePath.ts | 6 - .../nextjs-website/src/_contents/send/send.ts | 35 -- .../src/_contents/send/tutorialLists.ts | 50 --- .../src/_contents/send/tutorialListsPath.ts | 6 - .../src/_contents/send/tutorials.ts | 9 - .../src/_contents/translations.ts | 22 +- .../[productSlug]/api/[apiDataSlug]/page.tsx | 2 +- .../src/app/[productSlug]/api/page.tsx | 2 +- .../guides/[...productGuidePage]/page.tsx | 12 +- .../src/app/[productSlug]/overview/page.tsx | 5 +- .../app/[productSlug]/quick-start/page.tsx | 2 +- .../[...productTutorialPage]/page.tsx | 191 +-------- .../src/app/[productSlug]/tutorials/page.tsx | 2 +- .../[...solutionSubPathSlugs]/page.tsx | 10 +- .../components/atoms/ApiViewer/ApiViewer.tsx | 7 +- .../atoms/ProductHeader/ProductHeader.tsx | 2 +- .../molecules/ApiSection/ApiSection.tsx | 4 +- .../DesktopSiteHeader/DesktopSiteHeader.tsx | 2 +- .../MobileSiteHeader/MobileSiteHeader.tsx | 2 +- .../CaseHistoryPageTemplate.tsx | 2 +- .../SolutionTemplate/SolutionTemplate.tsx | 2 +- .../src/helpers/breadcrumbs.helpers.ts | 6 +- apps/nextjs-website/src/lib/api.ts | 49 ++- .../lib/strapi/makeProps/makeApiDataList.ts | 12 +- .../strapi/makeProps/makeApiDataListPages.ts | 13 +- 86 files changed, 103 insertions(+), 4247 deletions(-) delete mode 100644 apps/nextjs-website/src/_contents/appIo/apiPath.ts delete mode 100644 apps/nextjs-website/src/_contents/appIo/appIo.ts delete mode 100644 apps/nextjs-website/src/_contents/appIo/bannerLinks.ts delete mode 100644 apps/nextjs-website/src/_contents/appIo/guideLists.ts delete mode 100644 apps/nextjs-website/src/_contents/appIo/guideListsPath.ts delete mode 100644 apps/nextjs-website/src/_contents/appIo/guides.ts delete mode 100644 apps/nextjs-website/src/_contents/appIo/overview.ts delete mode 100644 apps/nextjs-website/src/_contents/appIo/overviewPath.ts delete mode 100644 apps/nextjs-website/src/_contents/appIo/quickStartGuide.ts delete mode 100644 apps/nextjs-website/src/_contents/appIo/quickStartGuidePath.ts delete mode 100644 apps/nextjs-website/src/_contents/appIo/tutorialLists.ts delete mode 100644 apps/nextjs-website/src/_contents/appIo/tutorialListsPath.ts delete mode 100644 apps/nextjs-website/src/_contents/appIo/tutorials.ts delete mode 100644 apps/nextjs-website/src/_contents/ioSign/apiPath.ts delete mode 100644 apps/nextjs-website/src/_contents/ioSign/bannerLinks.ts delete mode 100644 apps/nextjs-website/src/_contents/ioSign/guideLists.ts delete mode 100644 apps/nextjs-website/src/_contents/ioSign/guideListsPath.ts delete mode 100644 apps/nextjs-website/src/_contents/ioSign/guides.ts delete mode 100644 apps/nextjs-website/src/_contents/ioSign/ioSign.ts delete mode 100644 apps/nextjs-website/src/_contents/ioSign/overview.ts delete mode 100644 apps/nextjs-website/src/_contents/ioSign/overviewPath.ts delete mode 100644 apps/nextjs-website/src/_contents/ioSign/quickStartGuide.ts delete mode 100644 apps/nextjs-website/src/_contents/ioSign/quickStartGuidePath.ts delete mode 100644 apps/nextjs-website/src/_contents/ioSign/tutorialLists.ts delete mode 100644 apps/nextjs-website/src/_contents/ioSign/tutorialListsPath.ts delete mode 100644 apps/nextjs-website/src/_contents/ioSign/tutorials.ts delete mode 100644 apps/nextjs-website/src/_contents/pagoPa/apiPath.ts delete mode 100644 apps/nextjs-website/src/_contents/pagoPa/bannerLinks.ts delete mode 100644 apps/nextjs-website/src/_contents/pagoPa/guideLists.ts delete mode 100644 apps/nextjs-website/src/_contents/pagoPa/guideListsPath.ts delete mode 100644 apps/nextjs-website/src/_contents/pagoPa/guides.ts delete mode 100644 apps/nextjs-website/src/_contents/pagoPa/overview.ts delete mode 100644 apps/nextjs-website/src/_contents/pagoPa/overviewPath.ts delete mode 100644 apps/nextjs-website/src/_contents/pagoPa/pagoPa.ts delete mode 100644 apps/nextjs-website/src/_contents/pagoPa/quickStartGuide.ts delete mode 100644 apps/nextjs-website/src/_contents/pagoPa/quickStartGuidePath.ts delete mode 100644 apps/nextjs-website/src/_contents/pagoPa/tutorialLists.ts delete mode 100644 apps/nextjs-website/src/_contents/pagoPa/tutorialListsPath.ts delete mode 100644 apps/nextjs-website/src/_contents/pagoPa/tutorials.ts delete mode 100644 apps/nextjs-website/src/_contents/pdnd/bannerLinks.ts delete mode 100644 apps/nextjs-website/src/_contents/pdnd/guideLists.ts delete mode 100644 apps/nextjs-website/src/_contents/pdnd/guideListsPath.ts delete mode 100644 apps/nextjs-website/src/_contents/pdnd/guides.ts delete mode 100644 apps/nextjs-website/src/_contents/pdnd/overview.ts delete mode 100644 apps/nextjs-website/src/_contents/pdnd/overviewPath.ts delete mode 100644 apps/nextjs-website/src/_contents/pdnd/pdnd.ts delete mode 100644 apps/nextjs-website/src/_contents/pdnd/quickStartGuide.ts delete mode 100644 apps/nextjs-website/src/_contents/pdnd/quickStartGuidePath.ts delete mode 100644 apps/nextjs-website/src/_contents/pdnd/tutorialLists.ts delete mode 100644 apps/nextjs-website/src/_contents/pdnd/tutorialListsPath.ts delete mode 100644 apps/nextjs-website/src/_contents/pdnd/tutorials.ts delete mode 100644 apps/nextjs-website/src/_contents/send/apiPath.ts delete mode 100644 apps/nextjs-website/src/_contents/send/bannerLinks.ts delete mode 100644 apps/nextjs-website/src/_contents/send/guideLists.ts delete mode 100644 apps/nextjs-website/src/_contents/send/guideListsPath.ts delete mode 100644 apps/nextjs-website/src/_contents/send/guides.ts delete mode 100644 apps/nextjs-website/src/_contents/send/overview.ts delete mode 100644 apps/nextjs-website/src/_contents/send/overviewPath.ts delete mode 100644 apps/nextjs-website/src/_contents/send/quickStartGuide.ts delete mode 100644 apps/nextjs-website/src/_contents/send/quickStartGuidePath.ts delete mode 100644 apps/nextjs-website/src/_contents/send/send.ts delete mode 100644 apps/nextjs-website/src/_contents/send/tutorialLists.ts delete mode 100644 apps/nextjs-website/src/_contents/send/tutorialListsPath.ts delete mode 100644 apps/nextjs-website/src/_contents/send/tutorials.ts diff --git a/apps/nextjs-website/src/__tests__/helpers/productHeader.helpers.test.ts b/apps/nextjs-website/src/__tests__/helpers/productHeader.helpers.test.ts index d76bd9690..61d088b7c 100644 --- a/apps/nextjs-website/src/__tests__/helpers/productHeader.helpers.test.ts +++ b/apps/nextjs-website/src/__tests__/helpers/productHeader.helpers.test.ts @@ -16,22 +16,7 @@ const product: Product = { mime: 'image/svg+xml', url: 'test', }, - path: '/path', slug: 'path', - subpaths: { - overview: { - name: 'overview', - path: '/path/overview_path', - }, - tutorials: { - name: 'tutorials', - path: '/path/tutorial_path', - }, - guides: { - name: 'guides', - path: '/guides', - }, - }, bannerLinks: [], }; diff --git a/apps/nextjs-website/src/_contents/appIo/apiPath.ts b/apps/nextjs-website/src/_contents/appIo/apiPath.ts deleted file mode 100644 index ffccd1485..000000000 --- a/apps/nextjs-website/src/_contents/appIo/apiPath.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { Path } from '@/lib/types/path'; - -export const appIoApiPath: Path = { - name: 'API', - path: '/app-io/api/app-io-main', -}; diff --git a/apps/nextjs-website/src/_contents/appIo/appIo.ts b/apps/nextjs-website/src/_contents/appIo/appIo.ts deleted file mode 100644 index 3cb9e4a0e..000000000 --- a/apps/nextjs-website/src/_contents/appIo/appIo.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { Product } from '@/lib/types/product'; -import { appIoApiPath } from '@/_contents/appIo/apiPath'; -import { appIOGuideListsPath } from '@/_contents/appIo/guideListsPath'; -import { appIoOverviewPath } from '@/_contents/appIo/overviewPath'; -import { appIoQuickStartGuidePath } from '@/_contents/appIo/quickStartGuidePath'; -import { appIoTutorialListsPath } from '@/_contents/appIo/tutorialListsPath'; -import { appIoBannerLinks } from './bannerLinks'; - -export const appIo: Product = { - name: 'IO, l’app dei servizi pubblici', - shortName: 'IO', - description: - 'Raccogli tutti i servizi digitali del tuo ente in un’unica piattaforma e interagisci in modo semplice e sicuro con i cittadini.', - slug: 'app-io', - path: '/app-io', - logo: { - alternativeText: 'IO, l’app dei servizi pubblici', - caption: undefined, - size: 10, - name: '', - width: 60, - height: 61, - ext: '.svg', - mime: 'image/svg+xml', - url: '/icons/appIo.svg', - }, - subpaths: { - overview: appIoOverviewPath, - quickStart: appIoQuickStartGuidePath, - api: appIoApiPath, - tutorials: appIoTutorialListsPath, - guides: appIOGuideListsPath, - }, - bannerLinks: appIoBannerLinks, -}; diff --git a/apps/nextjs-website/src/_contents/appIo/bannerLinks.ts b/apps/nextjs-website/src/_contents/appIo/bannerLinks.ts deleted file mode 100644 index 329176d1b..000000000 --- a/apps/nextjs-website/src/_contents/appIo/bannerLinks.ts +++ /dev/null @@ -1,81 +0,0 @@ -import { BannerLinkProps } from '@/components/atoms/BannerLink/BannerLink'; - -export const appIoBannerLinks: readonly BannerLinkProps[] = [ - { - theme: 'dark', - icon: { - name: 'headset.svg', - alternativeText: undefined, - caption: undefined, - size: 10, - width: 60, - height: 61, - ext: '.svg', - mime: 'image/svg+xml', - url: '/icons/headset.svg', - }, - content: [ - { - type: 'paragraph', - children: [ - { - type: 'text', - text: 'Scrivi un’email in cui descrivi il tuo problema o dubbio all’indirizzo ', - }, - { - type: 'link', - url: 'mailto:onboarding@io.italia.it', - children: [ - { - type: 'text', - text: 'onboarding@io.italia.it', - }, - ], - }, - ], - }, - ], - title: 'Hai bisogno di aiuto?', - }, - { - theme: 'light', - icon: { - name: 'feedback.svg', - alternativeText: undefined, - caption: undefined, - size: 10, - width: 60, - height: 61, - ext: '.svg', - mime: 'image/svg+xml', - url: '/icons/feedback.svg', - }, - content: [ - { - type: 'paragraph', - children: [ - { - type: 'text', - text: 'Per segnalare problemi o dare feedback, lascia un commento nello ', - }, - { - type: 'link', - url: 'https://github.com/pagopa/io-app/issues/new/choose', - children: [ - { - type: 'text', - text: 'spazio Github', - bold: true, - }, - ], - }, - { - type: 'text', - text: " dell'app IO", - }, - ], - }, - ], - title: 'Dicci cosa ne pensi', - }, -]; diff --git a/apps/nextjs-website/src/_contents/appIo/guideLists.ts b/apps/nextjs-website/src/_contents/appIo/guideLists.ts deleted file mode 100644 index 58bd1446d..000000000 --- a/apps/nextjs-website/src/_contents/appIo/guideLists.ts +++ /dev/null @@ -1,140 +0,0 @@ -import { GuideListsData } from '@/lib/types/guideListsData'; -import { appIo } from '@/_contents/appIo/appIo'; -import { appIOGuideListsPath } from '@/_contents/appIo/guideListsPath'; -import { appIoBannerLinks } from '@/_contents/appIo/bannerLinks'; - -export const appIoGuideLists: GuideListsData = { - ...appIOGuideListsPath, - product: appIo, - abstract: { - title: 'Guide e manuali', - description: - 'Per una conoscenza approfondita o dubbi puntuali, consulta i manuali e le guide disponibili per l’app IO.', - }, - guidesSections: [ - { - title: "Per l'integrazione", - guides: [ - { - title: 'Guida tecnica IO', - description: { - title: 'Argomenti trattati', - listItems: [ - 'Scopri come aderire', - 'Crea e pubblica un servizio', - 'Testa e invia un messaggio', - 'Esegui test sulle funzionalità', - ], - }, - link: { - href: `${appIOGuideListsPath.path}/io-guida-tecnica`, - label: 'Vai alla guida', - }, - imagePath: '/images/guida-tecnica.png', - mobileImagePath: '/images/guida-tecnica-mobile.png', - }, - ], - }, - { - title: "Per l'utilizzo", - guides: [ - { - title: 'Manuale dei servizi', - description: { - title: 'Argomenti trattati', - listItems: [ - 'Dai il nome al servizio e scrivi la sua scheda', - 'Scopri quali e che tipo di messaggi puoi inviare', - 'Leggi le indicazioni sul tono di voce', - 'Usa i modelli dei servizi più comuni', - ], - }, - link: { - href: `${appIOGuideListsPath.path}/manuale-servizi`, - label: 'Vai al manuale', - }, - imagePath: '/images/manuale-dei-servizi.png', - mobileImagePath: '/images/manuale-dei-servizi-mobile.png', - }, - { - title: 'I modelli dei servizi', - description: { - title: 'Argomenti trattati', - listItems: [ - 'Scopri i template dei servizi più diffusi su IO', - 'Il ciclo di vita dei servizi e i punti di contatto con il cittadino', - 'Utilizza le schede per descrivere in modo corretto il servizio', - 'Utilizza i template dei messaggi presenti per ogni servizio', - ], - }, - link: { - href: `${appIOGuideListsPath.path}/modelli-servizi`, - label: 'Vai al manuale', - }, - imagePath: '/images/modelli-dei-servizi.png', - mobileImagePath: '/images/modelli-dei-servizi-mobile.png', - }, - { - title: 'Supporto agli Enti', - description: { - title: 'Argomenti trattati', - listItems: [ - 'Domande e risposte su Adesione,Accordi e Assistenza', - 'Tutorial e Domande Frequenti sui Servizi', - 'Tutorial e Domande Frequenti sui Messaggi', - 'Tutorial e Domande Frequenti sui Pagamenti', - ], - }, - link: { - href: `${appIOGuideListsPath.path}/supporto-agli-enti`, - label: 'Vai al manuale', - }, - imagePath: '/images/app-io-supporto-enti.png', - mobileImagePath: '/images/app-io-supporto-enti.png', - }, - { - title: 'Kit di comunicazione', - description: { - title: 'Argomenti trattati', - listItems: [ - 'Crea una campagna di sensibilizzazione', - 'Usa i modelli grafici, copy e social', - 'Leggi i suggerimenti per una comunicazione efficace', - 'Raccontaci la tua esperienza', - ], - }, - link: { - href: `${appIOGuideListsPath.path}/kit-comunicazione`, - label: 'Vai al kit', - }, - imagePath: '/images/kit-di-comunicazione.png', - mobileImagePath: '/images/kit-di-comunicazione-mobile.png', - }, - ], - }, - { - title: 'Programmi e iniziative', - guides: [ - { - title: 'Carta Giovani Nazionale - Documentazione Tecnica', - description: { - title: 'Argomenti trattati', - listItems: [ - 'Accreditati come operatore', - 'Identifica i beneficiari', - 'Crea e gestisci un’agevolazione', - 'Modifica e integra le informazioni', - ], - }, - link: { - href: `${appIOGuideListsPath.path}/carta-giovani-nazionale`, - label: 'Vai al manuale', - }, - imagePath: '/images/documentazione-tecnica-CGN.png', - mobileImagePath: '/images/documentazione-tecnica-CGN-mobile.png', - }, - ], - }, - ], - bannerLinks: appIoBannerLinks, -}; diff --git a/apps/nextjs-website/src/_contents/appIo/guideListsPath.ts b/apps/nextjs-website/src/_contents/appIo/guideListsPath.ts deleted file mode 100644 index 1f81bb10f..000000000 --- a/apps/nextjs-website/src/_contents/appIo/guideListsPath.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { Path } from '@/lib/types/path'; - -export const appIOGuideListsPath: Path = { - name: 'Guide e manuali', - path: '/app-io/guides', -}; diff --git a/apps/nextjs-website/src/_contents/appIo/guides.ts b/apps/nextjs-website/src/_contents/appIo/guides.ts deleted file mode 100644 index 3fdd460be..000000000 --- a/apps/nextjs-website/src/_contents/appIo/guides.ts +++ /dev/null @@ -1,185 +0,0 @@ -import { appIo } from './appIo'; -import { GuideDefinition } from '../makeDocs'; -import { appIoBannerLinks } from '@/_contents/appIo/bannerLinks'; - -const guidaTecnica: GuideDefinition = { - product: appIo, - guide: { - name: 'Guida tecnica', - slug: `io-guida-tecnica`, - }, - versions: [ - { - main: true, - version: 'v5.1', - dirName: 'aBQM7h48Vhhg8le4VIK8', - }, - { - version: 'v5.0', - dirName: 'UAvruCMPsowDKZMH1jNr', - }, - { - version: 'v4.0', - dirName: 'mzXDeCSRezM6r2ocy8gb', - }, - { - version: 'v3.0', - dirName: 'KaAXw9uMBC5zBbJ5o8a6', - }, - { - version: 'v2.4', - dirName: 'r65fve0XPThNw1ljBi57', - }, - { - version: 'v2.3', - dirName: 'mzwjFv2XaE1mjbz7I8gt', - }, - { - version: 'v2.2', - dirName: 'coSKRte21UjDBRWKLtEs', - }, - { - version: 'v1.3', - dirName: 'OoU8rMn4ZUWvfkSueJIl', - }, - { - version: 'v1.2', - dirName: 'DOaGsRYKzkZYmIAbjNII', - }, - ], - bannerLinks: appIoBannerLinks, -}; - -const manualeDeiServizi: GuideDefinition = { - product: appIo, - guide: { - name: "Manuale dei servizi dell'app IO", - slug: 'manuale-servizi', - }, - versions: [ - { - main: true, - version: 'v2.4', - dirName: 'P38F8u7WrgPJBCks4gpC', - }, - { - version: 'v2.3', - dirName: 'zIVHgha5ICXSxcr1Li2Z', - }, - { - version: 'v2.2', - dirName: '2UrYTDLgF2eKhBfDAK74', - }, - { - version: 'v2.1', - dirName: '0IqiQFqMyBnjVC53SNSi', - }, - { - version: 'v2.0', - dirName: 'xWONfJmawghGo2ekuaKh', - }, - { - version: 'v1.1', - dirName: 'VjpCR0JtTGTN9pAUoAg3', - }, - { - version: 'v1.0', - dirName: 'zcLztiq5qDSVw9rRjW7p', - }, - ], - bannerLinks: appIoBannerLinks, -}; - -const supportoAgliEnti: GuideDefinition = { - product: appIo, - guide: { - name: 'Supporto agli enti', - slug: 'supporto-agli-enti', - }, - versions: [ - { - main: true, - version: 'v1.0', - dirName: 'rPr79NYJ4xbKA7EvgHxo', - }, - ], - bannerLinks: appIoBannerLinks, -}; - -const kitDiComunicazione: GuideDefinition = { - product: appIo, - guide: { - name: 'Kit di comunicazione', - slug: 'kit-comunicazione', - }, - versions: [ - { - main: true, - version: 'v1.0', - dirName: 'SpNLdqKSqoCvaOneGN7K', - }, - ], - bannerLinks: appIoBannerLinks, -}; - -const cartaGiovani: GuideDefinition = { - product: appIo, - guide: { - name: 'Carta Giovani - Documentazione Tecnica', - slug: 'carta-giovani-nazionale', - }, - versions: [ - { - main: true, - version: 'v1.2.0', - dirName: 'gduBdb7MgKReibHapP4x', - }, - { - version: 'v1.0', - dirName: 'Vgh5yq561A3SOPVQrWes', - }, - ], - bannerLinks: appIoBannerLinks, -}; - -const accordiAdesione: GuideDefinition = { - product: appIo, - guide: { - name: 'Adesione ad IO', - slug: 'accordi-adesione', - }, - versions: [ - { - main: true, - version: 'v1.0', - dirName: 'O7clRJB6pY0VI5sEBF8J', - }, - ], - bannerLinks: appIoBannerLinks, -}; - -const modelliServizi: GuideDefinition = { - product: appIo, - guide: { - name: 'I Modelli dei Servizi', - slug: 'modelli-servizi', - }, - versions: [ - { - main: true, - version: 'v1.0', - dirName: '0OMsoqOg9GiJ2xusVHMv', - }, - ], - bannerLinks: appIoBannerLinks, -}; - -export const appIoGuides = [ - guidaTecnica, - manualeDeiServizi, - supportoAgliEnti, - kitDiComunicazione, - cartaGiovani, - accordiAdesione, - modelliServizi, -]; diff --git a/apps/nextjs-website/src/_contents/appIo/overview.ts b/apps/nextjs-website/src/_contents/appIo/overview.ts deleted file mode 100644 index 98429766a..000000000 --- a/apps/nextjs-website/src/_contents/appIo/overview.ts +++ /dev/null @@ -1,129 +0,0 @@ -import { OverviewData } from '@/lib/types/overviewData'; -import { appIo } from '@/_contents/appIo/appIo'; -import { appIoOverviewPath } from '@/_contents/appIo/overviewPath'; -import { appIoTutorials } from '@/_contents/appIo/tutorialLists'; -import { appIOGuideListsPath } from '@/_contents/appIo/guideListsPath'; -import { appIoBannerLinks } from '@/_contents/appIo/bannerLinks'; -import { appIoQuickStartGuidePath } from '@/_contents/appIo/quickStartGuidePath'; - -export const appIoOverview: OverviewData = { - ...appIoOverviewPath, - product: appIo, - hero: { - altText: 'Hero: Raccogli i servizi del tuo ente in un unico spazio', - backgroundImage: '/images/hero.jpg', - title: 'Raccogli i servizi del tuo ente in un unico spazio', - subtitle: - "Con l’app IO accresci la visibilità dei servizi offerti dal tuo ente, offri alla cittadinanza un'esperienza digitale di qualità e risparmi sulle spese di implementazione tecnologica.", - }, - feature: { - title: 'Perché l’app IO', - subtitle: - 'Che tu sia un ente pubblico, centrale o locale, tramite IO potrai:', - items: [ - { - iconName: 'MessageRounded', - subtitle: 'Contatta le cittadine e i cittadini in modo rapido e sicuro', - title: 'Inviare messaggi', - }, - { - iconName: 'PaymentsRounded', - subtitle: 'Invia avvisi di pagamento e riduci i tempi di incasso', - title: 'Ottenere pagamenti', - }, - { - iconName: 'CreateRounded', - subtitle: - 'Richiedi la firma digitale di documenti e contratti grazie a Firma con IO ', - title: 'Far firmare documenti', - }, - ], - }, - tutorials: { - subtitle: - 'Non sai come si manda un messaggio? Vuoi creare un servizio ma non sai da dove iniziare? Risolvi ogni dubbio con questi brevi tutorial.', - list: appIoTutorials, - }, - postIntegration: { - cta: { - label: 'Vai al manuale dei servizi', - href: `${appIOGuideListsPath.path}/manuale-servizi`, - }, - subtitle: - 'Scopri cosa può fare un servizio su IO e come pubblicarlo in app. Leggi il manuale dei servizi per creare un servizio da zero o personalizza uno dei tanti modelli disponibili.', - listTitle: 'MODELLI DEI SERVIZI', - serviceModels: [ - { - title: 'Tassa sui rifiuti (TARI)', - description: - 'Scheda e modelli di messaggi del servizio che invia comunicazioni in merito alla Tassa sui rifiuti (TARI)', - href: `${appIOGuideListsPath.path}/modelli-servizi/casa-e-utenze/tassa-sui-rifiuti-tari`, - }, - { - title: "Carta d'Identità Elettronica", - description: - "Scheda e modelli di messaggi del servizio che riguarda la richiesta e l'emissione della Carta d'Identità Elettronica", - href: `${appIOGuideListsPath.path}/modelli-servizi/servizi-anagrafici-e-civici/carta-didentita-elettronica`, - }, - { - title: 'Asilo Nido', - description: - 'Scheda e modelli di messaggi del servizio che riguarda a ricezione delle comunicazioni riguardanti il sistema scolastico frequentato dai figli a carico ', - href: `${appIOGuideListsPath.path}/modelli-servizi/educazione-e-formazione/asilo-nido`, - }, - { - title: 'Multe per violazioni codice della strada', - description: - 'Scheda e modelli di messaggi del servizio che riguarda le violazioni al Codice della Strada', - href: `${appIOGuideListsPath.path}/modelli-servizi/mobilita-e-trasporti/multe-per-violazioni-al-codice-della-strada`, - }, - ], - }, - relatedLinks: { - title: 'Link utili', - links: [ - { - text: 'Consulta alcuni dei modelli utili per configurare i servizi su IO', - href: `${appIOGuideListsPath.path}/modelli-servizi`, - }, - { - text: 'Consulta FAQ e approfondimenti nella documentazione di supporto agli Enti', - href: `${appIOGuideListsPath.path}/supporto-agli-enti`, - }, - { - text: 'Scarica il contratto di adesione a IO', - href: 'https://28648410-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FZugEhXfhuchEaSiqU3p5%2Fuploads%2FygbXW3iAtEO4zjdRaFKr%2FAccordo%20di%20Adesione%20IO_v.2.4_30_giugno_2024.pdf?alt=media', - }, - { - text: 'Leggi kit di comunicazione', - href: `${appIOGuideListsPath.path}/kit-comunicazione`, - }, - ], - }, - startInfo: { - cta: { - text: 'Scopri tutti i dettagli dell’integrazione', - label: 'Leggi la guida tecnica', - href: `${appIOGuideListsPath.path}/io-guida-tecnica`, - }, - cards: [ - { - title: 'Quick Start', - text: 'Aderire a IO tramite l’Area Riservata, creare un servizio, verificare l’esistenza di un utente, inviare un messaggio: ecco come si fa', - href: `${appIoQuickStartGuidePath.path}`, - iconName: 'FlagOutlined', - iconColor: 'primary.dark', - useSrc: false, - }, - { - title: 'Documentazione API', - text: "Esplora le API Rest per l'invio dei messaggi e la creazione di servizi sull'app IO", - href: '/app-io/api', - iconName: 'Code', - iconColor: 'primary.dark', - useSrc: false, - }, - ], - }, - bannerLinks: appIoBannerLinks, -}; diff --git a/apps/nextjs-website/src/_contents/appIo/overviewPath.ts b/apps/nextjs-website/src/_contents/appIo/overviewPath.ts deleted file mode 100644 index 96a15bfe0..000000000 --- a/apps/nextjs-website/src/_contents/appIo/overviewPath.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { Path } from '@/lib/types/path'; - -export const appIoOverviewPath: Path = { - name: 'Panoramica', - path: '/app-io/overview', -}; diff --git a/apps/nextjs-website/src/_contents/appIo/quickStartGuide.ts b/apps/nextjs-website/src/_contents/appIo/quickStartGuide.ts deleted file mode 100644 index 01b805539..000000000 --- a/apps/nextjs-website/src/_contents/appIo/quickStartGuide.ts +++ /dev/null @@ -1,222 +0,0 @@ -import { QuickStartGuideData } from '@/lib/types/quickStartGuideData'; -import { appIo } from '@/_contents/appIo/appIo'; -import { appIoQuickStartGuidePath } from '@/_contents/appIo/quickStartGuidePath'; -import { appIoBannerLinks } from '@/_contents/appIo/bannerLinks'; - -export const appIoQuickStartGuide: QuickStartGuideData = { - ...appIoQuickStartGuidePath, - product: appIo, - abstract: { - title: 'Quick start', - description: - 'Se vuoi sapere cosa devi fare per integrarti, sei nel posto giusto. Con la quick start scoprirai in poco tempo tutti i passaggi che compongono il processo di integrazione.', - }, - defaultStepAnchor: '01', - steps: [ - { - title: "Aderisci tramite l'Area Riservata", - anchor: '01', - parts: [ - { - component: 'innerHTMLLazyLoaded', - html: "Prima di poter utilizzare le API di IO, il tuo ente dovrà avere un'adesione base attiva. Se non la possiede, il primo passo è quello di eseguire il processo di onboarding ad App IO tramite l'Area Riservata.", - }, - ], - }, - { - title: 'Crea un servizio', - anchor: '02', - parts: [ - { - component: 'typography', - text: 'Segui i passaggi indicati nel video interattivo per scoprire come creare un servizio destinato ai cittadini e generare l’API-key che ti servirà per chiamare tutte le API di IO.', - }, - { - component: 'innerHTMLLazyLoaded', - html: - `
\n` + - ` \n` + - `
\n`, - }, - ], - }, - { - title: 'Autenticazione nella connettività in ingresso (ex modello 3)', - anchor: '03', - parts: [ - { - component: 'innerHTMLLazyLoaded', - html: `Modifica la tua applicazione affinché inserisca nell’header delle richieste SOAP la chiave Ocp-Apim-Subscription-Key avente il valore della API key rilasciata nel passaggio precedente, di seguito a titolo di esempio una possibile chiamata.`, - }, - { - component: 'codeBlock', - code: - `curl --location --request POST \\ \n` + - `'https:///nodo-auth/node-for-psp/v1' \\ \n` + - `--header 'SOAPAction: verifyPaymentNotice' \\ \n` + - `--header 'Content-Type: application/xml' \\ \n` + - `--header 'Ocp-Apim-Subscription-Key: ocpapimsubscriptionstring..' \\ \n` + - `--header 'Cookie: here cookiestring12345678....' \n` + - `\\--data-raw ' \n` + - `' \n` + - ` \n` + - ` \n` + - ` \n` + - ` ID_PSP \n` + - ` 123456789 \n` + - ` 123456789_01 \n` + - ` \n` + - ` 77777777777 \n` + - ` 0000111111112222222 \n` + - ` \n` + - ` \n` + - ` \n` + - ` ' \n`, - language: 'txt', - }, - ], - }, - { - title: 'Connettività in uscita (ex modello 1)', - anchor: '04', - parts: [ - { - component: 'innerHTMLLazyLoaded', - html: `

Scarica il certificato pubblico messo a disposizione da PagoPA e abilita la mutua autenticazione. I certificati sono pubblicati e quindi scaricabili sul repository https://github.com/pagopa/pagopa-node-forwarder.

`, - }, - { - component: 'alert', - severity: 'info', - title: 'Per accedere al repository devi essere accreditato', - }, - ], - }, - { - title: 'Processi di pagamento', - anchor: '05', - parts: [ - { - component: 'innerHTMLLazyLoaded', - html: `

Procedi con i processi di pagamento secondo la documentazione che trovi qui.

`, - }, - ], - }, - ], - bannerLinks: pagoPaBannerLinks, -}; diff --git a/apps/nextjs-website/src/_contents/pagoPa/quickStartGuidePath.ts b/apps/nextjs-website/src/_contents/pagoPa/quickStartGuidePath.ts deleted file mode 100644 index e65618078..000000000 --- a/apps/nextjs-website/src/_contents/pagoPa/quickStartGuidePath.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { Path } from '@/lib/types/path'; - -export const pagoPaQuickStartGuidePath: Path = { - name: 'Quick start', - path: '/pago-pa/quick-start', -}; diff --git a/apps/nextjs-website/src/_contents/pagoPa/tutorialLists.ts b/apps/nextjs-website/src/_contents/pagoPa/tutorialLists.ts deleted file mode 100644 index 5e6546bf3..000000000 --- a/apps/nextjs-website/src/_contents/pagoPa/tutorialLists.ts +++ /dev/null @@ -1,73 +0,0 @@ -import { pagoPa } from '@/_contents/pagoPa/pagoPa'; -import { pagoPaTutorialListsPath } from '@/_contents/pagoPa/tutorialListsPath'; -import { TutorialListsData } from '@/lib/types/tutorialListsData'; -import { Tutorial } from '@/lib/types/tutorialData'; -import { pagoPaBannerLinks } from '@/_contents/pagoPa/bannerLinks'; - -export const pagoPaTutorials: readonly Tutorial[] = [ - { - title: 'Come migrare alla Nuova Connettività', - path: `${pagoPaTutorialListsPath.path}/come-migrare-alla-nuova-connettivita`, - name: 'Come migrare alla Nuova Connettività', - image: { - url: '/images/pagopa-nuova-connetivita.png', - alternativeText: 'Immagine: Come migrare alla Nuova Connettività', - }, - showInOverview: true, - }, - { - title: 'Come richiedere pagamenti che contengono marca da bollo digitale', - path: `${pagoPaTutorialListsPath.path}/come-richiedere-pagamenti-che-contengono-marca-da-bollo-digitale`, - name: 'Come richiedere pagamenti che contengono marca da bollo digitale', - image: { - url: '/images/pago-pa-marca-bollo.png', - alternativeText: - 'Immagine: Come richiedere pagamenti che contengono marca da bollo digitale', - }, - showInOverview: true, - }, - { - title: 'Come avviare un esercizio come Ente Creditore su pagoPA', - path: `${pagoPaTutorialListsPath.path}/come-avviare-un-esercizio-come-ente-creditore-su-pagopa`, - name: 'Come avviare un esercizio come Ente Creditore su pagoPA', - image: { - url: '/images/pago-pa-creare-esercizio-ente-creditore.png', - alternativeText: - 'Immagine: Come avviare un esercizio come Ente Creditore su pagoPA', - }, - showInOverview: false, - }, - { - title: 'Come stampare un avviso di pagamento in formato PDF', - path: `${pagoPaTutorialListsPath.path}/come-stampare-un-avviso-di-pagamento-in-formato-pdf`, - name: 'Come stampare un avviso di pagamento in formato PDF', - image: { - url: '/images/pago-pa-stampare-avviso-pagamento.png', - alternativeText: - 'Immagine: Come stampare un avviso di pagamento in formato PDF', - }, - showInOverview: true, - }, - { - title: 'Come diventare Partner Tecnologico di PagoPA', - path: `${pagoPaTutorialListsPath.path}/come-diventare-partner-tecnologico-di-pagopa`, - name: 'Come diventare Partner Tecnologico di PagoPA', - image: { - url: '/images/pagopa-pt.png', - alternativeText: 'Immagine: Come diventare Partner Tecnologico di PagoPA', - }, - showInOverview: false, - }, -]; - -export const pagoPaTutorialLists: TutorialListsData = { - ...pagoPaTutorialListsPath, - product: pagoPa, - abstract: { - title: 'Tutorial', - description: - 'Quali sono i passaggi per rendere disponibili i propri servizi di pagamento sulla piattaforma pagoPA? Come si stampa un avviso di pagamento? Risolvi ogni dubbio con questi brevi tutorial.', - }, - tutorials: pagoPaTutorials, - bannerLinks: pagoPaBannerLinks, -}; diff --git a/apps/nextjs-website/src/_contents/pagoPa/tutorialListsPath.ts b/apps/nextjs-website/src/_contents/pagoPa/tutorialListsPath.ts deleted file mode 100644 index 6fcce70c5..000000000 --- a/apps/nextjs-website/src/_contents/pagoPa/tutorialListsPath.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { Path } from '@/lib/types/path'; - -export const pagoPaTutorialListsPath: Path = { - name: 'Tutorial', - path: '/pago-pa/tutorials', -}; diff --git a/apps/nextjs-website/src/_contents/pagoPa/tutorials.ts b/apps/nextjs-website/src/_contents/pagoPa/tutorials.ts deleted file mode 100644 index 5c201e96a..000000000 --- a/apps/nextjs-website/src/_contents/pagoPa/tutorials.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { pagoPa } from './pagoPa'; -import { pagoPaBannerLinks } from '@/_contents/pagoPa/bannerLinks'; -import { TutorialsDefinition } from '../makeDocs'; - -export const pagoPaTutorials: TutorialsDefinition = { - product: pagoPa, - dirName: '0daUnj7noyDC76EK6Bii', - bannerLinks: pagoPaBannerLinks, -}; diff --git a/apps/nextjs-website/src/_contents/pdnd/bannerLinks.ts b/apps/nextjs-website/src/_contents/pdnd/bannerLinks.ts deleted file mode 100644 index ccd00beba..000000000 --- a/apps/nextjs-website/src/_contents/pdnd/bannerLinks.ts +++ /dev/null @@ -1,45 +0,0 @@ -import { BannerLinkProps } from '@/components/atoms/BannerLink/BannerLink'; - -export const pdndBannerLinks: readonly BannerLinkProps[] = [ - { - theme: 'light', - icon: { - name: 'feedback.svg', - alternativeText: undefined, - caption: undefined, - size: 10, - width: 60, - height: 61, - ext: '.svg', - mime: 'image/svg+xml', - url: '/icons/feedback.svg', - }, - content: [ - { - type: 'paragraph', - children: [ - { - text: 'Per segnalare problemi o dare feedback, lascia un commento nello ', - type: 'text', - }, - { - type: 'link', - url: 'https://github.com/pagopa/pdnd-interop-frontend/issues', - children: [ - { - type: 'text', - text: 'spazio Github', - bold: true, - }, - ], - }, - { - type: 'text', - text: ' di PDND Interoperabilità.', - }, - ], - }, - ], - title: 'Dicci cosa ne pensi', - }, -]; diff --git a/apps/nextjs-website/src/_contents/pdnd/guideLists.ts b/apps/nextjs-website/src/_contents/pdnd/guideLists.ts deleted file mode 100644 index 384359271..000000000 --- a/apps/nextjs-website/src/_contents/pdnd/guideLists.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { GuideListsData } from '@/lib/types/guideListsData'; -import { pdnd } from '@/_contents/pdnd/pdnd'; -import { pdndGuideListsPath } from '@/_contents/pdnd/guideListsPath'; -import { pdndBannerLinks } from '@/_contents/pdnd/bannerLinks'; - -export const pdndGuideLists: GuideListsData = { - ...pdndGuideListsPath, - product: pdnd, - abstract: { - title: 'Guide e manuali', - description: - 'Per una conoscenza approfondita o dubbi puntuali, consulta i manuali e le guide disponibili per PDND Interoperabilità.', - }, - guidesSections: [ - { - title: "Per l'integrazione", - guides: [ - { - title: 'Manuale operativo', - description: { - title: 'Argomenti trattati', - listItems: [ - 'Scopri come aderire a PDND Interoperabilità', - 'Richiedi e utilizza un voucher', - 'Sottoscrivi una richiesta di fruizione', - 'Crea e gestisci un e-service', - ], - }, - link: { - href: `${pdndGuideListsPath.path}/manuale-operativo`, - label: 'Vai al manuale', - }, - imagePath: '/images/manuale-operativo.png', - mobileImagePath: '/images/manuale-operativo-mobile.png', - }, - ], - }, - ], - bannerLinks: pdndBannerLinks, -}; diff --git a/apps/nextjs-website/src/_contents/pdnd/guideListsPath.ts b/apps/nextjs-website/src/_contents/pdnd/guideListsPath.ts deleted file mode 100644 index 8d81d28c4..000000000 --- a/apps/nextjs-website/src/_contents/pdnd/guideListsPath.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { Path } from '@/lib/types/path'; - -export const pdndGuideListsPath: Path = { - name: 'Guide e manuali', - path: '/pdnd-interoperabilita/guides', -}; diff --git a/apps/nextjs-website/src/_contents/pdnd/guides.ts b/apps/nextjs-website/src/_contents/pdnd/guides.ts deleted file mode 100644 index e4d529e6a..000000000 --- a/apps/nextjs-website/src/_contents/pdnd/guides.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { pdnd } from './pdnd'; -import { GuideDefinition } from '../makeDocs'; -import { pdndBannerLinks } from '@/_contents/pdnd/bannerLinks'; - -const manualeOperativo: GuideDefinition = { - product: pdnd, - guide: { - name: 'Manuale operativo', - slug: `manuale-operativo`, - }, - versions: [ - { - main: true, - version: 'v1.0', - dirName: 'b8HnYwaAzhxRFAZdZBXL', - }, - ], - bannerLinks: pdndBannerLinks, -}; - -export const pdndGuides = [manualeOperativo]; diff --git a/apps/nextjs-website/src/_contents/pdnd/overview.ts b/apps/nextjs-website/src/_contents/pdnd/overview.ts deleted file mode 100644 index f2f951e01..000000000 --- a/apps/nextjs-website/src/_contents/pdnd/overview.ts +++ /dev/null @@ -1,94 +0,0 @@ -import { OverviewData } from '@/lib/types/overviewData'; -import { pdnd } from '@/_contents/pdnd/pdnd'; -import { pdndOverviewPath } from '@/_contents/pdnd/overviewPath'; -import { pdndTutorials } from '@/_contents/pdnd/tutorialLists'; -import { pdndBannerLinks } from '@/_contents/pdnd/bannerLinks'; -import { pdndQuickStartGuidePath } from '@/_contents/pdnd/quickStartGuidePath'; - -export const pdndOverview: OverviewData = { - ...pdndOverviewPath, - product: pdnd, - hero: { - altText: - 'La piattaforma che abilita lo scambio di informazioni tra gli enti', - backgroundImage: '/images/hero.jpg', - title: 'La piattaforma che abilita lo scambio di informazioni tra gli enti', - subtitle: - 'PDND Interoperabiltà rende semplice e sicuro lo scambio di informazioni tramite un processo standard. Come? Su PDND Interoperabilità, ogni erogatore può integrare i servizi che gestisce e richiedere la fruizione di quelli di cui ha bisogno.', - }, - feature: { - title: 'Perché PDND Interoperabilità', - subtitle: '', - items: [ - { - iconName: 'MessageRounded', - subtitle: - 'Offre un solo catalogo di servizi consultabile da tutti gli aderenti', - title: 'Unica', - }, - { - iconName: 'PaymentsRounded', - subtitle: - 'Crea un canale sicuro per autenticare e autorizzare erogatori e fruitori dei servizi ad accedere alle informazioni delle quali hanno bisogno', - title: 'Sicura', - }, - { - iconName: 'CreateRounded', - subtitle: - 'Semplifica l’iter amministrativo e riduce i tempi di accesso alle informazioni', - title: 'Veloce', - }, - ], - }, - tutorials: { - subtitle: - 'Vuoi scoprire cos’è una Finalità su PDND Interoperabilità? Vuoi capire come mettere un servizio a disposizione di altri enti? Questi tutorial possono aiutarti.', - list: pdndTutorials, - }, - relatedLinks: { - title: 'Link utili', - links: [ - { - text: 'Linee guida PDND Interoperabilità redatte da AgID e aggiornamento a maggio 2023', - href: 'https://trasparenza.agid.gov.it/archivio28_provvedimenti-amministrativi_0_123064_725_1.html', - }, - { - text: 'Parere del Garante per la Protezione dei Dati Personali', - href: 'https://www.garanteprivacy.it/web/guest/home/docweb/-/docweb-display/docweb/9732758', - }, - { - text: 'PDND - Piattaforma Digitale Nazionale Dati', - href: 'https://developers.italia.it/it/pdnd/', - }, - { - text: 'Ecosistema Interoperabilità', - href: 'https://next.developers.italia.it/it/interoperabilita/', - }, - { - text: 'Articolo 50-ter', - href: 'https://www.normattiva.it/atto/caricaDettaglioAtto?atto.dataPubblicazioneGazzetta=2005-05-16&atto.codiceRedazionale=005G0104&atto.articolo.numero=0&atto.articolo.sottoArticolo=1&atto.articolo.sottoArticolo1=10&qId=5614860b-4769-478e-bf22-a8a76a04159a&tabID=0.5538263478162919&title=lbl.dettaglioAtto', - }, - ], - }, - startInfo: { - cards: [ - { - title: 'Quick Start', - text: 'Scopri come iscriverti a un e-service partendo dal catalogo e ottenere un voucher per la fruizione del sevizio.', - href: `${pdndQuickStartGuidePath.path}`, - iconName: 'FlagOutlined', - iconColor: 'primary.dark', - useSrc: false, - }, - { - title: 'Manuale operativo', - text: 'Approfondisci tutti i dettagli di PDND Interoperabilità, dall’adesione alla piattaforma, alla creazione e gestione di un e-service.', - href: '/pdnd-interoperabilita/guides/manuale-operativo', - iconName: 'MenuBook', - iconColor: 'primary.dark', - useSrc: false, - }, - ], - }, - bannerLinks: pdndBannerLinks, -}; diff --git a/apps/nextjs-website/src/_contents/pdnd/overviewPath.ts b/apps/nextjs-website/src/_contents/pdnd/overviewPath.ts deleted file mode 100644 index 6dd0c46d2..000000000 --- a/apps/nextjs-website/src/_contents/pdnd/overviewPath.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { Path } from '@/lib/types/path'; - -export const pdndOverviewPath: Path = { - name: 'Panoramica', - path: '/pdnd-interoperabilita/overview', -}; diff --git a/apps/nextjs-website/src/_contents/pdnd/pdnd.ts b/apps/nextjs-website/src/_contents/pdnd/pdnd.ts deleted file mode 100644 index 4c3e59319..000000000 --- a/apps/nextjs-website/src/_contents/pdnd/pdnd.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { Product } from '@/lib/types/product'; -import { pdndGuideListsPath } from '@/_contents/pdnd/guideListsPath'; -import { pdndOverviewPath } from '@/_contents/pdnd/overviewPath'; -import { pdndQuickStartGuidePath } from '@/_contents/pdnd/quickStartGuidePath'; -import { pdndTutorialListsPath } from '@/_contents/pdnd/tutorialListsPath'; -import { pdndBannerLinks } from './bannerLinks'; - -export const pdnd: Product = { - name: 'PDND Interoperabilità', - shortName: 'PDND', - description: - 'Integra i tuoi servizi tramite PDND Interoperabiltà, la piattaforma che abilita lo scambio di informazioni tra gli enti. ', - slug: 'pdnd-interoperabilita', - path: '/pdnd-interoperabilita', - logo: { - alternativeText: 'PDND Interoperabilità', - caption: undefined, - size: 10, - name: '', - width: 60, - height: 61, - ext: '.svg', - mime: 'image/svg+xml', - url: '/icons/pdnd.svg', - }, - subpaths: { - overview: pdndOverviewPath, - quickStart: pdndQuickStartGuidePath, - tutorials: pdndTutorialListsPath, - guides: pdndGuideListsPath, - }, - bannerLinks: pdndBannerLinks, -}; diff --git a/apps/nextjs-website/src/_contents/pdnd/quickStartGuide.ts b/apps/nextjs-website/src/_contents/pdnd/quickStartGuide.ts deleted file mode 100644 index 41f199a54..000000000 --- a/apps/nextjs-website/src/_contents/pdnd/quickStartGuide.ts +++ /dev/null @@ -1,165 +0,0 @@ -import { QuickStartGuideData } from '@/lib/types/quickStartGuideData'; -import { pdnd } from '@/_contents/pdnd/pdnd'; -import { pdndQuickStartGuidePath } from '@/_contents/pdnd/quickStartGuidePath'; -import { pdndBannerLinks } from '@/_contents/pdnd/bannerLinks'; - -export const pdndQuickStartGuide: QuickStartGuideData = { - ...pdndQuickStartGuidePath, - product: pdnd, - abstract: { - title: 'Quick start', - description: - 'Se vuoi sapere come iscriverti a un e-service partendo dal catalogo e ottenere un voucher per la fruizione del sevizio.', - }, - defaultStepAnchor: '01', - steps: [ - { - title: 'Naviga nel catalogo degli e-service', - anchor: '01', - parts: [ - { - component: 'typography', - text: 'Il primo passaggio per fruire di un e-service è navigare nel catalogo. Nel video interattivo seguente è possibile vedere come selezionare, visualizzare i dettagli tecnici e accedere ai contatti dell’erogatore per un specifico e-service.', - }, - { - component: 'innerHTMLLazyLoaded', - html: - `
\n` + - `