-
Notifications
You must be signed in to change notification settings - Fork 364
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: [M3-8682] - Add 'Credit Card Expired' banner (#11240)
* feat: [M3-8682] - Add 'Credit Card Expired' banner * Added changeset: Credit Card Expired banner * switched to useAccount() query
- Loading branch information
1 parent
ef21ecb
commit f5beea7
Showing
3 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) |
47 changes: 47 additions & 0 deletions
47
packages/manager/src/features/GlobalNotifications/CreditCardExpiredBanner.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters