|
@@ -52,7 +52,7 @@
|
|
</div>
|
|
</div>
|
|
<div class="ptc-button-group">
|
|
<div class="ptc-button-group">
|
|
<div class="ptc-inner">
|
|
<div class="ptc-inner">
|
|
- <button class="ptc-button ptc-button--loading" @click="onSubmit">
|
|
|
|
|
|
+ <button class="ptc-button" :loading="loading" @click="onSubmit">
|
|
SUBMIT
|
|
SUBMIT
|
|
</button>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
@@ -74,6 +74,7 @@ onMounted(async () => {
|
|
})
|
|
})
|
|
|
|
|
|
const submitted = ref(false)
|
|
const submitted = ref(false)
|
|
|
|
+const loading = ref(false)
|
|
|
|
|
|
function onSubmit() {
|
|
function onSubmit() {
|
|
submit().then(next)
|
|
submit().then(next)
|
|
@@ -81,7 +82,10 @@ function onSubmit() {
|
|
|
|
|
|
async function submit() {
|
|
async function submit() {
|
|
if (submitted.value) return
|
|
if (submitted.value) return
|
|
- if (!state.phoneNumber) return Toast('Please enter your phone number')
|
|
|
|
|
|
+ if (!state.phoneNumber) {
|
|
|
|
+ Toast('Please enter your phone number')
|
|
|
|
+ return Promise.reject()
|
|
|
|
+ }
|
|
const commonParams = {
|
|
const commonParams = {
|
|
igeektek_id: state.shop.igeektek_id,
|
|
igeektek_id: state.shop.igeektek_id,
|
|
pickup_time: state.date + ' ' + state.period,
|
|
pickup_time: state.date + ' ' + state.period,
|
|
@@ -91,6 +95,8 @@ async function submit() {
|
|
const request = state.repairId
|
|
const request = state.repairId
|
|
? api.rescheduleRepair({ id: state.repairId, ...commonParams })
|
|
? api.rescheduleRepair({ id: state.repairId, ...commonParams })
|
|
: api.applyRepair({ right_id: state.rightId, ...commonParams })
|
|
: api.applyRepair({ right_id: state.rightId, ...commonParams })
|
|
|
|
+ loading.value = true
|
|
|
|
+ request.finally(() => (loading.value = false))
|
|
const { results } = await request
|
|
const { results } = await request
|
|
state.repairId = results
|
|
state.repairId = results
|
|
submitted.value = true
|
|
submitted.value = true
|