Skip to content

Commit 6a89b7e

Browse files
authored
Add config listings, listing types, and listing pricing types (#66)
1 parent f2a1d54 commit 6a89b7e

2 files changed

Lines changed: 48 additions & 1 deletion

File tree

src/index.test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,14 @@ const fullChartRendererConfig: Required<ChartRendererConfigOptions> = {
5252
],
5353
priceFormatter: price => '$' + price,
5454
showSectionPricingOverlay: true,
55+
listings: [
56+
{ id: 'vip', objects: ['A-1', 'A-2'], selectAsGroup: true, listingType: 'premium' },
57+
{ id: 'hot', objects: ['B-1'] }
58+
],
59+
listingTypes: {
60+
premium: { label: 'Premium', icon: 'star' },
61+
hot: { label: 'Hot', icon: 'fire' }
62+
},
5563
selectedObjects: [
5664
'A-1',
5765
{
@@ -612,6 +620,10 @@ const objectPricing: Required<Pricing> = {
612620
{ objects: ['A-1', 'A-2'], price: 10, fee: 1 },
613621
{ objects: ['A-1', 'A-2'], ticketTypes: [
614622
{ ticketType: 'Adult', price: 10, fee: 1 }
623+
]},
624+
{ listing: 'vip', price: 100, originalPrice: 120, fee: 2 },
625+
{ listing: 'hot', ticketTypes: [
626+
{ ticketType: 'adult', price: 30, fee: 1 }
615627
]
616628
}],
617629
showSectionPricingOverlay: true

src/index.ts

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,14 @@ export interface ChartRendererConfigOptions extends DeprecatedConfigProperties,
9696
* Seats supports two types of pricing: simple pricing and multi-level pricing. {@link https://docs.seats.io/docs/renderer/config-pricing See documentation}
9797
*/
9898
pricing?: Pricing
99+
/**
100+
* Groups objects into listings that can be configured with a type and selected together.
101+
*/
102+
listings?: ConfigListing[]
103+
/**
104+
* Defines the available listing types, each with an optional icon and label.
105+
*/
106+
listingTypes?: ListingTypes
99107
/**
100108
* Formats the price into a custom defined string when showing it to and en user. {@link https://docs.seats.io/docs/renderer/config-priceformatter See documentation}
101109
*/
@@ -1277,6 +1285,18 @@ export type MultiLevelPricingForObjects = {
12771285
ticketTypes: TicketType[]
12781286
}
12791287

1288+
export type SimplePricingForListing = {
1289+
listing: string
1290+
originalPrice?: number
1291+
price: number
1292+
fee?: number
1293+
}
1294+
1295+
export type MultiLevelPricingForListing = {
1296+
listing: string
1297+
ticketTypes: TicketType[]
1298+
}
1299+
12801300
export type ChannelPricing = (SimpleChannelPricing | MultiLevelChannelPricing)
12811301

12821302
export type SimpleChannelPricing = {
@@ -1306,6 +1326,7 @@ export type TicketType = {
13061326

13071327
export type PricingForCategory = (SimplePricing | MultiLevelPricing)
13081328
export type PricingForObjects = (SimplePricingForObjects | MultiLevelPricingForObjects)
1329+
export type PricingForListing = (SimplePricingForListing | MultiLevelPricingForListing)
13091330

13101331
// Legacy types for backwards compatibility
13111332
type LegacySimplePricing = Omit<SimplePricing, 'fee'>
@@ -1319,7 +1340,7 @@ export type LegacyPricing = (LegacyPricingForCategory | LegacyPricingForObjects)
13191340
export type Pricing = {
13201341
allFeesIncluded?: boolean
13211342
priceFormatter?: (price: number) => string
1322-
prices: (PricingForCategory | PricingForObjects)[],
1343+
prices: (PricingForCategory | PricingForObjects | PricingForListing)[],
13231344
showSectionPricingOverlay?: boolean
13241345
} | LegacyPricing
13251346

@@ -1639,6 +1660,20 @@ export type ListingBySection = {
16391660
quantity: number
16401661
}
16411662

1663+
export interface ConfigListing {
1664+
id: string
1665+
objects?: string[]
1666+
listingType?: string
1667+
selectAsGroup?: boolean
1668+
}
1669+
1670+
export interface ListingType {
1671+
icon?: string
1672+
label?: string
1673+
}
1674+
1675+
export type ListingTypes = Dict<ListingType>
1676+
16421677
// Runtime type helper functions
16431678
export function isBooth(object: SelectableObject): object is Booth {
16441679
return object.objectType === 'Booth'

0 commit comments

Comments
 (0)