Skip to content

Commit

Permalink
refactor(Price add): On price add done, redirect to User Dashboard (#941
Browse files Browse the repository at this point in the history
)
  • Loading branch information
raphodn authored Oct 7, 2024
1 parent 63ff257 commit bb9d2ff
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 42 deletions.
2 changes: 1 addition & 1 deletion src/views/AddPriceMultiple.vue
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ export default {
})
},
done() {
this.$router.push({ path: '/prices', query: { multipleSuccess: 'true' } })
this.$router.push({ path: '/dashboard', query: { multipleSuccess: 'true' } })
}
}
}
Expand Down
23 changes: 4 additions & 19 deletions src/views/AddPriceSingle.vue
Original file line number Diff line number Diff line change
Expand Up @@ -182,24 +182,6 @@ export default {
this.addPriceSingleForm.price_per = this.categoryPricePerList[0].key // init to 'KILOGRAM' because it's the most common use-case
this.addPriceSingleForm.currency = this.appStore.getUserLastCurrencyUsed
},
showBarcodeScannerDialog() {
this.barcodeScannerDialog = true
},
showBarcodeManualInputDialog() {
this.barcodeManualInputDialog = true
},
setProductCode(code) {
this.addPriceSingleForm.product = null
this.addPriceSingleForm.product_code = code
api
.getProductByCode(code)
.then((data) => {
this.addPriceSingleForm.product = data.id ? data : {'code': code, 'price_count': 0}
})
.catch((error) => { // eslint-disable-line no-unused-vars
alert('Error: Open Prices server error')
})
},
createPrice() {
this.createPriceLoading = true
this.appStore.setLastCurrencyUsed(this.addPriceSingleForm.currency)
Expand Down Expand Up @@ -227,7 +209,7 @@ export default {
if (data['detail']) {
alert(`Error: with input ${data['detail'][0]['input']}`)
} else {
this.$router.push({ path: '/prices', query: { singleSuccess: 'true' } })
this.done()
}
this.createPriceLoading = false
})
Expand All @@ -237,6 +219,9 @@ export default {
this.createPriceLoading = false
})
},
done() {
this.$router.push({ path: '/dasboard', query: { singleSuccess: 'true' } })
}
}
}
</script>
22 changes: 0 additions & 22 deletions src/views/PriceList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,6 @@
>
{{ $t('Common.SignedIn') }}
</v-snackbar>
<v-snackbar
v-model="singleSuccessMessage"
color="success"
:timeout="2000"
>
{{ $t('Common.PriceCreated') }}
</v-snackbar>
<v-snackbar
v-model="multipleSuccessMessage"
color="success"
:timeout="2000"
>
{{ $t('Common.Thanks') }}
</v-snackbar>
</template>

<script>
Expand All @@ -56,8 +42,6 @@ export default {
loading: false,
// success messages
signinSuccessMessage: false,
singleSuccessMessage: false,
multipleSuccessMessage: false,
// scroll
handleDebouncedScroll: null,
}
Expand All @@ -71,12 +55,6 @@ export default {
if (this.$route.query.signinSuccess === 'true') {
this.signinSuccessMessage = true
}
if (this.$route.query.singleSuccess === 'true') {
this.singleSuccessMessage = true
}
if (this.$route.query.multipleSuccess === 'true') {
this.multipleSuccessMessage = true
}
},
unmounted() {
window.removeEventListener('scroll', this.handleDebouncedScroll)
Expand Down
26 changes: 26 additions & 0 deletions src/views/UserDashboard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,21 @@
</v-btn>
</v-col>
</v-row>

<v-snackbar
v-model="singleSuccessMessage"
color="success"
:timeout="2000"
>
{{ $t('Common.PriceCreated') }}
</v-snackbar>
<v-snackbar
v-model="multipleSuccessMessage"
color="success"
:timeout="2000"
>
{{ $t('Common.Thanks') }}
</v-snackbar>
</template>

<script>
Expand All @@ -44,11 +59,15 @@ export default {
},
data() {
return {
// data
user: null,
userPriceCount: null,
userProofCount: null,
userPriceList: [],
loading: false,
// success messages
singleSuccessMessage: false,
multipleSuccessMessage: false,
}
},
computed: {
Expand All @@ -68,6 +87,13 @@ export default {
this.getUser()
this.getUserProofCount()
this.getPrices()
// success messages
if (this.$route.query.singleSuccess === 'true') {
this.singleSuccessMessage = true
}
if (this.$route.query.multipleSuccess === 'true') {
this.multipleSuccessMessage = true
}
},
methods: {
getUser() {
Expand Down

0 comments on commit bb9d2ff

Please sign in to comment.