| 1 |
<template> |
| 2 |
<div class="wpfnl-mm-setup-wizard-content"> |
| 3 |
<Welcome |
| 4 |
v-if="currentStep === 1" |
| 5 |
@next-step="handleNextStep" |
| 6 |
@prev-step="handlePrevStep" |
| 7 |
/> |
| 8 |
|
| 9 |
<Setup |
| 10 |
v-if="currentStep === 2" |
| 11 |
@next-step="handleNextStep" |
| 12 |
@prev-step="handlePrevStep" |
| 13 |
/> |
| 14 |
|
| 15 |
<StoreCheckout |
| 16 |
v-if="currentStep === 3" |
| 17 |
:builder="selectedBuilder" |
| 18 |
:prefetchedTemplates="prefetchedTemplates" |
| 19 |
:agreeToShare="agreeToShare" |
| 20 |
@prev-step="handlePrevStep" |
| 21 |
@store-checkout-phase="onStoreCheckoutPhase" |
| 22 |
/> |
| 23 |
|
| 24 |
|
| 25 |
<!-- Exit Confirmation Modal --> |
| 26 |
<div class="wpfnl-exit-modal-overlay" v-if="isExitModalVisible" @click.self="closeExitModal"> |
| 27 |
<div class="wpfnl-exit-modal"> |
| 28 |
<div class="wpfnl-exit-modal-header"> |
| 29 |
<svg width="48" height="48" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg">> |
| 30 |
<circle cx="24" cy="24" r="24" fill="#FEF3C7"/> |
| 31 |
<path d="M24 16V24M24 28H24.02M38 24C38 31.732 31.732 38 24 38C16.268 38 10 31.732 10 24C10 16.268 16.268 10 24 10C31.732 10 38 16.268 38 24Z" stroke="#F59E0B" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/> |
| 32 |
</svg> |
| 33 |
<h3 class="wpfnl-exit-modal-title">Exit Setup Wizard?</h3> |
| 34 |
<p class="wpfnl-exit-modal-description"> |
| 35 |
Are you sure you want to exit? Your progress won't be saved and you'll need to start over later. |
| 36 |
</p> |
| 37 |
</div> |
| 38 |
|
| 39 |
<div class="wpfnl-exit-modal-actions"> |
| 40 |
<button class="wpfnl-exit-modal-btn wpfnl-exit-modal-btn-secondary" @click="closeExitModal"> |
| 41 |
Continue Setup |
| 42 |
</button> |
| 43 |
<button class="wpfnl-exit-modal-btn wpfnl-exit-modal-btn-danger" @click="confirmExit"> |
| 44 |
Yes, Exit |
| 45 |
</button> |
| 46 |
</div> |
| 47 |
</div> |
| 48 |
</div> |
| 49 |
</div> |
| 50 |
</template> |
| 51 |
|
| 52 |
<script> |
| 53 |
import Setup from './Setup.vue' |
| 54 |
import Welcome from './Welcome.vue' |
| 55 |
import StoreCheckout from './StoreCheckout.vue' |
| 56 |
|
| 57 |
export default { |
| 58 |
name: 'Content', |
| 59 |
components: { |
| 60 |
Setup, |
| 61 |
Welcome, |
| 62 |
StoreCheckout, |
| 63 |
}, |
| 64 |
props: { |
| 65 |
currentStep: { |
| 66 |
type: Number, |
| 67 |
default: 1 |
| 68 |
}, |
| 69 |
selectedBuilder: { |
| 70 |
type: String, |
| 71 |
default: '' |
| 72 |
}, |
| 73 |
agreeToShare: { |
| 74 |
type: Boolean, |
| 75 |
default: false |
| 76 |
}, |
| 77 |
prefetchedTemplates: { |
| 78 |
type: Array, |
| 79 |
default: () => [] |
| 80 |
} |
| 81 |
}, |
| 82 |
data() { |
| 83 |
return { |
| 84 |
isExitModalVisible: false, |
| 85 |
storeCheckoutPhase: 'select', |
| 86 |
} |
| 87 |
}, |
| 88 |
methods: { |
| 89 |
handleNextStep(data) { |
| 90 |
this.$emit('next-step', data); |
| 91 |
}, |
| 92 |
handlePrevStep() { |
| 93 |
this.$emit('prev-step'); |
| 94 |
}, |
| 95 |
onStoreCheckoutPhase(phase) { |
| 96 |
this.storeCheckoutPhase = phase; |
| 97 |
this.$emit('store-checkout-phase', phase); |
| 98 |
}, |
| 99 |
showExitModal() { |
| 100 |
this.isExitModalVisible = true |
| 101 |
}, |
| 102 |
closeExitModal() { |
| 103 |
this.isExitModalVisible = false |
| 104 |
}, |
| 105 |
confirmExit() { |
| 106 |
this.trackAbandoned(() => { |
| 107 |
window.location.href = window.setup_wizard_obj.dashboard_url || '/wp-admin/'; |
| 108 |
}); |
| 109 |
}, |
| 110 |
trackAbandoned(callback) { |
| 111 |
const wizardObj = window.setup_wizard_obj || {}; |
| 112 |
const restApiUrl = wizardObj.rest_api_url || ''; |
| 113 |
const base = restApiUrl ? (restApiUrl.endsWith('/') ? restApiUrl : restApiUrl + '/') : null; |
| 114 |
|
| 115 |
if (!base) { |
| 116 |
callback(); |
| 117 |
return; |
| 118 |
} |
| 119 |
|
| 120 |
const url = base + 'wpfunnels/v1/setup-wizard/track-step'; |
| 121 |
const nonce = wizardObj.nonce || ''; |
| 122 |
|
| 123 |
// Use 'skipped' outcome when user reached step 3 template selection but didn't import |
| 124 |
// Use 'abandoned' (→ 'exited') for earlier exits |
| 125 |
const stepName = this.currentStep === 1 ? 'welcome' |
| 126 |
: this.currentStep === 2 ? 'required_installation' |
| 127 |
: 'store_checkout'; |
| 128 |
|
| 129 |
const eventType = (this.currentStep === 3 && this.storeCheckoutPhase === 'select') |
| 130 |
? 'skipped' |
| 131 |
: 'abandoned'; |
| 132 |
|
| 133 |
fetch(url, { |
| 134 |
method: 'POST', |
| 135 |
headers: { |
| 136 |
'Content-Type': 'application/json', |
| 137 |
'X-WP-Nonce': nonce, |
| 138 |
}, |
| 139 |
body: JSON.stringify({ |
| 140 |
event_type: eventType, |
| 141 |
step_name: stepName, |
| 142 |
step_index: this.currentStep, |
| 143 |
goal: 'improve-checkout', |
| 144 |
time_on_step: 0, |
| 145 |
total_steps: 3, |
| 146 |
}), |
| 147 |
}).catch(() => {}).finally(callback); |
| 148 |
}, |
| 149 |
} |
| 150 |
} |
| 151 |
</script> |
| 152 |
|
| 153 |
<style scoped> |
| 154 |
/* Exit Modal */ |
| 155 |
.wpfnl-exit-modal-overlay { |
| 156 |
position: fixed; |
| 157 |
top: 0; |
| 158 |
left: 0; |
| 159 |
right: 0; |
| 160 |
bottom: 0; |
| 161 |
background: rgba(0, 0, 0, 0.5); |
| 162 |
display: flex; |
| 163 |
align-items: center; |
| 164 |
justify-content: center; |
| 165 |
z-index: 10000; |
| 166 |
animation: fadeIn 0.2s ease; |
| 167 |
} |
| 168 |
|
| 169 |
@keyframes fadeIn { |
| 170 |
from { opacity: 0; } |
| 171 |
to { opacity: 1; } |
| 172 |
} |
| 173 |
|
| 174 |
.wpfnl-exit-modal { |
| 175 |
background: #FFFFFF; |
| 176 |
border-radius: 16px; |
| 177 |
padding: 32px; |
| 178 |
max-width: 440px; |
| 179 |
width: 90%; |
| 180 |
box-shadow: 0px 20px 40px rgba(0, 0, 0, 0.15); |
| 181 |
animation: slideUp 0.3s ease; |
| 182 |
} |
| 183 |
|
| 184 |
@keyframes slideUp { |
| 185 |
from { transform: translateY(20px); opacity: 0; } |
| 186 |
to { transform: translateY(0); opacity: 1; } |
| 187 |
} |
| 188 |
|
| 189 |
.wpfnl-exit-modal-header { |
| 190 |
display: flex; |
| 191 |
flex-direction: column; |
| 192 |
align-items: center; |
| 193 |
text-align: center; |
| 194 |
margin-bottom: 24px; |
| 195 |
} |
| 196 |
|
| 197 |
.wpfnl-exit-modal-header svg { |
| 198 |
margin-bottom: 16px; |
| 199 |
} |
| 200 |
|
| 201 |
.wpfnl-exit-modal-title { |
| 202 |
font-size: 20px; |
| 203 |
font-weight: 700; |
| 204 |
font-family: 'DM Sans', sans-serif; |
| 205 |
color: #363B4E; |
| 206 |
margin: 0 0 12px 0; |
| 207 |
letter-spacing: -0.5px; |
| 208 |
} |
| 209 |
|
| 210 |
.wpfnl-exit-modal-description { |
| 211 |
font-size: 14px; |
| 212 |
font-weight: 400; |
| 213 |
font-family: 'DM Sans', sans-serif; |
| 214 |
color: #6E7A85; |
| 215 |
line-height: 1.6; |
| 216 |
margin: 0; |
| 217 |
} |
| 218 |
|
| 219 |
.wpfnl-exit-modal-actions { |
| 220 |
display: flex; |
| 221 |
gap: 12px; |
| 222 |
justify-content: center; |
| 223 |
} |
| 224 |
|
| 225 |
.wpfnl-exit-modal-btn { |
| 226 |
padding: 12px 24px; |
| 227 |
border-radius: 8px; |
| 228 |
font-size: 14px; |
| 229 |
font-weight: 600; |
| 230 |
font-family: 'DM Sans', sans-serif; |
| 231 |
cursor: pointer; |
| 232 |
transition: all 0.3s ease; |
| 233 |
border: none; |
| 234 |
min-width: 140px; |
| 235 |
} |
| 236 |
|
| 237 |
.wpfnl-exit-modal-btn-secondary { |
| 238 |
background: #F6F5FA; |
| 239 |
color: #363B4E; |
| 240 |
border: 1px solid #ECEBF0; |
| 241 |
} |
| 242 |
|
| 243 |
.wpfnl-exit-modal-btn-secondary:hover { |
| 244 |
background: #ECEBF0; |
| 245 |
border-color: #6E42D3; |
| 246 |
} |
| 247 |
|
| 248 |
.wpfnl-exit-modal-btn-danger { |
| 249 |
background: #EF4444; |
| 250 |
color: #FFFFFF; |
| 251 |
} |
| 252 |
|
| 253 |
.wpfnl-exit-modal-btn-danger:hover { |
| 254 |
background: #DC2626; |
| 255 |
} |
| 256 |
</style> |
| 257 |
|