Replace the notify store with 2fauth/ui notifier & 2fauth/stores parser

This commit is contained in:
Bubka
2025-06-23 14:53:17 +02:00
parent 6f419cfbcb
commit 16a1a9077d
39 changed files with 192 additions and 203 deletions

View File

@ -1,6 +1,6 @@
import { defineStore } from 'pinia'
import { useUserStore } from '@/stores/user'
import { useNotifyStore } from '@/stores/notify'
import { useNotify } from '@2fauth/ui'
import groupService from '@/services/groupService'
export const useGroups = defineStore({
@ -17,7 +17,8 @@ export const useGroups = defineStore({
current(state) {
const group = state.items.find(item => item.id === parseInt(useUserStore().preferences.activeGroup))
return group ? group.name : t('message.all')
// TODO : restore translated prompt
return group ? group.name : 'message.all'
},
withoutTheAllGroup(state) {
@ -47,11 +48,13 @@ export const useGroups = defineStore({
if (index > -1) {
this.items[index] = group
useNotifyStore().success({ text: t('message.groups.group_name_saved') })
// TODO : restore translated message
useNotify().success({ text: 'message.groups.group_name_saved' })
}
else {
this.items.push(group)
useNotifyStore().success({ text: t('message.groups.group_successfully_created') })
// TODO : restore translated message
useNotify().success({ text: 'message.groups.group_successfully_created' })
}
},
@ -78,10 +81,13 @@ export const useGroups = defineStore({
async delete(id) {
const user = useUserStore()
if (confirm(t('message.groups.confirm.delete'))) {
// TODO : restore translated message
// if (confirm(t('message.groups.confirm.delete'))) {
if (confirm('message.groups.confirm.delete')) {
await groupService.delete(id).then(response => {
this.items = this.items.filter(a => a.id !== id)
useNotifyStore().success({ text: t('message.groups.group_successfully_deleted') })
// TODO : restore translated message
useNotify().success({ text: 'message.groups.group_successfully_deleted' })
// Reset group filter to 'All' (groupId=0) since the backend has already made
// the change automatically. This prevents a new request.