diff --git a/src/components/CheckoutForm/CheckoutForm.tsx b/src/components/CheckoutForm/CheckoutForm.tsx index 06309e371..42c5f5df5 100644 --- a/src/components/CheckoutForm/CheckoutForm.tsx +++ b/src/components/CheckoutForm/CheckoutForm.tsx @@ -134,7 +134,7 @@ const CheckoutForm: React.FC = ({ {t('checkout.coupon_discount')}
- {!!offer.period && ( + {!!offer.period && offerType === 'svod' && ( {t('checkout.discount_period', { count: order.discount.periods, diff --git a/src/containers/AccountModal/forms/ChooseOffer.tsx b/src/containers/AccountModal/forms/ChooseOffer.tsx index e73187bb7..10407ec4b 100644 --- a/src/containers/AccountModal/forms/ChooseOffer.tsx +++ b/src/containers/AccountModal/forms/ChooseOffer.tsx @@ -8,6 +8,7 @@ import useOffers from '../../../hooks/useOffers'; import { addQueryParam, removeQueryParam } from '#src/utils/history'; import { useCheckoutStore } from '#src/stores/CheckoutStore'; +import { useConfigStore } from '#src/stores/ConfigStore'; import LoadingOverlay from '#src/components/LoadingOverlay/LoadingOverlay'; import ChooseOfferForm from '#src/components/ChooseOfferForm/ChooseOfferForm'; import useForm, { UseFormOnSubmitHandler } from '#src/hooks/useForm'; @@ -17,6 +18,7 @@ const ChooseOffer = () => { const history = useHistory(); const { t } = useTranslation('account'); const { setOffer } = useCheckoutStore(({ setOffer }) => ({ setOffer }), shallow); + const { accessModel } = useConfigStore(({ accessModel }) => ({ accessModel }), shallow); const { isLoading, offerType, setOfferType, offers, offersDict, defaultOfferId, hasTVODOffers, hasPremierOffer } = useOffers(); const validationSchema: SchemaOf = object().shape({ @@ -67,7 +69,7 @@ const ChooseOffer = () => { submitting={submitting} offers={offers} offerType={offerType} - setOfferType={hasTVODOffers && !hasPremierOffer ? setOfferType : undefined} + setOfferType={accessModel === 'SVOD' && hasTVODOffers && !hasPremierOffer ? setOfferType : undefined} /> ); }; diff --git a/src/hooks/useOffers.ts b/src/hooks/useOffers.ts index cb3090a58..d8284213c 100644 --- a/src/hooks/useOffers.ts +++ b/src/hooks/useOffers.ts @@ -10,11 +10,18 @@ import type { OfferType } from '#types/account'; import { isSVODOffer } from '#src/utils/subscription'; const useOffers = () => { - const { cleengSandbox, json } = useConfigStore(({ config }) => config, shallow); + const { config, accessModel } = useConfigStore( + ({ config, accessModel }) => ({ + config, + accessModel, + }), + shallow, + ); + const { cleengSandbox, json } = config; const { requestedMediaOffers } = useCheckoutStore(({ requestedMediaOffers }) => ({ requestedMediaOffers }), shallow); const hasPremierOffer = (requestedMediaOffers || []).some((offer) => offer.premier); const tvodOfferIds = (requestedMediaOffers || []).map(({ offerId }) => offerId); - const [offerType, setOfferType] = useState('svod'); + const [offerType, setOfferType] = useState(accessModel === 'SVOD' ? 'svod' : 'tvod'); const monthlyOfferId = json?.cleengMonthlyOffer ? (json.cleengMonthlyOffer as string) : ''; const yearlyOfferId = json?.cleengYearlyOffer ? (json.cleengYearlyOffer as string) : '';