Skip to content

Commit

Permalink
Tick off some TODOs
Browse files Browse the repository at this point in the history
  • Loading branch information
rupertbates committed Jan 31, 2025
1 parent 966ed89 commit 0434c11
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 8 deletions.
36 changes: 30 additions & 6 deletions support-workers/src/typescript/model/productType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,30 @@ import { z } from 'zod';
import { billingPeriodSchema } from './billingPeriod';
import { currencySchema } from './currency';

export const fulfilmentOptionsSchema = z.enum([
'HomeDelivery',
'NationalDelivery',
'Collection',
'Domestic',
'RestOfWorld',
'NoFulfilmentOptions',
]);

const productOptionsSchema = z.enum([
'NoProductOptions',
'Saturday',
'SaturdayPlus',
'Sunday',
'SundayPlus',
'Weekend',
'WeekendPlus',
'Sixday',
'SixdayPlus',
'Everyday',
'EverydayPlus',
'NewspaperArchive',
]);

export const contributionProductSchema = z.object({
amount: z.number(),
currency: currencySchema,
Expand All @@ -17,27 +41,27 @@ export const supporterPlusProductSchema = z.object({
export const tierThreeProductSchema = z.object({
currency: currencySchema,
billingPeriod: billingPeriodSchema,
fulfilmentOptions: z.string(), //TODO type this properly
productOptions: z.string(), //TODO type this properly
fulfilmentOptions: fulfilmentOptionsSchema,
productOptions: productOptionsSchema,
productType: z.literal('TierThree'),
});
export const paperProductSchema = z.object({
currency: currencySchema,
billingPeriod: billingPeriodSchema,
fulfilmentOptions: z.string(), //TODO type this properly
productOptions: z.string(), //TODO type this properly
fulfilmentOptions: fulfilmentOptionsSchema,
productOptions: productOptionsSchema,
productType: z.literal('Paper'),
});
export const guardianWeeklyProductSchema = z.object({
currency: currencySchema,
billingPeriod: billingPeriodSchema,
fulfilmentOptions: z.string(), //TODO type this properly
fulfilmentOptions: fulfilmentOptionsSchema,
productType: z.literal('GuardianWeekly'),
});
export const digitalPackProductSchema = z.object({
currency: currencySchema,
billingPeriod: billingPeriodSchema,
readerType: z.string(), //TODO type this properly
readerType: z.string(), //TODO this can be removed now that digital subscription gifts are no longer supported but we'll need to remove it from the scala code as well
productType: z.literal('DigitalPack'),
});
export const guardianAdLiteProductSchema = z.object({
Expand Down
4 changes: 2 additions & 2 deletions support-workers/src/typescript/model/stateSchemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ const baseStateSchema = z.object({
appliedPromotion: z
.object({
promoCode: z.string(),
countryGroupId: z.string(), //TODO: build a schema for this
countryGroupId: z.string(), //TODO: build a schema for this or take it from the frontend
})
.nullable(),
csrUsername: z.string().nullable(),
Expand All @@ -100,7 +100,7 @@ const baseStateSchema = z.object({

export const createPaymentMethodStateSchema = baseStateSchema.merge(
z.object({
paymentFields: paymentFieldsSchema, //TODO scala model is an either with redemption data
paymentFields: paymentFieldsSchema,
ipAddress: z.string(),
userAgent: z.string(),
}),
Expand Down

0 comments on commit 0434c11

Please sign in to comment.