-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: initial inplayer subscription change implementation
- Loading branch information
1 parent
035a0da
commit b335b69
Showing
18 changed files
with
455 additions
and
340 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,52 @@ | ||
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'; | ||
import { useAccountStore } from '#src/stores/AccountStore'; | ||
|
||
interface OfferSwitchProps { | ||
isCurrentOffer: boolean; | ||
offer: Offer; | ||
selected: { | ||
value: boolean; | ||
set: React.Dispatch<React.SetStateAction<string | null>>; | ||
}; | ||
} | ||
|
||
const OfferSwitch = ({ isCurrentOffer, offer, selected }: OfferSwitchProps) => { | ||
const { t, i18n } = useTranslation('user'); | ||
const { customerPriceInclTax, customerCurrency, period } = offer; | ||
const expiresAt = useAccountStore((state) => state.subscription?.expiresAt); | ||
|
||
return ( | ||
<div className={classNames(styles.offerSwitchContainer, { [styles.activeOfferSwitchContainer]: selected.value })}> | ||
<Checkbox name={offer.offerId} checked={selected.value} onChange={() => selected.set(offer.offerId)} /> | ||
<div className={styles.offerSwitchInfoContainer}> | ||
{isCurrentOffer && ( | ||
<div className={classNames(styles.currentPlanHeading, { [styles.activeCurrentPlanHeading]: selected.value })}>{t('payment.current_plan')}</div> | ||
)} | ||
<div className={styles.offerSwitchPlanContainer}> | ||
<div>{t(`payment.${period === 'month' ? 'monthly' : 'annual'}_subscription`)}</div> | ||
{isCurrentOffer && expiresAt && ( | ||
<div className={styles.nextBillingDate}> | ||
{t('payment.next_billing_date_on', { date: formatLocalizedDate(new Date(expiresAt * 1000), i18n.language) })} | ||
</div> | ||
)} | ||
</div> | ||
</div> | ||
<div className={styles.price}> | ||
{formatPrice(customerPriceInclTax, customerCurrency, undefined)} | ||
{ | ||
//todo: i18n | ||
} | ||
<span className={styles.paymentFrequency}>/{period === 'month' ? 'month' : 'year'}</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.