Skip to content

Commit

Permalink
fix: hide start watching button in avod platform
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristiaanScheermeijer committed Feb 7, 2024
1 parent ca3d38e commit 86b461f
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import { modalURLFromLocation } from '@jwp/ott-ui-react/src/utils/location';
import useBreakpoint, { Breakpoint } from '@jwp/ott-ui-react/src/hooks/useBreakpoint';
import useEntitlement from '@jwp/ott-hooks-react/src/useEntitlement';
import Play from '@jwp/ott-theme/assets/icons/play.svg?react';
import { useConfigStore } from '@jwp/ott-common/src/stores/ConfigStore';
import { ACCESS_MODEL } from '@jwp/ott-common/src/constants';

import Button from '../../components/Button/Button';
import Icon from '../../components/Icon/Icon';
Expand All @@ -29,6 +31,7 @@ const StartWatchingButton: React.VFC<Props> = ({ item, playUrl, disabled = false
const breakpoint = useBreakpoint();

// account
const accessModel = useConfigStore((state) => state.accessModel);
const user = useAccountStore((state) => state.user);
const isLoggedIn = !!user;

Expand Down Expand Up @@ -70,6 +73,11 @@ const StartWatchingButton: React.VFC<Props> = ({ item, playUrl, disabled = false
return () => setRequestedMediaOffers(null);
}, [mediaOffers, setRequestedMediaOffers]);

// the user can't purchase access in an AVOD platform due to missing configuration, so we hide the button
if (accessModel === ACCESS_MODEL.AVOD && !isEntitled) {
return null;
}

return (
<Button
color="primary"
Expand Down

0 comments on commit 86b461f

Please sign in to comment.