feat: add blocks for loyalty page
This commit is contained in:
47
types/components/loyalty/blocks.ts
Normal file
47
types/components/loyalty/blocks.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
import { Embeds } from "@/types/requests/embeds"
|
||||
import { PageLink } from "@/types/requests/myPages/navigation"
|
||||
import { Edges } from "@/types/requests/utils/edges"
|
||||
import { RTEDocument } from "@/types/rte/node"
|
||||
|
||||
export enum LoyaltyComponentEnum {
|
||||
loyalty_levels = "loyalty_levels",
|
||||
how_it_works = "how_it_works",
|
||||
overview_table = "overview_table",
|
||||
}
|
||||
|
||||
export type LoyaltyComponent = keyof typeof LoyaltyComponentEnum
|
||||
|
||||
export type DynamicContentBlock = {
|
||||
dynamic_content: {
|
||||
title: string
|
||||
preamble?: string
|
||||
component: LoyaltyComponent
|
||||
link: {
|
||||
text?: string
|
||||
page: Edges<PageLink>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export type DynamicContentProps = {
|
||||
dynamicContent: DynamicContentBlock["dynamic_content"]
|
||||
}
|
||||
|
||||
export type CardGrid = {
|
||||
card_grid: {
|
||||
heading: string
|
||||
preamble: string
|
||||
cards: {
|
||||
referenceConnection: Edges<PageLink>
|
||||
heading: string
|
||||
preamble: string
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export type Content = {
|
||||
content: {
|
||||
embedded_itemsConnection: Edges<Embeds>
|
||||
json: RTEDocument
|
||||
}
|
||||
}
|
||||
20
types/components/loyalty/sidebar.ts
Normal file
20
types/components/loyalty/sidebar.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { ContactFields } from "@/types/requests/contactConfig"
|
||||
import { Embeds } from "@/types/requests/embeds"
|
||||
import { JoinLoyaltyContactEnum } from "@/types/requests/loyaltyPage"
|
||||
import { Edges } from "@/types/requests/utils/edges"
|
||||
import { RTEDocument } from "@/types/rte/node"
|
||||
|
||||
export type SidebarContent = {
|
||||
content: {
|
||||
embedded_itemsConnection: Edges<Embeds>
|
||||
json: RTEDocument
|
||||
}
|
||||
}
|
||||
|
||||
export type Contact = {
|
||||
contact: ContactFields
|
||||
}
|
||||
|
||||
export type ContactProps = {
|
||||
contactBlock: JoinLoyaltyContactEnum[]
|
||||
}
|
||||
@@ -1,48 +1,73 @@
|
||||
import { AllRequestResponse } from "./utils/all"
|
||||
|
||||
export type ContactConfig = {
|
||||
items: [
|
||||
{
|
||||
email: {
|
||||
name: string
|
||||
address: string
|
||||
}
|
||||
email_loyalty: {
|
||||
name: string
|
||||
address: string
|
||||
}
|
||||
mailing_address: {
|
||||
zip: string
|
||||
street: string
|
||||
name: string
|
||||
city: string
|
||||
country: string
|
||||
}
|
||||
phone: {
|
||||
number: string
|
||||
naem: string
|
||||
}
|
||||
phone_loyalty: {
|
||||
number: string
|
||||
name: string
|
||||
}
|
||||
visiting_address: {
|
||||
zip: string
|
||||
country: string
|
||||
city: string
|
||||
street: string
|
||||
}
|
||||
},
|
||||
]
|
||||
email: {
|
||||
name?: string
|
||||
address?: string
|
||||
}
|
||||
email_loyalty: {
|
||||
name?: string
|
||||
address?: string
|
||||
}
|
||||
mailing_address: {
|
||||
zip?: string
|
||||
street?: string
|
||||
name?: string
|
||||
city?: string
|
||||
country?: string
|
||||
}
|
||||
phone: {
|
||||
number?: string
|
||||
name?: string
|
||||
}
|
||||
phone_loyalty: {
|
||||
number?: string
|
||||
name?: string
|
||||
}
|
||||
visiting_address: {
|
||||
zip?: string
|
||||
country?: string
|
||||
city?: string
|
||||
street?: string
|
||||
}
|
||||
}
|
||||
type FlattenKeys<T> = T extends object
|
||||
? {
|
||||
[K in keyof T]-?: `${K & string}.${FlattenKeys<T[K]>}`
|
||||
}[keyof T]
|
||||
: ""
|
||||
|
||||
export type ContactField = FlattenKeys<ContactConfig["items"][0]>
|
||||
export enum ContactFieldGroupsEnum {
|
||||
email = "email",
|
||||
email_loyalty = "email_loyalty",
|
||||
mailing_address = "mailing_address",
|
||||
phone = "phone",
|
||||
phone_loyalty = "phone_loyalty",
|
||||
visiting_address = "visiting_address",
|
||||
}
|
||||
|
||||
export type ContactFieldGroups = keyof typeof ContactFieldGroupsEnum
|
||||
|
||||
export type GetContactConfigData = {
|
||||
all_contact_config: AllRequestResponse<ContactConfig>
|
||||
}
|
||||
|
||||
// Utility types that extract the possible strings of ContactConfigField,
|
||||
// Which is all the dot notated values of ContactConfig (for example: 'email.name')
|
||||
type PathsToStringProps<T> = T extends string
|
||||
? []
|
||||
: {
|
||||
[K in Extract<keyof T, string>]: [K, ...PathsToStringProps<T[K]>]
|
||||
}[Extract<keyof T, string>]
|
||||
|
||||
type Join<T extends string[], D extends string> = T extends []
|
||||
? never
|
||||
: T extends [infer F]
|
||||
? F
|
||||
: T extends [infer F, ...infer R]
|
||||
? F extends string
|
||||
? `${F}${D}${Join<Extract<R, string[]>, D>}`
|
||||
: never
|
||||
: string
|
||||
|
||||
type ContactConfigField = Join<PathsToStringProps<ContactConfig>, ".">
|
||||
|
||||
export type ContactFields = {
|
||||
display_text?: string
|
||||
contact_field: ContactConfigField
|
||||
}
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import { PageLink } from "./myPages/navigation"
|
||||
import { Edges } from "./utils/edges"
|
||||
import type { AllRequestResponse } from "./utils/all"
|
||||
import type { Typename } from "./utils/typename"
|
||||
import type { RTEDocument } from "../rte/node"
|
||||
import type { Embeds } from "./embeds"
|
||||
import type { ContactField } from "./contactConfig"
|
||||
import { Contact, SidebarContent } from "../components/loyalty/sidebar"
|
||||
import {
|
||||
CardGrid,
|
||||
Content,
|
||||
DynamicContentBlock,
|
||||
} from "../components/loyalty/blocks"
|
||||
|
||||
export enum SidebarTypenameEnum {
|
||||
LoyaltyPageSidebarJoinLoyaltyContact = "LoyaltyPageSidebarJoinLoyaltyContact",
|
||||
@@ -13,24 +14,11 @@ export enum SidebarTypenameEnum {
|
||||
|
||||
export type SidebarTypename = keyof typeof SidebarTypenameEnum
|
||||
|
||||
type SidebarContent = {
|
||||
content: {
|
||||
embedded_itemsConnection: Edges<Embeds>
|
||||
json: RTEDocument
|
||||
}
|
||||
}
|
||||
|
||||
type Contact = {
|
||||
contact: {
|
||||
contact_fields: ContactField[]
|
||||
}
|
||||
}
|
||||
|
||||
enum JoinLoyaltyContactTypenameEnum {
|
||||
export enum JoinLoyaltyContactTypenameEnum {
|
||||
LoyaltyPageSidebarJoinLoyaltyContactBlockContactContact = "LoyaltyPageSidebarJoinLoyaltyContactBlockContactContact",
|
||||
}
|
||||
|
||||
type JoinLoyaltyContactEnum = Typename<
|
||||
export type JoinLoyaltyContactEnum = Typename<
|
||||
Contact,
|
||||
JoinLoyaltyContactTypenameEnum.LoyaltyPageSidebarJoinLoyaltyContactBlockContactContact
|
||||
>
|
||||
@@ -57,43 +45,10 @@ export enum LoyaltyBlocksTypenameEnum {
|
||||
LoyaltyPageBlocksContent = "LoyaltyPageBlocksContent",
|
||||
}
|
||||
|
||||
type CardGrid = {
|
||||
card_grid: {
|
||||
heading: string
|
||||
preamble: string
|
||||
cards: {
|
||||
referenceConnection: Edges<PageLink>
|
||||
heading: string
|
||||
preamble: string
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
type Content = {
|
||||
content: {
|
||||
embedded_itemsConnection: Edges<Embeds>
|
||||
json: RTEDocument
|
||||
}
|
||||
}
|
||||
|
||||
type LoyaltyComponent = "loyalty_levels" | "how_it_works" | "overview_table"
|
||||
|
||||
type DynamicContent = {
|
||||
dynamic_content: {
|
||||
title: string
|
||||
preamble?: string
|
||||
component: LoyaltyComponent
|
||||
link: {
|
||||
text?: string
|
||||
page: Edges<PageLink>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export type Blocks =
|
||||
| Typename<CardGrid, LoyaltyBlocksTypenameEnum.LoyaltyPageBlocksCardGrid>
|
||||
| Typename<
|
||||
DynamicContent,
|
||||
DynamicContentBlock,
|
||||
LoyaltyBlocksTypenameEnum.LoyaltyPageBlocksDynamicContent
|
||||
>
|
||||
| Typename<Content, LoyaltyBlocksTypenameEnum.LoyaltyPageBlocksContent>
|
||||
|
||||
Reference in New Issue
Block a user