feat(SW-391): Changes after PR

This commit is contained in:
Erik Tiekstra
2024-10-11 11:04:47 +02:00
committed by Pontus Dreij
parent 9ba5795718
commit ceb612a2f4
9 changed files with 57 additions and 23 deletions

View File

@@ -6,8 +6,7 @@ import LoyaltyCard from "@/components/TempDesignSystem/LoyaltyCard"
import TeaserCard from "@/components/TempDesignSystem/TeaserCard"
import type { CardsGridProps } from "@/types/components/blocks/cardsGrid"
import { CardsGridEnum } from "@/types/enums/cardsGrid"
import { CardsGridLayoutEnum } from "@/types/trpc/routers/contentstack/blocks"
import { CardsGridEnum, CardsGridLayoutEnum } from "@/types/enums/cardsGrid"
export default function CardsGrid({
cards_grid,

View File

@@ -83,7 +83,7 @@ function SidePeek({
aria-label={intl.formatMessage({ id: "Close" })}
className={styles.closeButton}
intent="text"
onClick={onClose}
onPress={onClose}
>
<CloseLargeIcon color="burgundy" />
</Button>

View File

@@ -11,19 +11,19 @@ import SidePeek from "../../SidePeek"
import styles from "./sidepeek.module.css"
import { TeaserCardSidepeekProps } from "@/types/components/teaserCard"
import type { TeaserCardSidepeekProps } from "@/types/components/teaserCard"
export default function TeaserCardSidepeek({
button,
data,
sidePeekContent,
}: TeaserCardSidepeekProps) {
const [sidePeekIsOpen, setSidePeekIsOpen] = useState(false)
const { heading, content, primary_button, secondary_button } = data
const { heading, content, primary_button, secondary_button } = sidePeekContent
return (
<>
<Button
onClick={() => setSidePeekIsOpen(true)}
onPress={() => setSidePeekIsOpen(true)}
theme="base"
variant="icon"
intent="text"

View File

@@ -46,7 +46,10 @@ export default function TeaserCard({
{description}
</Body>
{sidePeekButton && sidePeekContent ? (
<TeaserCardSidepeek button={sidePeekButton} data={sidePeekContent} />
<TeaserCardSidepeek
button={sidePeekButton}
sidePeekContent={sidePeekContent}
/>
) : (
<div className={styles.ctaContainer}>
{primaryButton && (

View File

@@ -30,6 +30,45 @@ fragment TeaserCardBlockRef on TeaserCard {
}
}
}
sidepeek_content {
content {
embedded_itemsConnection {
edges {
node {
__typename
...AccountPageRef
...ContentPageRef
...LoyaltyPageRef
...HotelPageRef
}
}
}
}
primary_button {
linkConnection {
edges {
node {
__typename
...ContentPageRef
...LoyaltyPageRef
...HotelPageRef
}
}
}
}
secondary_button {
linkConnection {
edges {
node {
__typename
...ContentPageRef
...LoyaltyPageRef
...HotelPageRef
}
}
}
}
}
system {
...System
}

View File

@@ -10,8 +10,7 @@ import { imageSchema } from "./image"
import { imageContainerSchema } from "./imageContainer"
import { BlocksEnums } from "@/types/enums/blocks"
import { CardsGridEnum } from "@/types/enums/cardsGrid"
import { CardsGridLayoutEnum } from "@/types/trpc/routers/contentstack/blocks"
import { CardsGridEnum, CardsGridLayoutEnum } from "@/types/enums/cardsGrid"
export const cardBlockSchema = z.object({
__typename: z.literal(CardsGridEnum.cards.Card),
@@ -93,18 +92,12 @@ export const teaserCardBlockSchema = z.object({
secondary_button: buttonSchema,
})
.optional(),
// sidepeek_content: z
// .object({
// heading: z.string(),
// })
// .optional(),
system: systemSchema,
})
export function transformTeaserCardBlock(
card: typeof teaserCardBlockSchema._type
) {
console.log({ has_sidepeek_button: card.sidepeek_content })
return {
__typename: card.__typename,
body_text: card.body_text,

View File

@@ -24,5 +24,5 @@ export interface TeaserCardProps
export interface TeaserCardSidepeekProps {
button: SidePeekButton
data: NonNullable<TeaserCard["sidepeek_content"]>
sidePeekContent: NonNullable<TeaserCard["sidepeek_content"]>
}

View File

@@ -5,3 +5,9 @@ export namespace CardsGridEnum {
TeaserCard = "TeaserCard",
}
}
export enum CardsGridLayoutEnum {
TWO_COLUMNS = "twoColumnGrid",
THREE_COLUMNS = "threeColumnGrid",
TWO_PLUS_ONE = "twoPlusOne", // Not sure if this is used?
}

View File

@@ -11,12 +11,6 @@ import { tableSchema } from "@/server/routers/contentstack/schemas/blocks/table"
import { textColsSchema } from "@/server/routers/contentstack/schemas/blocks/textCols"
import { uspGridSchema } from "@/server/routers/contentstack/schemas/blocks/uspGrid"
export enum CardsGridLayoutEnum {
TWO_COLUMNS = "twoColumnGrid",
THREE_COLUMNS = "threeColumnGrid",
TWO_PLUS_ONE = "twoPlusOne",
}
export interface TeaserCard extends z.output<typeof teaserCardBlockSchema> {}
export interface CardsGrid extends z.output<typeof cardsGridSchema> {}
export interface Content extends z.output<typeof contentSchema> {}