Skip to content

Commit

Permalink
Tick off some more TODOs
Browse files Browse the repository at this point in the history
  • Loading branch information
rupertbates committed Jan 31, 2025
1 parent 0434c11 commit 9c134ee
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ export type WeeklyBillingPeriod =
| typeof Quarterly
| typeof Annual;

export const allBillingPeriods = [Monthly, Quarterly, Annual] as const;

const weeklyBillingPeriods = (): WeeklyBillingPeriod[] => {
return [Monthly, Quarterly, Annual];
};
Expand Down
5 changes: 4 additions & 1 deletion support-workers/src/typescript/model/address.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import { z } from 'zod';
import { isoCountries } from '../../../../support-frontend/assets/helpers/internationalisation/country';

export const countrySchema = z.enum(isoCountries);

export const addressSchema = z.object({
lineOne: z.string().nullable(),
lineTwo: z.string().nullable(),
city: z.string().nullable(),
state: z.string().nullable(),
postCode: z.string().nullable(),
country: z.string(), //TODO: build a schema for this
country: countrySchema,
});

type AddressLine = {
Expand Down
7 changes: 2 additions & 5 deletions support-workers/src/typescript/model/billingPeriod.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import { z } from 'zod';
import { allBillingPeriods } from '../../../../support-frontend/assets/helpers/productPrice/billingPeriods';

export const billingPeriodSchema = z.union([
z.literal('Monthly'), //TODO: share this with support-frontend
z.literal('Annual'),
z.literal('Quarterly'),
]);
export const billingPeriodSchema = z.enum(allBillingPeriods);
export type BillingPeriod = z.infer<typeof billingPeriodSchema>;
4 changes: 2 additions & 2 deletions support-workers/src/typescript/model/paymentFields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ export const stripePaymentTypeSchema = z.union([
const stripePaymentFieldsSchema = z.object({
paymentType: stripePaymentProviderSchema,
paymentMethod: z.string(),
stripePaymentType: stripePaymentTypeSchema, //TODO: this was optional in scala model
stripePublicKey: z.string(), //TODO: this has more validation in scala model
stripePaymentType: stripePaymentTypeSchema,
stripePublicKey: z.string(),
});
export type StripePaymentFields = z.infer<typeof stripePaymentFieldsSchema>;
const directDebitPaymentFieldsSchema = z.object({
Expand Down
7 changes: 4 additions & 3 deletions support-workers/src/typescript/model/paymentMethod.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { z } from 'zod';
import { countrySchema } from './address';
import { stripePaymentTypeSchema } from './paymentFields';
// Payment methods are the activated payment details which are passed into Zuora as opposed to
// payment fields which are the details entered by the user into the checkout
Expand Down Expand Up @@ -34,13 +35,13 @@ const stripePaymentMethodSchema = z.object({
TokenId: z.string(), // Stripe Card id
SecondTokenId: z.string(), // Stripe Customer Id
CreditCardNumber: z.string(),
CreditCardCountry: z.string().nullable(), //TODO: build a schema for this
CreditCardCountry: z.string().nullable(),
CreditCardExpirationMonth: z.number(),
CreditCardExpirationYear: z.number(),
CreditCardType: z.string().optional(),
PaymentGateway: stripePaymentGatewaySchema,
Type: z.literal('CreditCardReferenceTransaction'),
StripePaymentType: stripePaymentTypeSchema, //TODO: this is optional in the scala model
StripePaymentType: stripePaymentTypeSchema,
});
export type StripePaymentMethod = z.infer<typeof stripePaymentMethodSchema>;

Expand All @@ -50,7 +51,7 @@ const directDebitPaymentMethodSchema = z.object({
BankTransferAccountName: z.string(),
BankCode: z.string(),
BankTransferAccountNumber: z.string(),
Country: z.string(), //TODO: build a schema for this
Country: countrySchema,
City: z.string().nullable(),
PostalCode: z.string().nullable(),
State: z.string().nullable(),
Expand Down
2 changes: 1 addition & 1 deletion 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 or take it from the frontend
countryGroupId: z.string(),
})
.nullable(),
csrUsername: z.string().nullable(),
Expand Down

0 comments on commit 9c134ee

Please sign in to comment.