mirror of
https://github.com/Bubka/2FAuth.git
synced 2025-06-20 11:47:53 +02:00
Update the twofaccounts store after item creation/update
This commit is contained in:
parent
e8a3c441be
commit
dc03e8b1e5
@ -4,6 +4,7 @@
|
|||||||
import FormLockField from '@/components/formelements/FormLockField.vue'
|
import FormLockField from '@/components/formelements/FormLockField.vue'
|
||||||
import twofaccountService from '@/services/twofaccountService'
|
import twofaccountService from '@/services/twofaccountService'
|
||||||
import { useUserStore } from '@/stores/user'
|
import { useUserStore } from '@/stores/user'
|
||||||
|
import { useTwofaccounts } from '@/stores/twofaccounts'
|
||||||
import { useBusStore } from '@/stores/bus'
|
import { useBusStore } from '@/stores/bus'
|
||||||
import { useNotifyStore } from '@/stores/notify'
|
import { useNotifyStore } from '@/stores/notify'
|
||||||
import { UseColorMode } from '@vueuse/components'
|
import { UseColorMode } from '@vueuse/components'
|
||||||
@ -13,6 +14,7 @@
|
|||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const user = useUserStore()
|
const user = useUserStore()
|
||||||
|
const twofaccounts = useTwofaccounts()
|
||||||
const bus = useBusStore()
|
const bus = useBusStore()
|
||||||
const notify = useNotifyStore()
|
const notify = useNotifyStore()
|
||||||
const form = reactive(new Form({
|
const form = reactive(new Form({
|
||||||
@ -147,9 +149,10 @@
|
|||||||
// set current temp icon as account icon
|
// set current temp icon as account icon
|
||||||
form.icon = tempIcon.value
|
form.icon = tempIcon.value
|
||||||
|
|
||||||
await form.post('/api/v1/twofaccounts')
|
const { data } = await form.post('/api/v1/twofaccounts')
|
||||||
|
|
||||||
if (form.errors.any() === false) {
|
if (form.errors.any() === false) {
|
||||||
|
twofaccounts.items.push(data)
|
||||||
notify.success({ text: trans('twofaccounts.account_created') })
|
notify.success({ text: trans('twofaccounts.account_created') })
|
||||||
router.push({ name: 'accounts' });
|
router.push({ name: 'accounts' });
|
||||||
}
|
}
|
||||||
@ -170,9 +173,12 @@
|
|||||||
deleteIcon()
|
deleteIcon()
|
||||||
}
|
}
|
||||||
|
|
||||||
await form.put('/api/v1/twofaccounts/' + props.twofaccountId)
|
const { data } = await form.put('/api/v1/twofaccounts/' + props.twofaccountId)
|
||||||
|
|
||||||
if( form.errors.any() === false ) {
|
if( form.errors.any() === false ) {
|
||||||
|
const index = twofaccounts.items.findIndex(acc => acc.id === data.id)
|
||||||
|
twofaccounts.items.splice(index, 1, data)
|
||||||
|
|
||||||
notify.success({ text: trans('twofaccounts.account_updated') })
|
notify.success({ text: trans('twofaccounts.account_updated') })
|
||||||
router.push({ name: 'accounts' })
|
router.push({ name: 'accounts' })
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user