|
| 1 | +<template> |
| 2 | + <div class="wmde-banner-wrapper" :class="contentState"> |
| 3 | + <MainBanner |
| 4 | + @form-interaction="$emit( 'bannerContentChanged' )" |
| 5 | + v-if="contentState === ContentStates.Main" |
| 6 | + :bannerState="bannerState" |
| 7 | + > |
| 8 | + <template #close-button> |
| 9 | + <ButtonClose @close="onCloseMain"/> |
| 10 | + </template> |
| 11 | + |
| 12 | + <template #banner-title> |
| 13 | + <BannerTitle/> |
| 14 | + </template> |
| 15 | + |
| 16 | + <template #banner-text> |
| 17 | + <BannerText/> |
| 18 | + </template> |
| 19 | + |
| 20 | + <template #banner-slides="{ play }: any"> |
| 21 | + <KeenSlider :with-navigation="true" :play="play" :interval="10000" :delay="2000" :navigation-color="'#ffffff'"> |
| 22 | + |
| 23 | + <template #slides="{ currentSlide }: any"> |
| 24 | + <BannerSlides :currentSlide="currentSlide"/> |
| 25 | + </template> |
| 26 | + |
| 27 | + </KeenSlider> |
| 28 | + </template> |
| 29 | + |
| 30 | + <template #progress> |
| 31 | + <ProgressBar amount-to-show-on-right="TARGET"/> |
| 32 | + </template> |
| 33 | + |
| 34 | + <template #donation-form="{ formInteraction }: any"> |
| 35 | + <MultiStepDonation |
| 36 | + :step-controllers="stepControllers" |
| 37 | + @form-interaction="formInteraction" |
| 38 | + :submit-callback="onSubmit" |
| 39 | + > |
| 40 | + |
| 41 | + <template #[FormStepNames.MainDonationFormStep]="{ pageIndex, submit, isCurrent, previous }: any"> |
| 42 | + <MainDonationForm :page-index="pageIndex" @submit="submit" :is-current="isCurrent" @previous="previous"> |
| 43 | + <template #label-payment-ppl> |
| 44 | + <span class="wmde-banner-select-group-label with-logos paypal"> |
| 45 | + <PayPalIcon/><span>Paypal</span> |
| 46 | + </span> |
| 47 | + </template> |
| 48 | + |
| 49 | + <template #label-payment-mcp> |
| 50 | + <span class="wmde-banner-select-group-label with-logos credit-cards"> |
| 51 | + <MasterCardIcon/><span>Kreditkarte</span> |
| 52 | + </span> |
| 53 | + </template> |
| 54 | + |
| 55 | + <template #label-payment-ueb> |
| 56 | + <span class="wmde-banner-select-group-label with-logos bank-transfer"> |
| 57 | + <BankTransferIcon/><span>Überweisung</span> |
| 58 | + </span> |
| 59 | + </template> |
| 60 | + |
| 61 | + <template #label-payment-bez> |
| 62 | + <span class="wmde-banner-select-group-label with-logos bank-transfer"> |
| 63 | + <DirectDebitIcon/><span>Lastschrift</span> |
| 64 | + </span> |
| 65 | + </template> |
| 66 | + </MainDonationForm> |
| 67 | + </template> |
| 68 | + |
| 69 | + <template #[FormStepNames.UpgradeToYearlyFormStep]="{ pageIndex, submit, isCurrent, previous }: any"> |
| 70 | + <UpgradeToYearlyButtonForm |
| 71 | + :page-index="pageIndex" |
| 72 | + @submit="submit" |
| 73 | + :is-current="isCurrent" |
| 74 | + @previous="previous" |
| 75 | + /> |
| 76 | + </template> |
| 77 | + |
| 78 | + </MultiStepDonation> |
| 79 | + </template> |
| 80 | + |
| 81 | + <template #footer> |
| 82 | + <FooterAlreadyDonated |
| 83 | + @showFundsModal="onModalOpened" |
| 84 | + @clickedAlreadyDonatedLink="onClose( 'MainBanner', CloseChoices.AlreadyDonated )" |
| 85 | + /> |
| 86 | + </template> |
| 87 | + |
| 88 | + </MainBanner> |
| 89 | + |
| 90 | + <FundsModal |
| 91 | + :content="useOfFundsContent" |
| 92 | + :visible="isFundsModalVisible" |
| 93 | + @hide="onHideFundsModal" |
| 94 | + @call-to-action="onHideFundsModal" |
| 95 | + /> |
| 96 | + </div> |
| 97 | +</template> |
| 98 | + |
| 99 | +<script setup lang="ts"> |
| 100 | +import { BannerStates } from '@src/components/BannerConductor/StateMachine/BannerStates'; |
| 101 | +import { inject, ref, watch } from 'vue'; |
| 102 | +import { UseOfFundsContent as useOfFundsContentInterface } from '@src/domain/UseOfFunds/UseOfFundsContent'; |
| 103 | +import MainBanner from './MainBanner.vue'; |
| 104 | +import FundsModal from '@src/components/UseOfFunds/UseOfFundsModal.vue'; |
| 105 | +import BannerText from '../content/BannerText.vue'; |
| 106 | +import BannerSlides from '../content/BannerSlides.vue'; |
| 107 | +import MultiStepDonation from '@src/components/DonationForm/MultiStepDonation.vue'; |
| 108 | +import MainDonationForm from '@src/components/DonationForm/Forms/MainDonationForm.vue'; |
| 109 | +import UpgradeToYearlyButtonForm from '@src/components/DonationForm/Forms/UpgradeToYearlyButtonForm.vue'; |
| 110 | +import KeenSlider from '@src/components/Slider/KeenSlider.vue'; |
| 111 | +import { useFormModel } from '@src/components/composables/useFormModel'; |
| 112 | +import { |
| 113 | + createSubmittableMainDonationForm |
| 114 | +} from '@src/components/DonationForm/StepControllers/SubmittableMainDonationForm'; |
| 115 | +import { |
| 116 | + createSubmittableUpgradeToYearly |
| 117 | +} from '@src/components/DonationForm/StepControllers/SubmittableUpgradeToYearly'; |
| 118 | +import { CloseChoices } from '@src/domain/CloseChoices'; |
| 119 | +import { CloseEvent } from '@src/tracking/events/CloseEvent'; |
| 120 | +import { TrackingFeatureName } from '@src/tracking/TrackingEvent'; |
| 121 | +import ButtonClose from '@src/components/ButtonClose/ButtonClose.vue'; |
| 122 | +import FooterAlreadyDonated from '@src/components/Footer/FooterAlreadyDonated.vue'; |
| 123 | +import { LocalCloseTracker } from '@src/utils/LocalCloseTracker'; |
| 124 | +import { BannerSubmitOnReturnEvent } from '@src/tracking/events/BannerSubmitOnReturnEvent'; |
| 125 | +import { Tracker } from '@src/tracking/Tracker'; |
| 126 | +import { useBannerHider } from '@src/components/composables/useBannerHider'; |
| 127 | +import BannerTitle from '../content/BannerTitle.vue'; |
| 128 | +import BankTransferIcon from '@src/components/PaymentLogos/BankTransferIcon.vue'; |
| 129 | +import PayPalIcon from '@src/components/PaymentLogos/PayPalIcon.vue'; |
| 130 | +import DirectDebitIcon from '@src/components/PaymentLogos/DirectDebitIcon.vue'; |
| 131 | +import MasterCardIcon from '@src/components/PaymentLogos/MasterCardIcon.vue'; |
| 132 | +import ProgressBar from '@src/components/ProgressBar/ProgressBar.vue'; |
| 133 | +
|
| 134 | +enum ContentStates { |
| 135 | + Main = 'wmde-banner-wrapper--main', |
| 136 | +} |
| 137 | +
|
| 138 | +enum FormStepNames { |
| 139 | + MainDonationFormStep = 'MainDonationForm', |
| 140 | + UpgradeToYearlyFormStep = 'UpgradeToYearlyForm' |
| 141 | +} |
| 142 | +
|
| 143 | +interface Props { |
| 144 | + bannerState: BannerStates; |
| 145 | + useOfFundsContent: useOfFundsContentInterface; |
| 146 | + localCloseTracker: LocalCloseTracker; |
| 147 | +} |
| 148 | +
|
| 149 | +const props = defineProps<Props>(); |
| 150 | +const emit = defineEmits( [ 'bannerClosed', 'bannerContentChanged', 'modalOpened', 'modalClosed' ] ); |
| 151 | +useBannerHider( 800, emit ); |
| 152 | +
|
| 153 | +const tracker = inject<Tracker>( 'tracker' ); |
| 154 | +
|
| 155 | +const isFundsModalVisible = ref<boolean>( false ); |
| 156 | +const contentState = ref<ContentStates>( ContentStates.Main ); |
| 157 | +const formModel = useFormModel(); |
| 158 | +const stepControllers = [ |
| 159 | + createSubmittableMainDonationForm( formModel, FormStepNames.UpgradeToYearlyFormStep ), |
| 160 | + createSubmittableUpgradeToYearly( formModel, FormStepNames.MainDonationFormStep, FormStepNames.MainDonationFormStep ) |
| 161 | +]; |
| 162 | +
|
| 163 | +watch( contentState, async () => { |
| 164 | + emit( 'bannerContentChanged' ); |
| 165 | +} ); |
| 166 | +
|
| 167 | +const onSubmit = (): void => { |
| 168 | + // special callback function: asking for previous close choices |
| 169 | + const closeChoice = props.localCloseTracker.getItem(); |
| 170 | + if ( closeChoice !== '' ) { |
| 171 | + tracker.trackEvent( new BannerSubmitOnReturnEvent( closeChoice ) ); |
| 172 | + } |
| 173 | +}; |
| 174 | +
|
| 175 | +function onCloseMain(): void { |
| 176 | + onClose( 'MainBanner', CloseChoices.Close ); |
| 177 | +} |
| 178 | +
|
| 179 | +function onClose( feature: TrackingFeatureName, userChoice: CloseChoices ): void { |
| 180 | + emit( 'bannerClosed', new CloseEvent( feature, userChoice ) ); |
| 181 | + props.localCloseTracker.setItem( feature, userChoice ); |
| 182 | +} |
| 183 | +
|
| 184 | +function onHideFundsModal(): void { |
| 185 | + isFundsModalVisible.value = false; |
| 186 | + emit( 'modalClosed' ); |
| 187 | +} |
| 188 | +
|
| 189 | +function onModalOpened(): void { |
| 190 | + isFundsModalVisible.value = true; |
| 191 | + emit( 'modalOpened' ); |
| 192 | +} |
| 193 | +
|
| 194 | +</script> |
0 commit comments