-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #320 from jwplayer/feat/change-subscription
feat: initial inplayer subscription change implementation
- Loading branch information
Showing
28 changed files
with
660 additions
and
175 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
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
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
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,62 @@ | ||
@use 'src/styles/variables'; | ||
@use 'src/styles/theme'; | ||
|
||
.offerSwitchContainer { | ||
display: flex; | ||
align-items: center; | ||
width: 100%; | ||
height: auto; | ||
padding: 16px; | ||
gap: 25px; | ||
color: variables.$gray-white; | ||
background-color: theme.$panel-bg; | ||
border-radius: 4px; | ||
} | ||
|
||
.activeOfferSwitchContainer { | ||
color: variables.$gray-darker; | ||
background-color: variables.$white; | ||
} | ||
|
||
.offerSwitchInfoContainer { | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
align-items: flex-start; | ||
height: 100%; | ||
gap: 4px; | ||
font-weight: 600; | ||
} | ||
|
||
.offerSwitchPlanContainer { | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
align-items: flex-start; | ||
gap: 2px; | ||
} | ||
|
||
.currentPlanHeading { | ||
color: variables.$gray; | ||
font-size: 10px; | ||
} | ||
|
||
.activeCurrentPlanHeading { | ||
color: variables.$gray; | ||
} | ||
|
||
.nextBillingDate { | ||
color: variables.$gray; | ||
font-weight: 400; | ||
font-size: 12px; | ||
} | ||
|
||
.price { | ||
margin-left: auto; | ||
font-size: 20px; | ||
line-height: 28px; | ||
} | ||
|
||
.paymentFrequency { | ||
font-size: 12px; | ||
} |
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,55 @@ | ||
import classNames from 'classnames'; | ||
import { useTranslation } from 'react-i18next'; | ||
|
||
import styles from './OfferSwitch.module.scss'; | ||
|
||
import type { Offer } from '#types/checkout'; | ||
import Checkbox from '#components/Checkbox/Checkbox'; | ||
import { formatLocalizedDate, formatPrice } from '#src/utils/formatting'; | ||
|
||
type OfferSwitchProps = { | ||
isCurrentOffer: boolean; | ||
pendingDowngradeOfferId: string; | ||
offer: Offer; | ||
selected: boolean; | ||
onChange: (offerId: string) => void; | ||
expiresAt: number | undefined; | ||
}; | ||
|
||
const OfferSwitch = ({ isCurrentOffer, pendingDowngradeOfferId, offer, selected, onChange, expiresAt }: OfferSwitchProps) => { | ||
const { t, i18n } = useTranslation(['user', 'account']); | ||
const { customerPriceInclTax, customerCurrency, period } = offer; | ||
|
||
const isPendingDowngrade = pendingDowngradeOfferId === offer.offerId; | ||
|
||
return ( | ||
<div className={classNames(styles.offerSwitchContainer, { [styles.activeOfferSwitchContainer]: selected })}> | ||
<Checkbox disabled={isPendingDowngrade} name={offer.offerId} checked={selected} onChange={() => onChange(offer.offerId)} /> | ||
<div className={styles.offerSwitchInfoContainer}> | ||
{(isCurrentOffer || isPendingDowngrade) && ( | ||
<div className={classNames(styles.currentPlanHeading, { [styles.activeCurrentPlanHeading]: selected })}> | ||
{isCurrentOffer && t('user:payment.current_plan').toUpperCase()} | ||
{isPendingDowngrade && t('user:payment.pending_downgrade').toUpperCase()} | ||
</div> | ||
)} | ||
<div className={styles.offerSwitchPlanContainer}> | ||
<div>{t(`user:payment.${period === 'month' ? 'monthly' : 'annual'}_subscription`)}</div> | ||
{(isCurrentOffer || isPendingDowngrade) && expiresAt && ( | ||
<div className={styles.nextBillingDate}> | ||
{isCurrentOffer && | ||
!pendingDowngradeOfferId && | ||
t('user:payment.next_billing_date_on', { date: formatLocalizedDate(new Date(expiresAt * 1000), i18n.language) })} | ||
{isPendingDowngrade && t('user:payment.downgrade_on', { date: formatLocalizedDate(new Date(expiresAt * 1000), i18n.language) })} | ||
</div> | ||
)} | ||
</div> | ||
</div> | ||
<div className={styles.price}> | ||
{formatPrice(customerPriceInclTax, customerCurrency, undefined)} | ||
<span className={styles.paymentFrequency}>/{t(`account:periods.${period}_one`)}</span> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default OfferSwitch; |
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
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
Oops, something went wrong.