Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/components/PurchaseSummary/PurchaseSummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Card, Stack } from '@openedx/paragon';
import React from 'react';

import { usePurchaseSummaryPricing } from '@/components/app/data';
import ReceiptButton from '@/components/PurchaseSummary/ReceiptButton';
import { DataStoreKey } from '@/constants/checkout';
import { useCheckoutFormStore } from '@/hooks/index';

Expand Down Expand Up @@ -36,6 +37,9 @@ const PurchaseSummary: React.FC = () => {
<DueTodayRow amountDue={yearlySubscriptionCostForQuantity ?? 0} />
</Stack>
</Card.Section>
<Card.Footer>
<ReceiptButton />
</Card.Footer>
</Card>
);
};
Expand Down
20 changes: 20 additions & 0 deletions src/components/PurchaseSummary/ReceiptButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { AppContext } from '@edx/frontend-platform/react';
import { Button } from '@openedx/paragon';
import { useContext } from 'react';

import useBFFSuccess from '@/components/app/data/hooks/useBFFSuccess';

const ReceiptButton = () => {
const { authenticatedUser }: AppContextValue = useContext(AppContext);
const { data: contextData } = useBFFSuccess(authenticatedUser.userId);
const { checkoutIntent } = contextData ?? {};

// TODO: Stub button
return (
<Button className="w-100" variant="secondary" size="lg" disabled={!checkoutIntent?.stripeCustomerId}>
View Receipt
</Button>
);
};

export default ReceiptButton;
2 changes: 1 addition & 1 deletion src/components/app/routes/loaders/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
* Object indicating if a successful intent exists and if the intent is expired.
*/
const determineExistingCheckoutIntentState = (
checkoutIntent: ExtendedCheckoutContextCheckoutIntent | null,
checkoutIntent: CheckoutContextCheckoutIntent & CheckoutContextCheckoutIntentSuccess | null,
): DetermineExistingPaidCheckoutIntent => {
if (!checkoutIntent) {
return {
Expand All @@ -53,8 +53,8 @@
}

return {
existingSuccessfulCheckoutIntent: checkoutIntent.existingSuccessfulCheckoutIntent!,

Check failure on line 56 in src/components/app/routes/loaders/utils.ts

View workflow job for this annotation

GitHub Actions / lint

Property 'existingSuccessfulCheckoutIntent' does not exist on type 'CheckoutContextCheckoutIntent & CheckoutContextCheckoutIntentSuccess'.
expiredCheckoutIntent: checkoutIntent.expiredCheckoutIntent!,

Check failure on line 57 in src/components/app/routes/loaders/utils.ts

View workflow job for this annotation

GitHub Actions / lint

Property 'expiredCheckoutIntent' does not exist on type 'CheckoutContextCheckoutIntent & CheckoutContextCheckoutIntentSuccess'.
};
};

Expand Down
10 changes: 9 additions & 1 deletion src/types/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,15 @@ declare global {
adminPortalUrl: string;
}

interface ExtendedCheckoutContextCheckoutIntent extends CheckoutContextCheckoutIntent {
// TODO: will need to be modified further to include missing fields from the API response
interface CheckoutContextCheckoutIntentSuccess extends CheckoutContextCheckoutIntent {
stripeCustomerId: string;
enterpriseCustomerUuid: string | null;
}

interface ExtendedCheckoutContextCheckoutIntent extends
CheckoutContextCheckoutIntent,
CheckoutContextCheckoutIntentSuccess {
existingSuccessfulCheckoutIntent: boolean | null;
expiredCheckoutIntent: boolean | null;
}
Expand Down
Loading