toast added

Signed-off-by: Benny Samir Hierl <bennysamir@posteo.de>
This commit is contained in:
Benny Samir Hierl 2022-02-13 19:31:45 +01:00
parent b4b09e079b
commit 7916d435a0
7 changed files with 45 additions and 3 deletions

15
package-lock.json generated
View file

@ -21,6 +21,7 @@
"vue": "^3.2.31", "vue": "^3.2.31",
"vue-i18n": "^9.2.0-beta.30", "vue-i18n": "^9.2.0-beta.30",
"vue-router": "^4.0.12", "vue-router": "^4.0.12",
"vue-toastification": "^2.0.0-rc.5",
"yup": "^0.32.11" "yup": "^0.32.11"
}, },
"devDependencies": { "devDependencies": {
@ -6993,6 +6994,14 @@
"vue": "^3.0.0" "vue": "^3.0.0"
} }
}, },
"node_modules/vue-toastification": {
"version": "2.0.0-rc.5",
"resolved": "https://registry.npmjs.org/vue-toastification/-/vue-toastification-2.0.0-rc.5.tgz",
"integrity": "sha512-q73e5jy6gucEO/U+P48hqX+/qyXDozAGmaGgLFm5tXX4wJBcVsnGp4e/iJqlm9xzHETYOilUuwOUje2Qg1JdwA==",
"peerDependencies": {
"vue": "^3.0.2"
}
},
"node_modules/vue-tsc": { "node_modules/vue-tsc": {
"version": "0.31.3", "version": "0.31.3",
"resolved": "https://registry.npmjs.org/vue-tsc/-/vue-tsc-0.31.3.tgz", "resolved": "https://registry.npmjs.org/vue-tsc/-/vue-tsc-0.31.3.tgz",
@ -12474,6 +12483,12 @@
"@vue/devtools-api": "^6.0.0-beta.18" "@vue/devtools-api": "^6.0.0-beta.18"
} }
}, },
"vue-toastification": {
"version": "2.0.0-rc.5",
"resolved": "https://registry.npmjs.org/vue-toastification/-/vue-toastification-2.0.0-rc.5.tgz",
"integrity": "sha512-q73e5jy6gucEO/U+P48hqX+/qyXDozAGmaGgLFm5tXX4wJBcVsnGp4e/iJqlm9xzHETYOilUuwOUje2Qg1JdwA==",
"requires": {}
},
"vue-tsc": { "vue-tsc": {
"version": "0.31.3", "version": "0.31.3",
"resolved": "https://registry.npmjs.org/vue-tsc/-/vue-tsc-0.31.3.tgz", "resolved": "https://registry.npmjs.org/vue-tsc/-/vue-tsc-0.31.3.tgz",

View file

@ -32,6 +32,7 @@
"vue": "^3.2.31", "vue": "^3.2.31",
"vue-i18n": "^9.2.0-beta.30", "vue-i18n": "^9.2.0-beta.30",
"vue-router": "^4.0.12", "vue-router": "^4.0.12",
"vue-toastification": "^2.0.0-rc.5",
"yup": "^0.32.11" "yup": "^0.32.11"
}, },
"devDependencies": { "devDependencies": {

View file

@ -1,6 +1,6 @@
import { ref } from 'vue'
import useAxios, { CustomAxiosError } from '@/composables/useAxios' import useAxios, { CustomAxiosError } from '@/composables/useAxios'
import { Wishlist, WishlistItem } from '@/types' import { Wishlist, WishlistItem } from '@/types'
import { ref } from 'vue'
const { client } = useAxios() const { client } = useAxios()
//@ts-expect-error ... //@ts-expect-error ...

View file

@ -5,6 +5,14 @@
}, },
"loading": { "loading": {
"text": "Lade..." "text": "Lade..."
},
"wishlist": {
"saved": {
"text": "Wunschliste gespeichert"
},
"saving-failed": {
"text": "Wunschliste konnte nicht gespeichert werden"
}
} }
}, },
"errors": { "errors": {

View file

@ -5,6 +5,14 @@
}, },
"loading": { "loading": {
"text": "Loading..." "text": "Loading..."
},
"wishlist": {
"saved": {
"text": "Wishlist saved"
},
"saving-failed": {
"text": "Saving wishlist failed"
}
} }
}, },
"errors": { "errors": {

View file

@ -1,5 +1,7 @@
import { createApp } from 'vue' import { createApp } from 'vue'
import Toast from 'vue-toastification'
import './assets/tailwind.css' import './assets/tailwind.css'
import 'vue-toastification/dist/index.css'
import App from './App.vue' import App from './App.vue'
import router from './router' import router from './router'
@ -10,6 +12,7 @@ const app = createApp(App)
app.use(router) app.use(router)
app.use(i18n) app.use(i18n)
app.use(Toast, {})
app.component('modalOverlay', Modal) app.component('modalOverlay', Modal)
app.mount('#app') app.mount('#app')

View file

@ -1,5 +1,6 @@
<script setup lang="ts"> <script setup lang="ts">
import { useI18n } from 'vue-i18n' import { useI18n } from 'vue-i18n'
import { useToast } from 'vue-toastification'
import { Wishlist, WishlistItem as WishlistItemType } from '@/types' import { Wishlist, WishlistItem as WishlistItemType } from '@/types'
import { computed } from 'vue' import { computed } from 'vue'
import { useRoute, useRouter } from 'vue-router' import { useRoute, useRouter } from 'vue-router'
@ -13,6 +14,7 @@ const router = useRouter()
const modal = useModal() const modal = useModal()
const { isActive: editModeIsActive } = useEditMode() const { isActive: editModeIsActive } = useEditMode()
const { t } = useI18n() const { t } = useI18n()
const toast = useToast()
const { const {
state, state,
@ -47,8 +49,13 @@ const bought = async (item: WishlistItemType): Promise<void> => {
} }
const handleUpdateWishlist = async (values: Wishlist) => { const handleUpdateWishlist = async (values: Wishlist) => {
await updateWishlist(values) try {
router.push(`/${state.value?.slugUrlText}`) await updateWishlist(values)
toast.success(t('common.wishlist.saved.text'))
router.push(`/${state.value?.slugUrlText}`)
} catch (error) {
toast.error(t('common.wishlist.saving-failed.text'))
}
} }
</script> </script>