Footer.vue
240 lines
| 1 | <template> |
| 2 | <div |
| 3 | v-if="props.ready && !props.loading && !props.loadingUpcoming" |
| 4 | class="am-elf__footer" |
| 5 | :class="{ 'am-congrats': isCongratzStep && props.secondButtonShow }" |
| 6 | > |
| 7 | <AmButton |
| 8 | v-if="props.secondButtonShow" |
| 9 | category="secondary" |
| 10 | :type="props.secondaryFooterButtonType" |
| 11 | size="medium" |
| 12 | @click="secondButtonClick" |
| 13 | > |
| 14 | {{ displayLabels(secondaryBtnLabel) }} |
| 15 | </AmButton> |
| 16 | <div |
| 17 | v-if="props.paymentGateway === 'payPal' && !isCongratzStep" |
| 18 | :id="`am-paypal-element-${shortcodeData.counter}`" |
| 19 | ></div> |
| 20 | <AmButton |
| 21 | v-if="props.paymentGateway !== 'payPal' || isCongratzStep" |
| 22 | :class="[{ mainBtnClass }, { 'square-continue': props.paymentGateway === 'square' }]" |
| 23 | :type="props.primaryFooterButtonType" |
| 24 | :category="isWaitingListStep() ? 'waiting' : 'primary'" |
| 25 | size="medium" |
| 26 | :disabled="footerBtnDisabled" |
| 27 | @click="footerButtonClick" |
| 28 | > |
| 29 | {{ displayLabels(primaryBtnLabel) }} |
| 30 | </AmButton> |
| 31 | </div> |
| 32 | <!-- Skeleton --> |
| 33 | <div v-else class="am-elf__footer-skeleton"> |
| 34 | <el-skeleton animated> |
| 35 | <template #template> |
| 36 | <el-skeleton-item /> |
| 37 | <el-skeleton-item /> |
| 38 | </template> |
| 39 | </el-skeleton> |
| 40 | </div> |
| 41 | <!-- /Skeleton --> |
| 42 | </template> |
| 43 | |
| 44 | <script setup> |
| 45 | import AmButton from '../../../_components/button/AmButton.vue' |
| 46 | |
| 47 | import { inject, ref, computed } from 'vue' |
| 48 | |
| 49 | let props = defineProps({ |
| 50 | ready: { |
| 51 | type: Boolean, |
| 52 | default: true, |
| 53 | }, |
| 54 | loading: { |
| 55 | type: Boolean, |
| 56 | default: false, |
| 57 | }, |
| 58 | loadingUpcoming: { |
| 59 | type: Boolean, |
| 60 | default: false, |
| 61 | }, |
| 62 | customizedLabels: { |
| 63 | type: Object, |
| 64 | default: () => { |
| 65 | return {} |
| 66 | }, |
| 67 | }, |
| 68 | primaryFooterButtonType: { |
| 69 | type: String, |
| 70 | default: 'filled', |
| 71 | }, |
| 72 | secondaryFooterButtonType: { |
| 73 | type: String, |
| 74 | default: 'plain', |
| 75 | }, |
| 76 | waitingFooterButtonType: { |
| 77 | type: String, |
| 78 | default: 'filled', |
| 79 | }, |
| 80 | paymentGateway: { |
| 81 | type: String, |
| 82 | default: '', |
| 83 | }, |
| 84 | secondButtonShow: { |
| 85 | type: Boolean, |
| 86 | default: true, |
| 87 | }, |
| 88 | isWaitingList: { |
| 89 | type: Boolean, |
| 90 | default: false, |
| 91 | }, |
| 92 | }) |
| 93 | |
| 94 | // * Step Functions |
| 95 | const { secondButtonClick } = inject('secondButton', { |
| 96 | secondButtonClick: () => {}, |
| 97 | }) |
| 98 | |
| 99 | const { footerButtonClick, footerBtnDisabled } = inject('changingStepsFunctions', { |
| 100 | footerButtonClick: () => {}, |
| 101 | footerBtnDisabled: ref(false), |
| 102 | }) |
| 103 | |
| 104 | const steps = inject('stepsArray') |
| 105 | const currentStep = inject('stepIndex') |
| 106 | |
| 107 | const isCongratzStep = computed(() => { |
| 108 | return currentStep.value === steps.value.length - 1 |
| 109 | }) |
| 110 | |
| 111 | let primaryBtnLabel = computed(() => { |
| 112 | if (isWaitingListStep()) { |
| 113 | // TODO - check from where to pass waitingList settings |
| 114 | return 'join_waiting_list' |
| 115 | } |
| 116 | |
| 117 | if ( |
| 118 | steps.value[currentStep.value].name === 'EventInfo' || |
| 119 | steps.value[currentStep.value].name === 'EventPayment' |
| 120 | ) { |
| 121 | return 'event_book_event' |
| 122 | } |
| 123 | |
| 124 | if (steps.value[currentStep.value].name === 'CongratulationsStep') return 'finish_appointment' |
| 125 | |
| 126 | return 'continue' |
| 127 | }) |
| 128 | |
| 129 | let secondaryBtnLabel = computed(() => { |
| 130 | if (steps.value[currentStep.value].name === 'CongratulationsStep') return 'congrats_panel' |
| 131 | |
| 132 | return 'event_close' |
| 133 | }) |
| 134 | |
| 135 | let mainBtnClass = computed(() => { |
| 136 | if (steps.value[currentStep.value].name === 'CongratulationsStep') |
| 137 | return 'am-elf__footer-btn__finish' |
| 138 | |
| 139 | return '' |
| 140 | }) |
| 141 | |
| 142 | const shortcodeData = inject( |
| 143 | 'shortcodeData', |
| 144 | ref({ |
| 145 | counter: 1000, |
| 146 | }), |
| 147 | ) |
| 148 | |
| 149 | // * Labels |
| 150 | const amLabels = inject('labels') |
| 151 | function displayLabels(label) { |
| 152 | return Object.keys(props.customizedLabels).length && props.customizedLabels[label] |
| 153 | ? props.customizedLabels[label] |
| 154 | : amLabels[label] |
| 155 | } |
| 156 | |
| 157 | function isWaitingListStep() { |
| 158 | return ( |
| 159 | (steps.value[currentStep.value].name === 'EventInfo' || |
| 160 | steps.value[currentStep.value].name === 'EventTickets') && |
| 161 | props.isWaitingList |
| 162 | ) |
| 163 | } |
| 164 | </script> |
| 165 | |
| 166 | <script> |
| 167 | export default { |
| 168 | name: 'EventListFooter', |
| 169 | } |
| 170 | </script> |
| 171 | |
| 172 | <style lang="scss"> |
| 173 | @mixin main-content-footer { |
| 174 | // am -- amelia |
| 175 | // elf -- event list form |
| 176 | // Amelia Form Steps |
| 177 | .am-elf { |
| 178 | &__footer { |
| 179 | display: flex; |
| 180 | justify-content: flex-end; |
| 181 | align-items: center; |
| 182 | gap: 28px; |
| 183 | |
| 184 | &.am-congrats { |
| 185 | justify-content: space-between; |
| 186 | } |
| 187 | |
| 188 | .am-button { |
| 189 | &--primary { |
| 190 | &.is-disabled { |
| 191 | cursor: not-allowed; |
| 192 | } |
| 193 | } |
| 194 | } |
| 195 | |
| 196 | &-btn { |
| 197 | &__finish { |
| 198 | margin-left: auto !important; |
| 199 | } |
| 200 | } |
| 201 | |
| 202 | &-skeleton { |
| 203 | display: flex; |
| 204 | align-items: center; |
| 205 | justify-content: flex-end; |
| 206 | width: 100%; |
| 207 | box-shadow: 0 -2px 3px rgba(26, 44, 55, 0.15); |
| 208 | |
| 209 | .el-skeleton { |
| 210 | display: flex; |
| 211 | align-items: center; |
| 212 | justify-content: flex-end; |
| 213 | width: 100%; |
| 214 | padding: 16px 24px; |
| 215 | |
| 216 | &__item { |
| 217 | width: 109px; |
| 218 | height: 40px; |
| 219 | |
| 220 | &:first-child { |
| 221 | margin-right: 12px; |
| 222 | } |
| 223 | } |
| 224 | } |
| 225 | } |
| 226 | } |
| 227 | } |
| 228 | } |
| 229 | |
| 230 | // Public |
| 231 | .amelia-v2-booking { |
| 232 | @include main-content-footer; |
| 233 | } |
| 234 | |
| 235 | // Admin |
| 236 | #amelia-app-backend-new { |
| 237 | @include main-content-footer; |
| 238 | } |
| 239 | </style> |
| 240 |