Skip to content

Commit

Permalink
fix(payment): show offer modal after registration in authvod platform
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristiaanScheermeijer committed Jun 1, 2022
1 parent 23c67c2 commit 0071c63
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/containers/AccountModal/forms/PersonalDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { useConfigStore } from '../../../stores/ConfigStore';

import type { CaptureCustomAnswer, CleengCaptureQuestionField, PersonalDetailsFormData } from '#types/account';
import { getCaptureStatus, updateCaptureAnswers } from '#src/stores/AccountController';
import useOffers from '#src/hooks/useOffers';

const yupConditional = (required: boolean, message: string) => {
return required ? string().required(message) : mixed().notRequired();
Expand All @@ -22,6 +23,7 @@ const PersonalDetails = () => {
const { t } = useTranslation('account');
const accessModel = useConfigStore((s) => s.accessModel);
const { data, isLoading } = useQuery('captureStatus', () => getCaptureStatus());
const { hasTVODOffers } = useOffers();
const [questionValues, setQuestionValues] = useState<Record<string, string>>({});
const [questionErrors, setQuestionErrors] = useState<Record<string, string>>({});

Expand All @@ -32,8 +34,10 @@ const PersonalDetails = () => {
);

const nextStep = useCallback(() => {
history.replace(addQueryParam(history, 'u', accessModel === 'SVOD' ? 'choose-offer' : 'welcome'));
}, [history, accessModel]);
const hasOffers = accessModel === 'SVOD' || (accessModel === 'AUTHVOD' && hasTVODOffers);

history.replace(addQueryParam(history, 'u', hasOffers ? 'choose-offer' : 'welcome'));
}, [history, accessModel, hasTVODOffers]);

useEffect(() => {
if (data && (!data.isCaptureEnabled || !data.shouldCaptureBeDisplayed)) nextStep();
Expand Down

0 comments on commit 0071c63

Please sign in to comment.