adjust form completion

pull/356/head^2
Pete Matsyburka 1 year ago committed by Oleksandr Turchyn
parent e72090c2e0
commit be4962a02a

@ -70,7 +70,7 @@
:class="{ 'md:px-4': isBreakpointMd }" :class="{ 'md:px-4': isBreakpointMd }"
> >
<form <form
v-if="!isCompleted" v-if="!isCompleted && !isInvite"
ref="form" ref="form"
:action="submitPath" :action="submitPath"
method="post" method="post"
@ -437,13 +437,13 @@
</div> </div>
</form> </form>
<InviteForm <InviteForm
v-else-if="!isInvited && inviteSubmitters.length" v-else-if="isInvite"
:submitters="inviteSubmitters" :submitters="inviteSubmitters"
:submitter-slug="submitterSlug" :submitter-slug="submitterSlug"
:authenticity-token="authenticityToken" :authenticity-token="authenticityToken"
:url="baseUrl + submitPath + '/invite'" :url="baseUrl + submitPath + '/invite'"
:style="{ maxWidth: isBreakpointMd ? '582px' : '' }" :style="{ maxWidth: isBreakpointMd ? '582px' : '' }"
@success="isInvited = true" @success="[isInvite = false, performComplete($event)]"
/> />
<FormCompleted <FormCompleted
v-else v-else
@ -755,7 +755,7 @@ export default {
data () { data () {
return { return {
isCompleted: false, isCompleted: false,
isInvited: false, isInvite: false,
isFormVisible: this.expand !== false, isFormVisible: this.expand !== false,
showFillAllRequiredFields: false, showFillAllRequiredFields: false,
currentStep: 0, currentStep: 0,
@ -1175,18 +1175,10 @@ export default {
if (emptyRequiredField === nextStep) { if (emptyRequiredField === nextStep) {
this.showFillAllRequiredFields = true this.showFillAllRequiredFields = true
} }
} else if (this.inviteSubmitters.length) {
this.isInvite = true
} else { } else {
this.isCompleted = true this.performComplete(response)
const respData = await response.text()
if (respData) {
this.onComplete(JSON.parse(respData))
}
if (this.completedRedirectUrl) {
window.location.href = this.completedRedirectUrl
}
} }
}).catch(error => { }).catch(error => {
console.error(error) console.error(error)
@ -1202,6 +1194,21 @@ export default {
}).finally(() => { }).finally(() => {
this.isSubmitting = false this.isSubmitting = false
}) })
},
async performComplete (resp) {
this.isCompleted = true
if (resp) {
const respData = await resp.text()
if (respData) {
this.onComplete(JSON.parse(respData))
}
}
if (this.completedRedirectUrl) {
window.location.href = this.completedRedirectUrl
}
} }
} }
} }

Loading…
Cancel
Save