Skip to content

Commit

Permalink
get rid of milestones, refactor for facts
Browse files Browse the repository at this point in the history
  • Loading branch information
pokornyd committed Jul 27, 2023
1 parent 665e058 commit ecfa89c
Show file tree
Hide file tree
Showing 20 changed files with 59 additions and 126 deletions.
2 changes: 1 addition & 1 deletion .env.local.template
Original file line number Diff line number Diff line change
Expand Up @@ -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 <COLLECTION_CODENAME>:<DOMAIN_WITOUHOUT_PROTOCOL> 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 <COLLECTION_CODENAME>:<DOMAIN_WITOUHOUT_PROTOCOL> 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=
Expand Down
File renamed without changes.
8 changes: 4 additions & 4 deletions components/shared/visualContainer/Grid.tsx
Original file line number Diff line number Diff line change
@@ -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<Milestone>;
items: ReadonlyArray<Fact>;
}>;

export const GridComponent: FC<Props> = props => {
Expand All @@ -19,8 +19,8 @@ export const GridComponent: FC<Props> = props => {
className="p-4 flex flex-col text-center items-center"
key={link.system.id}
>
<div className="font-bold text-3xl">{link.elements.achievement.value}</div>
<div>{link.elements.subject.value}</div>
<div className="font-bold text-3xl">{link.elements.title.value}</div>
<div>{link.elements.message.value}</div>
</div>
))}
</div>
Expand Down
2 changes: 1 addition & 1 deletion components/shared/visualContainer/Stack.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down
11 changes: 4 additions & 7 deletions components/shared/visualContainer/VisualContainer.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -15,9 +15,9 @@ export const VisualContainer: FC<Props> = props => {
case visualRepresentation.grid:
return (
<>
{!props.item.elements.items.linkedItems.every(isMilestone) && <BuildError>Grid representation can only have Milestone items. Some items are of a wrong type.</BuildError>}
{!props.item.elements.items.linkedItems.every(isFact) && <BuildError>Grid representation can only have Fact items. Some items are of a wrong type.</BuildError>}
<GridComponent
items={props.item.elements.items.linkedItems.filter(isMilestone)}
items={props.item.elements.items.linkedItems.filter(isFact)}
/>
</>
);
Expand Down Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions lib/kontentClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export const getItemByCodename = <ItemType extends IContentItem>(codename: PerCo

const homepageTypeCodename = "web_spotlight_root" as const;

export const getHomepage = (usePreview: boolean) =>
export const getHomepage = async (usePreview: boolean) =>
deliveryClient
.items()
.type(homepageTypeCodename)
Expand All @@ -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<Product>()
.type(contentTypes.product.codename)
Expand Down
3 changes: 1 addition & 2 deletions models/content-types/Block_VisualContainer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]'
Expand All @@ -18,7 +17,7 @@ export type Block_VisualContainer = IContentItem<{
* Id: 081f63c6-9589-5f8d-a9de-bc3b1ceb24e7
* Codename: items
*/
items: Elements.LinkedItemsElement<Fact | Milestone | Block_HeroUnit>;
items: Elements.LinkedItemsElement<Fact | Block_HeroUnit>;

/**
* Subtitle (text)
Expand Down
10 changes: 5 additions & 5 deletions models/content-types/WSL_Page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ import { type WSL_WebSpotlightRoot } from './WSL_WebSpotlightRoot';
* Generated by '@kontent-ai/[email protected]'
*
* 💡 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<
Expand All @@ -28,23 +28,23 @@ 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<WSL_Page | WSL_WebSpotlightRoot>;

/**
* Title (text)
* Required: false
* Id: aa8bd39c-ad1d-4557-ada1-7422f07a4f47
* Id: c2808c7e-9f57-4d0b-815c-f535752ed1cd
* Codename: title
*/
title: Elements.TextElement;

/**
* URL (url_slug)
* Required: false
* Id: 4e9acc07-f7e9-49ae-a992-88e791b07204
* Id: 434f911b-c645-46e1-a633-0c8a3b1e9207
* Codename: url
*/
url: Elements.UrlSlugElement;
Expand Down
8 changes: 4 additions & 4 deletions models/content-types/WSL_WebSpotlightRoot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ import { type WSL_Page } from './WSL_Page';
* Generated by '@kontent-ai/[email protected]'
*
* 💡 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<
Expand All @@ -37,15 +37,15 @@ 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<WSL_Page | WSL_WebSpotlightRoot>;

/**
* Title (text)
* Required: false
* Id: 60ff91ab-cd43-4003-a9ba-d50639b57d18
* Id: fba9369c-61f3-4a91-a809-70129484c3ca
* Codename: title
*/
title: Elements.TextElement;
Expand Down
1 change: 0 additions & 1 deletion models/content-types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
25 changes: 0 additions & 25 deletions models/content-types/milestone.ts

This file was deleted.

6 changes: 3 additions & 3 deletions models/project/assetFolders.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/**
* Generated by '@kontent-ai/[email protected]'
*
* 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 = {
/**
Expand Down
6 changes: 3 additions & 3 deletions models/project/collections.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/**
* Generated by '@kontent-ai/[email protected]'
*
* 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 = {
/**
Expand Down
6 changes: 3 additions & 3 deletions models/project/contentTypeSnippets.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/**
* Generated by '@kontent-ai/[email protected]'
*
* 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 = {
/**
Expand Down
Loading

0 comments on commit ecfa89c

Please sign in to comment.