From ecfa89ce3fcc7ab4c24b69697c8f17fa133def5d Mon Sep 17 00:00:00 2001 From: Daniel Pokorny Date: Thu, 27 Jul 2023 04:10:56 +0200 Subject: [PATCH] get rid of milestones, refactor for facts --- .env.local.template | 2 +- .../shared/{GenericAction.tsx => Fact.tsx} | 0 components/shared/visualContainer/Grid.tsx | 8 +-- components/shared/visualContainer/Stack.tsx | 2 +- .../visualContainer/VisualContainer.tsx | 11 ++-- lib/kontentClient.ts | 6 +- models/content-types/Block_VisualContainer.ts | 3 +- models/content-types/WSL_Page.ts | 10 +-- models/content-types/WSL_WebSpotlightRoot.ts | 8 +-- models/content-types/index.ts | 1 - models/content-types/milestone.ts | 25 -------- models/project/assetFolders.ts | 6 +- models/project/collections.ts | 6 +- models/project/contentTypeSnippets.ts | 6 +- models/project/contentTypes.ts | 61 ++++--------------- models/project/languages.ts | 6 +- models/project/roles.ts | 6 +- models/project/taxonomies.ts | 6 +- models/project/webhooks.ts | 6 +- models/project/workflows.ts | 6 +- 20 files changed, 59 insertions(+), 126 deletions(-) rename components/shared/{GenericAction.tsx => Fact.tsx} (100%) delete mode 100644 models/content-types/milestone.ts diff --git a/.env.local.template b/.env.local.template index ad822f70..c33a2df9 100644 --- a/.env.local.template +++ b/.env.local.template @@ -2,7 +2,7 @@ APP_VERSION=$npm_package_version APP_NAME=$npm_package_name NEXT_PUBLIC_KONTENT_ENVIRONMENT_ID=2cedc519-a547-01ba-dde7-b01e00b909a1 KONTENT_COLLECTION_CODENAME=ficto_healthtech_surgical -# Domain for toher collection links in format : i.e. "ficto_healthtech_imaging:ficto-healthtech-imaging.vercel.app,ficto_healthtech_surgical:ficto-healthtech-surgical.vercel.app +# Domain for other collection links in format : i.e. "ficto_healthtech_imaging:ficto-healthtech-imaging.vercel.app,ficto_healthtech_surgical:ficto-healthtech-surgical.vercel.app OTHER_COLLECTIONS_DOMAINS= KONTENT_PREVIEW_API_KEY= KONTENT_MANAGEMENT_API_KEY= diff --git a/components/shared/GenericAction.tsx b/components/shared/Fact.tsx similarity index 100% rename from components/shared/GenericAction.tsx rename to components/shared/Fact.tsx diff --git a/components/shared/visualContainer/Grid.tsx b/components/shared/visualContainer/Grid.tsx index bbf3035c..621da48e 100644 --- a/components/shared/visualContainer/Grid.tsx +++ b/components/shared/visualContainer/Grid.tsx @@ -1,11 +1,11 @@ import React, { FC } from 'react' import { mainColorBgClass } from '../../../lib/constants/colors' -import { Milestone } from '../../../models'; +import { Fact } from '../../../models'; import { useSiteCodename } from '../siteCodenameContext' type Props = Readonly<{ - items: ReadonlyArray; + items: ReadonlyArray; }>; export const GridComponent: FC = props => { @@ -19,8 +19,8 @@ export const GridComponent: FC = props => { className="p-4 flex flex-col text-center items-center" key={link.system.id} > -
{link.elements.achievement.value}
-
{link.elements.subject.value}
+
{link.elements.title.value}
+
{link.elements.message.value}
))} diff --git a/components/shared/visualContainer/Stack.tsx b/components/shared/visualContainer/Stack.tsx index aeca70bc..86092588 100644 --- a/components/shared/visualContainer/Stack.tsx +++ b/components/shared/visualContainer/Stack.tsx @@ -3,7 +3,7 @@ import { FC, useState } from "react"; import { mainColorBorderClass } from "../../../lib/constants/colors"; import { createElementSmartLink, createItemSmartLink, createRelativeAddSmartLink } from "../../../lib/utils/smartLinkUtils"; import { contentTypes, Fact } from "../../../models" -import { FactComponent } from "../GenericAction"; +import { FactComponent } from "../Fact"; import { useSiteCodename } from "../siteCodenameContext"; import { StandaloneSmartLinkButton } from "../StandaloneSmartLinkButton"; diff --git a/components/shared/visualContainer/VisualContainer.tsx b/components/shared/visualContainer/VisualContainer.tsx index e5d3d88b..e55ff461 100644 --- a/components/shared/visualContainer/VisualContainer.tsx +++ b/components/shared/visualContainer/VisualContainer.tsx @@ -1,6 +1,6 @@ import { FC } from "react"; -import { Block_HeroUnit, Block_VisualContainer, contentTypes, Fact, Milestone } from "../../../models" +import { Block_HeroUnit, Block_VisualContainer, contentTypes, Fact } from "../../../models" import { BuildError } from "../ui/BuildError"; import { CarouselComponent } from "./Carousel"; import { GridComponent } from "./Grid"; @@ -15,9 +15,9 @@ export const VisualContainer: FC = props => { case visualRepresentation.grid: return ( <> - {!props.item.elements.items.linkedItems.every(isMilestone) && Grid representation can only have Milestone items. Some items are of a wrong type.} + {!props.item.elements.items.linkedItems.every(isFact) && Grid representation can only have Fact items. Some items are of a wrong type.} ); @@ -55,10 +55,7 @@ const visualRepresentation = { stack: "stack", } as const; -type VisualContainerItem = Fact | Milestone | Block_HeroUnit; - -const isMilestone = (item: VisualContainerItem): item is Milestone => - item.system.type === contentTypes.milestone.codename; +type VisualContainerItem = Fact | Block_HeroUnit; const isFact = (item: VisualContainerItem): item is Fact => item.system.type === contentTypes.fact.codename; diff --git a/lib/kontentClient.ts b/lib/kontentClient.ts index 1812ec3a..6bb49f4f 100644 --- a/lib/kontentClient.ts +++ b/lib/kontentClient.ts @@ -66,7 +66,7 @@ export const getItemByCodename = (codename: PerCo const homepageTypeCodename = "web_spotlight_root" as const; -export const getHomepage = (usePreview: boolean) => +export const getHomepage = async (usePreview: boolean) => deliveryClient .items() .type(homepageTypeCodename) @@ -76,10 +76,10 @@ export const getHomepage = (usePreview: boolean) => waitForLoadingNewContent: usePreview }) .depthParameter(10) - .toPromise() + .toAllPromise() .then(res => res.data.items[0] as WSL_WebSpotlightRoot | undefined) -export const getProductsForListing = (usePreview: boolean, page?: number, categories?: string[], pageSize: number = ProductsPageSize) => { +export const getProductsForListing = async (usePreview: boolean, page?: number, categories?: string[], pageSize: number = ProductsPageSize) => { const query = deliveryClient .items() .type(contentTypes.product.codename) diff --git a/models/content-types/Block_VisualContainer.ts b/models/content-types/Block_VisualContainer.ts index 918654a3..66e0a28f 100644 --- a/models/content-types/Block_VisualContainer.ts +++ b/models/content-types/Block_VisualContainer.ts @@ -2,7 +2,6 @@ import { type IContentItem, type Elements } from '@kontent-ai/delivery-sdk'; import { type Block_EmojiGuideline } from '../content-type-snippets/Block_EmojiGuideline'; import { type Block_HeroUnit } from './Block_HeroUnit'; import { type Fact } from './fact'; -import { type Milestone } from './milestone'; /** * Generated by '@kontent-ai/model-generator@5.10.0' @@ -18,7 +17,7 @@ export type Block_VisualContainer = IContentItem<{ * Id: 081f63c6-9589-5f8d-a9de-bc3b1ceb24e7 * Codename: items */ - items: Elements.LinkedItemsElement; + items: Elements.LinkedItemsElement; /** * Subtitle (text) diff --git a/models/content-types/WSL_Page.ts b/models/content-types/WSL_Page.ts index 56545ba4..5a307e51 100644 --- a/models/content-types/WSL_Page.ts +++ b/models/content-types/WSL_Page.ts @@ -11,14 +11,14 @@ import { type WSL_WebSpotlightRoot } from './WSL_WebSpotlightRoot'; * Generated by '@kontent-ai/model-generator@5.10.0' * * 💡 Page - * Id: 2d783b04-c9ac-42f5-bd34-959340e8e2ac + * Id: 0cb81f69-3f4b-46a1-8ce2-0aada4cdc358 * Codename: page */ export type WSL_Page = IContentItem<{ /** * Content (modular_content) * Required: false - * Id: dc3e831e-0157-41c8-b4a4-ff95b576a71e + * Id: 27bc37be-796c-4219-a85d-cd61fc2e4f43 * Codename: content */ content: Elements.LinkedItemsElement< @@ -28,7 +28,7 @@ export type WSL_Page = IContentItem<{ /** * Subpages (subpages) * Required: false - * Id: ce96b539-ab2f-4ddf-8e94-e79acf2aec1a + * Id: 7e159b22-7b95-4a9b-9e2a-a79d407edd76 * Codename: subpages */ subpages: Elements.LinkedItemsElement; @@ -36,7 +36,7 @@ export type WSL_Page = IContentItem<{ /** * Title (text) * Required: false - * Id: aa8bd39c-ad1d-4557-ada1-7422f07a4f47 + * Id: c2808c7e-9f57-4d0b-815c-f535752ed1cd * Codename: title */ title: Elements.TextElement; @@ -44,7 +44,7 @@ export type WSL_Page = IContentItem<{ /** * URL (url_slug) * Required: false - * Id: 4e9acc07-f7e9-49ae-a992-88e791b07204 + * Id: 434f911b-c645-46e1-a633-0c8a3b1e9207 * Codename: url */ url: Elements.UrlSlugElement; diff --git a/models/content-types/WSL_WebSpotlightRoot.ts b/models/content-types/WSL_WebSpotlightRoot.ts index 85a0fe9b..2df1a4e5 100644 --- a/models/content-types/WSL_WebSpotlightRoot.ts +++ b/models/content-types/WSL_WebSpotlightRoot.ts @@ -12,14 +12,14 @@ import { type WSL_Page } from './WSL_Page'; * Generated by '@kontent-ai/model-generator@5.10.0' * * 💡 Web spotlight root - * Id: 746e489b-4dbe-403a-a9db-0876fddfb68b + * Id: eba96027-914d-48f7-a7f8-38502fa7e869 * Codename: web_spotlight_root */ export type WSL_WebSpotlightRoot = IContentItem<{ /** * Content (modular_content) * Required: false - * Id: 376309cf-f65e-43ab-a104-118f5c143413 + * Id: 0273c87b-86ae-4c9b-8e49-d064f25d1417 * Codename: content */ content: Elements.LinkedItemsElement< @@ -37,7 +37,7 @@ export type WSL_WebSpotlightRoot = IContentItem<{ /** * Subpages (subpages) * Required: false - * Id: a96ae5ad-8971-47ca-9a06-330193ebb7ef + * Id: 9e2d4dd9-7d9f-4365-99e0-6b1528f25215 * Codename: subpages */ subpages: Elements.LinkedItemsElement; @@ -45,7 +45,7 @@ export type WSL_WebSpotlightRoot = IContentItem<{ /** * Title (text) * Required: false - * Id: 60ff91ab-cd43-4003-a9ba-d50639b57d18 + * Id: fba9369c-61f3-4a91-a809-70129484c3ca * Codename: title */ title: Elements.TextElement; diff --git a/models/content-types/index.ts b/models/content-types/index.ts index 21439c1c..9fef5930 100644 --- a/models/content-types/index.ts +++ b/models/content-types/index.ts @@ -7,7 +7,6 @@ export * from './Block_Navigation'; export * from './Block_VisualContainer'; export * from './article'; export * from './fact'; -export * from './milestone'; export * from './person'; export * from './product'; export * from './testimonial'; diff --git a/models/content-types/milestone.ts b/models/content-types/milestone.ts deleted file mode 100644 index 18fab9db..00000000 --- a/models/content-types/milestone.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { type IContentItem, type Elements } from '@kontent-ai/delivery-sdk'; -/** - * Generated by '@kontent-ai/model-generator@5.10.0' - * - * Milestone - * Id: 71d17027-a0e8-5366-8373-cca093fb190d - * Codename: milestone - */ -export type Milestone = IContentItem<{ - /** - * Achievement (text) - * Required: true - * Id: 7b5abc87-10de-580b-b350-22e2c1e8c97e - * Codename: achievement - */ - achievement: Elements.TextElement; - - /** - * Subject (text) - * Required: true - * Id: d6428ff0-bc13-57df-b7be-70ebe5f79a90 - * Codename: subject - */ - subject: Elements.TextElement; -}>; diff --git a/models/project/assetFolders.ts b/models/project/assetFolders.ts index 8f13e1d8..1d38fa52 100644 --- a/models/project/assetFolders.ts +++ b/models/project/assetFolders.ts @@ -1,9 +1,9 @@ /** * Generated by '@kontent-ai/model-generator@5.10.0' * - * Project name: New sample migrations (TMP) (Kontent) - * Environment: App test - * Project Id: 89962bec-344a-01fd-58aa-40c92b21f579 + * Project name: Migration test + * Environment: Production + * Project Id: b5905129-8bdb-0115-aca0-d1700790cd2a */ export const assetFolders = { /** diff --git a/models/project/collections.ts b/models/project/collections.ts index 0136fd6c..7bfde700 100644 --- a/models/project/collections.ts +++ b/models/project/collections.ts @@ -1,9 +1,9 @@ /** * Generated by '@kontent-ai/model-generator@5.10.0' * - * Project name: New sample migrations (TMP) (Kontent) - * Environment: App test - * Project Id: 89962bec-344a-01fd-58aa-40c92b21f579 + * Project name: Migration test + * Environment: Production + * Project Id: b5905129-8bdb-0115-aca0-d1700790cd2a */ export const collections = { /** diff --git a/models/project/contentTypeSnippets.ts b/models/project/contentTypeSnippets.ts index 51be7366..8ebcf41f 100644 --- a/models/project/contentTypeSnippets.ts +++ b/models/project/contentTypeSnippets.ts @@ -1,9 +1,9 @@ /** * Generated by '@kontent-ai/model-generator@5.10.0' * - * Project name: New sample migrations (TMP) (Kontent) - * Environment: App test - * Project Id: 89962bec-344a-01fd-58aa-40c92b21f579 + * Project name: Migration test + * Environment: Production + * Project Id: b5905129-8bdb-0115-aca0-d1700790cd2a */ export const contentTypeSnippets = { /** diff --git a/models/project/contentTypes.ts b/models/project/contentTypes.ts index 0e883aaa..1d139802 100644 --- a/models/project/contentTypes.ts +++ b/models/project/contentTypes.ts @@ -1,9 +1,9 @@ /** * Generated by '@kontent-ai/model-generator@5.10.0' * - * Project name: New sample migrations (TMP) (Kontent) - * Environment: App test - * Project Id: 89962bec-344a-01fd-58aa-40c92b21f579 + * Project name: Migration test + * Environment: Production + * Project Id: b5905129-8bdb-0115-aca0-d1700790cd2a */ export const contentTypes = { /** @@ -11,7 +11,7 @@ export const contentTypes = { */ page: { codename: 'page', - id: '2d783b04-c9ac-42f5-bd34-959340e8e2ac', + id: '0cb81f69-3f4b-46a1-8ce2-0aada4cdc358', externalId: undefined, name: '💡 Page', elements: { @@ -20,7 +20,7 @@ export const contentTypes = { */ content: { codename: 'content', - id: 'dc3e831e-0157-41c8-b4a4-ff95b576a71e', + id: '27bc37be-796c-4219-a85d-cd61fc2e4f43', externalId: undefined, name: 'Content', required: false, @@ -59,7 +59,7 @@ export const contentTypes = { */ subpages: { codename: 'subpages', - id: 'ce96b539-ab2f-4ddf-8e94-e79acf2aec1a', + id: '7e159b22-7b95-4a9b-9e2a-a79d407edd76', externalId: undefined, name: 'Subpages', required: false, @@ -72,7 +72,7 @@ export const contentTypes = { */ title: { codename: 'title', - id: 'aa8bd39c-ad1d-4557-ada1-7422f07a4f47', + id: 'c2808c7e-9f57-4d0b-815c-f535752ed1cd', externalId: undefined, name: 'Title', required: false, @@ -98,7 +98,7 @@ export const contentTypes = { */ url: { codename: 'url', - id: '4e9acc07-f7e9-49ae-a992-88e791b07204', + id: '434f911b-c645-46e1-a633-0c8a3b1e9207', externalId: undefined, name: 'URL', required: false, @@ -113,7 +113,7 @@ export const contentTypes = { */ web_spotlight_root: { codename: 'web_spotlight_root', - id: '746e489b-4dbe-403a-a9db-0876fddfb68b', + id: 'eba96027-914d-48f7-a7f8-38502fa7e869', externalId: undefined, name: '💡 Web spotlight root', elements: { @@ -122,7 +122,7 @@ export const contentTypes = { */ content: { codename: 'content', - id: '376309cf-f65e-43ab-a104-118f5c143413', + id: '0273c87b-86ae-4c9b-8e49-d064f25d1417', externalId: undefined, name: 'Content', required: false, @@ -174,7 +174,7 @@ export const contentTypes = { */ subpages: { codename: 'subpages', - id: 'a96ae5ad-8971-47ca-9a06-330193ebb7ef', + id: '9e2d4dd9-7d9f-4365-99e0-6b1528f25215', externalId: undefined, name: 'Subpages', required: false, @@ -187,7 +187,7 @@ export const contentTypes = { */ title: { codename: 'title', - id: '60ff91ab-cd43-4003-a9ba-d50639b57d18', + id: 'fba9369c-61f3-4a91-a809-70129484c3ca', externalId: undefined, name: 'Title', required: false, @@ -687,43 +687,6 @@ export const contentTypes = { }, }, - /** - * Milestone - */ - milestone: { - codename: 'milestone', - id: '71d17027-a0e8-5366-8373-cca093fb190d', - externalId: 'milestone-7ca0204e-241d-4d77-90a6-e6110232ef14', - name: 'Milestone', - elements: { - /** - * Achievement (text) - */ - achievement: { - codename: 'achievement', - id: '7b5abc87-10de-580b-b350-22e2c1e8c97e', - externalId: 'achievement-b5030fb3-1a43-4203-99ab-2368b16f383a', - name: 'Achievement', - required: true, - type: 'text', - snippetCodename: undefined, - }, - - /** - * Subject (text) - */ - subject: { - codename: 'subject', - id: 'd6428ff0-bc13-57df-b7be-70ebe5f79a90', - externalId: 'subject-99a49380-1094-4baa-b359-6007624f9869', - name: 'Subject', - required: true, - type: 'text', - snippetCodename: undefined, - }, - }, - }, - /** * Person */ diff --git a/models/project/languages.ts b/models/project/languages.ts index 8c031bd9..97741e97 100644 --- a/models/project/languages.ts +++ b/models/project/languages.ts @@ -1,9 +1,9 @@ /** * Generated by '@kontent-ai/model-generator@5.10.0' * - * Project name: New sample migrations (TMP) (Kontent) - * Environment: App test - * Project Id: 89962bec-344a-01fd-58aa-40c92b21f579 + * Project name: Migration test + * Environment: Production + * Project Id: b5905129-8bdb-0115-aca0-d1700790cd2a */ export const languages = { /** diff --git a/models/project/roles.ts b/models/project/roles.ts index 3b20d318..d4c8e7c9 100644 --- a/models/project/roles.ts +++ b/models/project/roles.ts @@ -1,8 +1,8 @@ /** * Generated by '@kontent-ai/model-generator@5.10.0' * - * Project name: New sample migrations (TMP) (Kontent) - * Environment: App test - * Project Id: 89962bec-344a-01fd-58aa-40c92b21f579 + * Project name: Migration test + * Environment: Production + * Project Id: b5905129-8bdb-0115-aca0-d1700790cd2a */ export const roles = {} as const; diff --git a/models/project/taxonomies.ts b/models/project/taxonomies.ts index 69856cbf..f8d41244 100644 --- a/models/project/taxonomies.ts +++ b/models/project/taxonomies.ts @@ -1,9 +1,9 @@ /** * Generated by '@kontent-ai/model-generator@5.10.0' * - * Project name: New sample migrations (TMP) (Kontent) - * Environment: App test - * Project Id: 89962bec-344a-01fd-58aa-40c92b21f579 + * Project name: Migration test + * Environment: Production + * Project Id: b5905129-8bdb-0115-aca0-d1700790cd2a */ export const taxonomies = { /** diff --git a/models/project/webhooks.ts b/models/project/webhooks.ts index ddb7818d..903d8ad8 100644 --- a/models/project/webhooks.ts +++ b/models/project/webhooks.ts @@ -1,8 +1,8 @@ /** * Generated by '@kontent-ai/model-generator@5.10.0' * - * Project name: New sample migrations (TMP) (Kontent) - * Environment: App test - * Project Id: 89962bec-344a-01fd-58aa-40c92b21f579 + * Project name: Migration test + * Environment: Production + * Project Id: b5905129-8bdb-0115-aca0-d1700790cd2a */ export const webhooks = {} as const; diff --git a/models/project/workflows.ts b/models/project/workflows.ts index 01b51263..01536bad 100644 --- a/models/project/workflows.ts +++ b/models/project/workflows.ts @@ -1,9 +1,9 @@ /** * Generated by '@kontent-ai/model-generator@5.10.0' * - * Project name: New sample migrations (TMP) (Kontent) - * Environment: App test - * Project Id: 89962bec-344a-01fd-58aa-40c92b21f579 + * Project name: Migration test + * Environment: Production + * Project Id: b5905129-8bdb-0115-aca0-d1700790cd2a */ export const workflows = { /**