Skip to content

Commit

Permalink
[DEV-1389] Migrate to cms the "Discover our ecosystem" section in hom…
Browse files Browse the repository at this point in the history
…e page (#632)
  • Loading branch information
marcobottaro authored Feb 19, 2024
1 parent 945394d commit 1e4b96e
Show file tree
Hide file tree
Showing 19 changed files with 187 additions and 40 deletions.
5 changes: 5 additions & 0 deletions .changeset/nine-wombats-pretend.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"nextjs-website": minor
---

Allow fetching from the CMS the "Discover our ecosystem" section on the home page
5 changes: 5 additions & 0 deletions .changeset/slimy-turkeys-flash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"strapi-cms": minor
---

Set logo as required in product schema
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
import { productToMenuItems } from '../../helpers/productHeader.helper';
import { productToMenuItems } from '@/helpers/productHeader.helper';
import { Product } from '@/lib/types/product';

const product: Product = {
name: 'test',
description: 'test',
svgPath: 'test',
logo: {
name: 'test',
width: 60,
height: 61,
ext: '.svg',
mime: 'image/svg+xml',
url: 'test',
},
path: '/path',
slug: 'path',
subpaths: {
Expand Down
13 changes: 9 additions & 4 deletions apps/nextjs-website/src/_contents/appIo/appIo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,21 @@ 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 { baseUrl } from '@/config';

export const appIo: Product = {
name: 'IO, l’app dei servizi pubblici',
description:
'Raccogli tutti i servizi digitali del tuo ente in un’unica piattaforma e interagisci in modo semplice e sicuro con i cittadini.',
svgPath: '/icons/appIo.svg',
pngUrl: `${baseUrl}/icons/appIo.png`,
path: '/app-io',
slug: 'app-io',
path: '/app-io',
logo: {
name: '',
width: 60,
height: 61,
ext: '.svg',
mime: 'image/svg+xml',
url: '/icons/appIo.svg',
},
subpaths: {
overview: appIoOverviewPath,
quickStart: appIoQuickStartGuidePath,
Expand Down
15 changes: 10 additions & 5 deletions apps/nextjs-website/src/_contents/ioSign/ioSign.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,21 @@ import { ioSignOverviewPath } from '@/_contents/ioSign/overviewPath';
import { ioSignTutorialListsPath } from '@/_contents/ioSign/tutorialListsPath';
import { Product } from '@/lib/types/product';
import { ioSignQuickStartGuidePath } from './quickStartGuidePath';
import { baseUrl } from '@/config';

export const ioSign: Product = {
name: 'Firma con IO',
slug: 'firma-con-io',
path: '/firma-con-io',
description:
'Richiedi la Firma Elettronica Certificata su contratti e documenti. Le cittadine e i cittadini possono firmare direttamente sull’app IO.',
svgPath: '/icons/appIo.svg',
pngUrl: `${baseUrl}/icons/appIo.png`,
slug: 'firma-con-io',
path: '/firma-con-io',
logo: {
name: '',
width: 60,
height: 61,
ext: '.svg',
mime: 'image/svg+xml',
url: '/icons/appIo.svg',
},
subpaths: {
overview: ioSignOverviewPath,
quickStart: ioSignQuickStartGuidePath,
Expand Down
16 changes: 11 additions & 5 deletions apps/nextjs-website/src/_contents/pagoPa/pagoPa.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,22 @@ import { pagoPaOverviewPath } from '@/_contents/pagoPa/overviewPath';
import { pagoPaTutorialListsPath } from '@/_contents/pagoPa/tutorialListsPath';
import { pagoPaQuickStartGuidePath } from '@/_contents/pagoPa/quickStartGuidePath';
import { Product } from '@/lib/types/product';
import { baseUrl } from '@/config';

export const pagoPa: Product = {
name: 'Piattaforma pagoPA',
path: '/pago-pa',
slug: 'pago-pa',
description:
'Gestisci gli incassi in modo centralizzato e con immediata riconciliazione delle posizioni debitorie.',
svgPath: '/icons/pagoPa.svg',
pngUrl: `${baseUrl}/icons/pagoPa.png`,
path: '/pago-pa',
slug: 'pago-pa',
logo: {
name: '',
width: 60,
height: 61,
ext: '.svg',
mime: 'image/svg+xml',
url: '/icons/pagoPa.svg',
},

subpaths: {
overview: pagoPaOverviewPath,
quickStart: pagoPaQuickStartGuidePath,
Expand Down
15 changes: 10 additions & 5 deletions apps/nextjs-website/src/_contents/send/send.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,21 @@ import { sendGuideListsPath } from '@/_contents/send/guideListsPath';
import { sendOverviewPath } from '@/_contents/send/overviewPath';
import { sendTutorialListsPath } from '@/_contents/send/tutorialListsPath';
import { sendQuickStartGuidePath } from '@/_contents/send/quickStartGuidePath';
import { baseUrl } from '@/config';

export const send: Product = {
name: 'SEND - Servizio Notifiche Digitali',
path: '/send',
slug: 'send',
description:
'Invia comunicazioni a valore legale con un processo di notificazione gestito interamente dalla piattaforma.',
svgPath: '/icons/send.svg',
pngUrl: `${baseUrl}/icons/send.png`,
slug: 'send',
path: '/send',
logo: {
name: '',
width: 60,
height: 61,
ext: '.svg',
mime: 'image/svg+xml',
url: '/icons/send.svg',
},
subpaths: {
overview: sendOverviewPath,
quickStart: sendQuickStartGuidePath,
Expand Down
9 changes: 8 additions & 1 deletion apps/nextjs-website/src/_contents/translations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
import { ioSignTutorialListsPath } from '@/_contents/ioSign/tutorialListsPath';
import { sendGuideListsPath } from '@/_contents/send/guideListsPath';
import { pagoPaQuickStartGuidePath } from '@/_contents/pagoPa/quickStartGuidePath';
import { send } from '@/_contents/send/send';
import { appIo } from '@/_contents/appIo/appIo';
import { ioSign } from '@/_contents/ioSign/ioSign';
import { pagoPa } from '@/_contents/pagoPa/pagoPa';

export const translations = {
header: {
Expand Down Expand Up @@ -85,7 +89,10 @@ export const translations = {
],
},
webinarBannerButtonContent: 'Scopri',
productsShowcaseTitle: 'Scopri il nostro ecosistema',
productsShowcase: {
title: 'Scopri il nostro ecosistema',
products: [appIo, ioSign, pagoPa, send],
},
heroItems: [
{
title: 'Tutto ciò che serve per integrarsi con i prodotti PagoPA',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export async function generateMetadata(
title: product.name,
description: product.description,
url: path,
image: product.pngUrl,
image: product.logo.url,
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export async function generateMetadata(
title: abstract?.title,
description: abstract?.description,
url: path,
image: product.pngUrl,
image: product.logo.url,
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export async function generateMetadata(
title: product.name,
description: abstract?.description,
url: path,
image: product.pngUrl,
image: product.logo.url,
});
}

Expand Down
11 changes: 5 additions & 6 deletions apps/nextjs-website/src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import News from '@/components/organisms/News/News';
import ProductsShowcase from '@/components/organisms/ProductsShowcase/ProductsShowcase';
import { Metadata } from 'next';
import { makeMetadata } from '@/helpers/metadata.helpers';
import { getProducts, getVisibleInHomeWebinars } from '@/lib/api';
import { getVisibleInHomeWebinars } from '@/lib/api';
import dynamic from 'next/dynamic';
import { baseUrl } from '@/config';
import { getHomepageProps } from '@/lib/cmsApi';
Expand All @@ -31,7 +31,6 @@ const NotSsrWebinarsSection = dynamic(
);

const Home = async () => {
const products = await getProducts();
const webinars = await getVisibleInHomeWebinars();
const { header } = translations;

Expand All @@ -56,12 +55,12 @@ const Home = async () => {
cards={[...homepage.news.cards]}
/>
<ProductsShowcase
title={homepage.productsShowcaseTitle}
cards={products.map((product) => ({
title={homepage.productsShowcase.title}
cards={homepage.productsShowcase.products.map((product) => ({
title: product.name,
text: product.description,
href: product.subpaths.overview.path,
svgPath: product.svgPath,
href: `/${product.slug}/overview`,
logoUrl: product.logo.url,
}))}
/>
<NotSsrWebinarsSection webinars={[...webinars]} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const CardsGrid = ({

return (
<EContainer>
<Box pb={4}>
<Box pb={4} width={'100%'}>
<Grid container spacing={3}>
{cards.map(({ title, text, href, icon, comingSoon }, index) => {
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ type ProductsShowcaseProps = {
title: string;
text: string;
href: string;
svgPath: string;
logoUrl: string;
}[];
};

Expand All @@ -26,7 +26,7 @@ const ProductsShowcase = ({ title, cards }: ProductsShowcaseProps) => {
title: card.title,
text: card.text,
href: card.href,
icon: card.svgPath,
icon: card.logoUrl,
}))}
/>
</Box>
Expand Down
30 changes: 28 additions & 2 deletions apps/nextjs-website/src/lib/homepage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,22 @@ export type HomepageProps = {
};
}[];
};
readonly productsShowcaseTitle: string;
readonly productsShowcase: {
readonly title: string;
readonly products: readonly {
readonly name: string;
readonly description: string;
readonly slug: string;
readonly logo: {
readonly name: string;
readonly width: number;
readonly height: number;
readonly ext: string;
readonly mime: string;
readonly url: string;
};
}[];
};
readonly comingsoonDocumentation: {
readonly title: string;
readonly links: readonly {
Expand All @@ -46,6 +61,17 @@ export const makeHomepageProps = (
...makeHomepagePropsFromStatic(staticHeader, staticHomepage),
comingsoonDocumentation:
strapiHomepage.data.attributes.comingsoonDocumentation,
productsShowcase: {
title: strapiHomepage.data.attributes.productsShowcase.title,
products: strapiHomepage.data.attributes.productsShowcase.products.data.map(
(product) => ({
name: product.attributes.name,
description: product.attributes.description,
slug: product.attributes.slug,
logo: product.attributes.logo.data.attributes,
})
),
},
});

export const makeHomepagePropsFromStatic = (
Expand All @@ -61,6 +87,6 @@ export const makeHomepagePropsFromStatic = (
title: staticHomepage.news.title,
cards: staticHomepage.news.list,
},
productsShowcaseTitle: staticHomepage.productsShowcaseTitle,
productsShowcase: staticHomepage.productsShowcase,
comingsoonDocumentation: staticHomepage.comingsoonDocumentation,
});
43 changes: 43 additions & 0 deletions apps/nextjs-website/src/lib/strapi/__tests__/homepage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,49 @@ const makeStrapiResponseJson = () => ({
},
],
},
productsShowcase: {
id: 1,
title: 'aText',
products: {
data: [
{
id: 1,
attributes: {
name: 'aText',
description: 'aText',
slug: 'a-slug',
createdAt: '2024-02-09T13:32:16.646Z',
updatedAt: '2024-02-09T13:32:25.171Z',
publishedAt: '2024-02-09T13:32:25.170Z',
locale: 'it',
logo: {
data: {
id: 2,
attributes: {
name: 'aFileName.svg',
alternativeText: null,
caption: null,
width: 60,
height: 61,
formats: null,
hash: 'a_file_name_714c6d0fd3',
ext: '.svg',
mime: 'image/svg+xml',
size: 1.9,
url: '/uploads/a_file_name_714c6d0fd3.svg',
previewUrl: null,
provider: 'local',
provider_metadata: null,
createdAt: '2024-02-07T17:29:12.923Z',
updatedAt: '2024-02-07T17:29:12.923Z',
},
},
},
},
},
],
},
},
},
},
meta: {},
Expand Down
Loading

0 comments on commit 1e4b96e

Please sign in to comment.