Skip to content

Commit

Permalink
feat: [M3-8682] - Add 'Credit Card Expired' banner (#11240)
Browse files Browse the repository at this point in the history
* feat: [M3-8682] - Add 'Credit Card Expired' banner

* Added changeset: Credit Card Expired banner

* switched to useAccount() query
  • Loading branch information
harsh-akamai authored Nov 18, 2024
1 parent ef21ecb commit f5beea7
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/manager/.changeset/pr-11240-added-1731323233092.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Added
---

Credit Card Expired banner ([#11240](https://github.com/linode/manager/pull/11240))
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { Typography } from '@mui/material';
import * as React from 'react';
import { useHistory } from 'react-router-dom';

import { Button } from 'src/components/Button/Button';
import { DismissibleBanner } from 'src/components/DismissibleBanner/DismissibleBanner';
import { useAccount } from 'src/queries/account/account';
import { isCreditCardExpired } from 'src/utilities/creditCard';

export const CreditCardExpiredBanner = () => {
const history = useHistory();

const { data: account } = useAccount();

if (!account) {
return null;
}

const isExpired = Boolean(
account?.credit_card?.expiry &&
isCreditCardExpired(account?.credit_card.expiry)
);

if (!isExpired) {
return;
}

return (
<DismissibleBanner
actionButton={
<Button
buttonType="primary"
onClick={() => history.push('/account/billing')}
>
Update Card
</Button>
}
important
preferenceKey={'credit-card-expired'}
variant="error"
>
<Typography variant="body1">
Your credit card has expired! Please update your payment details.
</Typography>
</DismissibleBanner>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { SessionExpirationDialog } from '../Account/SwitchAccounts/SessionExpira
import { APIMaintenanceBanner } from './APIMaintenanceBanner';
import { ComplianceBanner } from './ComplianceBanner';
import { ComplianceUpdateModal } from './ComplianceUpdateModal';
import { CreditCardExpiredBanner } from './CreditCardExpiredBanner';
import { EmailBounceNotificationSection } from './EmailBounce';
import { RegionStatusBanner } from './RegionStatusBanner';
import { TaxCollectionBanner } from './TaxCollectionBanner';
Expand Down Expand Up @@ -53,6 +54,7 @@ export const GlobalNotifications = () => {

return (
<>
<CreditCardExpiredBanner />
<DesignUpdateBanner />
<EmailBounceNotificationSection />
<RegionStatusBanner />
Expand Down

0 comments on commit f5beea7

Please sign in to comment.