diff --git a/static/gsApp/types/index.tsx b/static/gsApp/types/index.tsx index 71e6e03fd1ed..4f09e37c4090 100644 --- a/static/gsApp/types/index.tsx +++ b/static/gsApp/types/index.tsx @@ -542,7 +542,7 @@ export type Invoice = InvoiceBase & { type BaseInvoiceItem = { amount: number; - data: {period?: any; plan?: any; quantity?: any}; + data: {period?: any; plan?: any; quantity?: any} | null; description: string; type: InvoiceItemType; }; diff --git a/static/gsApp/views/amCheckout/components/checkoutSuccess.spec.tsx b/static/gsApp/views/amCheckout/components/checkoutSuccess.spec.tsx index 96177c93ef6b..0bdfedfe3419 100644 --- a/static/gsApp/views/amCheckout/components/checkoutSuccess.spec.tsx +++ b/static/gsApp/views/amCheckout/components/checkoutSuccess.spec.tsx @@ -68,6 +68,31 @@ describe('CheckoutSuccess', () => { expect(screen.queryByTestId('receipt')).not.toBeInTheDocument(); }); + it('renders scheduled changes when a reserved item has null data', async () => { + render( + + ); + + expect(await screen.findByText('Consider it done (soon)')).toBeInTheDocument(); + expect(screen.getByRole('heading', {name: /^From /})).toBeInTheDocument(); + }); + it('renders ondemand items in receipt', async () => { const invoiceWithOnDemand = InvoiceFixture({ items: [ diff --git a/static/gsApp/views/amCheckout/components/checkoutSuccess.tsx b/static/gsApp/views/amCheckout/components/checkoutSuccess.tsx index 115791789abf..9b87a6f67be2 100644 --- a/static/gsApp/views/amCheckout/components/checkoutSuccess.tsx +++ b/static/gsApp/views/amCheckout/components/checkoutSuccess.tsx @@ -155,7 +155,7 @@ function ScheduledChanges({ if (!defined(category)) { return null; } - const quantity = item.data.quantity ?? 0; + const quantity = item.data?.quantity ?? 0; const reserved = isByteCategory(category) ? quantity / GIGABYTE : quantity; if (reserved <= 0) { return null; @@ -352,7 +352,7 @@ function Receipt({ if (!defined(category)) { return null; } - const quantity = item.data.quantity ?? 0; + const quantity = item.data?.quantity ?? 0; const reserved = isByteCategory(category) ? quantity / GIGABYTE : quantity; diff --git a/static/gsApp/views/amCheckout/index.tsx b/static/gsApp/views/amCheckout/index.tsx index 1ddb1e7efca2..f551aeb204e8 100644 --- a/static/gsApp/views/amCheckout/index.tsx +++ b/static/gsApp/views/amCheckout/index.tsx @@ -626,7 +626,7 @@ function AMCheckout(props: Props) { if (isSubmitted) { const purchasedPlanItem = invoice?.items.find(item => item.type === 'subscription'); const basePlan = purchasedPlanItem - ? getPlan(purchasedPlanItem.data.plan) + ? getPlan(purchasedPlanItem.data?.plan) : getPlan(formData.plan); return (