| 1 |
<template> |
| 2 |
<div class="wpfnl-mm-setup-wizard"> |
| 3 |
<Sidebar :currentStep="currentStep" :selectedGoal="selectedGoal" @show-exit-modal="handleShowExitModal" /> |
| 4 |
<Content |
| 5 |
ref="contentComponent" |
| 6 |
:currentStep="currentStep" |
| 7 |
:selectedGoal="selectedGoal" |
| 8 |
:selectedBuilder="selectedBuilder" |
| 9 |
:selectedTemplate="selectedTemplate" |
| 10 |
:funnelId="createdFunnelId" |
| 11 |
:firstStepLink="firstStepLink" |
| 12 |
:selectedProductId="selectedProductId" |
| 13 |
:selectedProduct="selectedProduct" |
| 14 |
:agreeToShare="agreeToShare" |
| 15 |
:mainProduct="mainProduct" |
| 16 |
:orderBump="orderBump" |
| 17 |
:upsellProduct="upsellProduct" |
| 18 |
@next-step="handleNextStep" |
| 19 |
@prev-step="handlePrevStep" |
| 20 |
/> |
| 21 |
</div> |
| 22 |
</template> |
| 23 |
|
| 24 |
<script> |
| 25 |
import Content from './Content/Content.vue' |
| 26 |
import Sidebar from './Sidebar/Sidebar.vue' |
| 27 |
import apiFetch from '@wordpress/api-fetch' |
| 28 |
|
| 29 |
const nonce = window.setup_wizard_obj.nonce |
| 30 |
apiFetch.use(apiFetch.createNonceMiddleware(nonce)) |
| 31 |
|
| 32 |
export default { |
| 33 |
name: 'Wizard', |
| 34 |
components: { |
| 35 |
Content, |
| 36 |
Sidebar, |
| 37 |
}, |
| 38 |
data() { |
| 39 |
return { |
| 40 |
currentStep: 1, |
| 41 |
selectedGoal: '', |
| 42 |
agreeToShare: false, |
| 43 |
selectedBuilder: '', |
| 44 |
wooInstalled: false, |
| 45 |
wooActivated: false, |
| 46 |
selectedTemplate: null, |
| 47 |
createdFunnelId: null, |
| 48 |
firstStepLink: '', |
| 49 |
selectedProductId: null, |
| 50 |
selectedProduct: null, |
| 51 |
mainProduct: null, |
| 52 |
orderBump: null, |
| 53 |
upsellProduct: null, |
| 54 |
} |
| 55 |
}, |
| 56 |
|
| 57 |
mounted() { |
| 58 |
// Initialization logic if needed |
| 59 |
}, |
| 60 |
|
| 61 |
methods: { |
| 62 |
handleNextStep(data) { |
| 63 |
|
| 64 |
// Store data from current step |
| 65 |
if (data && data.goal) { |
| 66 |
this.selectedGoal = data.goal; |
| 67 |
this.agreeToShare = data.agreeToShare; |
| 68 |
} |
| 69 |
if (data && data.builder) { |
| 70 |
this.selectedBuilder = data.builder; |
| 71 |
this.wooInstalled = data.wooInstalled; |
| 72 |
this.wooActivated = data.wooActivated; |
| 73 |
} |
| 74 |
if (data && data.template) { |
| 75 |
this.selectedTemplate = data.template; |
| 76 |
} |
| 77 |
if (data && data.productId) { |
| 78 |
this.selectedProductId = data.productId; |
| 79 |
this.selectedProduct = data.product || null; |
| 80 |
} |
| 81 |
if (data && data.funnelId) { |
| 82 |
this.createdFunnelId = data.funnelId; |
| 83 |
} |
| 84 |
if (data && data.firstStepLink) { |
| 85 |
this.firstStepLink = data.firstStepLink; |
| 86 |
} |
| 87 |
if (data && data.mainProduct !== undefined) { |
| 88 |
this.mainProduct = data.mainProduct; |
| 89 |
} |
| 90 |
if (data && data.orderBump !== undefined) { |
| 91 |
this.orderBump = data.orderBump; |
| 92 |
} |
| 93 |
if (data && data.upsell !== undefined) { |
| 94 |
this.upsellProduct = data.upsell; |
| 95 |
} |
| 96 |
|
| 97 |
// Move to next step |
| 98 |
const maxSteps = this.getMaxSteps(); |
| 99 |
if (this.currentStep < maxSteps) { |
| 100 |
this.currentStep++; |
| 101 |
} |
| 102 |
}, |
| 103 |
handlePrevStep() { |
| 104 |
// Move to previous step |
| 105 |
if (this.currentStep > 1) { |
| 106 |
this.currentStep--; |
| 107 |
} |
| 108 |
}, |
| 109 |
handleShowExitModal() { |
| 110 |
// Call the showExitModal method in Content component |
| 111 |
if (this.$refs.contentComponent) { |
| 112 |
this.$refs.contentComponent.showExitModal(); |
| 113 |
} |
| 114 |
}, |
| 115 |
getMaxSteps() { |
| 116 |
// Dynamic step calculation based on goal |
| 117 |
if (this.selectedGoal === 'order-value') { |
| 118 |
return 6; // Welcome, Setup, ChooseGoal, ChooseTemplate, BuildFunnel, Complete |
| 119 |
} |
| 120 |
if (this.selectedGoal === 'improve-checkout') { |
| 121 |
return 6; // Welcome, Setup, ChooseGoal, ChooseTemplate, GenerateFunnel, Complete |
| 122 |
} |
| 123 |
if (this.selectedGoal === 'sales') { |
| 124 |
return 7; // Welcome, Setup, ChooseGoal, ProductSync, ChooseTemplate, GenerateFunnel, Complete |
| 125 |
} |
| 126 |
// Default before goal selection |
| 127 |
return 5; // Welcome, Setup, ChooseGoal, ChooseTemplate, Complete (initial display) |
| 128 |
} |
| 129 |
}, |
| 130 |
} |
| 131 |
</script> |