fix submit handler

This commit is contained in:
2025-06-18 16:00:20 +02:00
parent 78036f9aea
commit 62ddc33290
15 changed files with 73 additions and 45 deletions

View File

@ -128,7 +128,7 @@ const addGroupAsync = async (group: Partial<InsertHaexPasswordsGroups>) => {
name: group.name,
order: group.order,
}
await currentVault.drizzle.insert(haexPasswordsGroups).values(newGroup)
await currentVault.drizzle?.insert(haexPasswordsGroups).values(newGroup)
await syncGroupItemsAsync()
return newGroup
}
@ -138,7 +138,7 @@ const readGroupAsync = async (groupId: string) => {
return (
await currentVault.drizzle
.select()
?.select()
.from(haexPasswordsGroups)
.where(eq(haexPasswordsGroups.id, groupId))
).at(0)
@ -166,12 +166,12 @@ const readGroupItemsAsync = async (
if (groupId) {
return currentVault.drizzle
.select()
?.select()
.from(haexPasswordsGroupItems)
.where(eq(haexPasswordsGroupItems.groupId, groupId))
} else {
return currentVault.drizzle
.select()
?.select()
.from(haexPasswordsGroupItems)
.where(isNull(haexPasswordsGroupItems.groupId))
}
@ -198,7 +198,7 @@ const getByParentIdAsync = async (
console.log('getByParentIdAsync', parentId)
if (parentId) {
const groups = await currentVault.drizzle
.select()
?.select()
.from(haexPasswordsGroups)
.where(eq(haexPasswordsGroups.parentId, parentId))
.orderBy(sql`${haexPasswordsGroups.order} nulls last`)
@ -206,7 +206,7 @@ const getByParentIdAsync = async (
return groups
} else {
const groups = await currentVault.drizzle
.select()
?.select()
.from(haexPasswordsGroups)
.where(isNull(haexPasswordsGroups.parentId))
.orderBy(sql`${haexPasswordsGroups.order} nulls last`)
@ -238,10 +238,20 @@ const updateAsync = async (group: InsertHaexPasswordsGroups) => {
const { currentVault } = storeToRefs(useVaultStore())
if (!group.id) return
const newGroup: InsertHaexPasswordsGroups = {
id: group.id,
color: group.color,
description: group.description,
icon: group.icon,
name: group.name,
order: group.order,
parentId: group.parentId,
}
return currentVault.value.drizzle
.update(haexPasswordsGroups)
.set(group)
.where(eq(haexPasswordsGroups.id, group.id))
.set(newGroup)
.where(eq(haexPasswordsGroups.id, newGroup.id))
}
const navigateToGroupItemsAsync = (groupId: string) => {

View File

@ -15,7 +15,7 @@ const getAsync = async (itemId: string | null) => {
const { currentVault } = useVaultStore()
const history = await currentVault.drizzle
.select()
?.select()
.from(haexPasswordsItemHistory)
.where(eq(haexPasswordsItemHistory.itemId, itemId))

View File

@ -121,12 +121,14 @@ export const useVaultSettingsStore = defineStore('vaultSettingsStore', () => {
const readDeviceNameAsync = async (id: string) => {
const { currentVault } = useVaultStore()
const deviceName = await currentVault.drizzle.query.haexSettings.findFirst({
where: and(
eq(schema.haexSettings.type, VaultSettingsTypeEnum.deviceName),
eq(schema.haexSettings.key, id),
),
})
const deviceName = await currentVault.drizzle?.query.haexSettings.findFirst(
{
where: and(
eq(schema.haexSettings.type, VaultSettingsTypeEnum.deviceName),
eq(schema.haexSettings.key, id),
),
},
)
console.log('readDeviceNameAsync', deviceName)
return deviceName
}
@ -146,7 +148,7 @@ export const useVaultSettingsStore = defineStore('vaultSettingsStore', () => {
return
}
return currentVault.drizzle.insert(schema.haexSettings).values({
return currentVault.drizzle?.insert(schema.haexSettings).values({
id: crypto.randomUUID(),
type: VaultSettingsTypeEnum.deviceName,
key: deviceId,
@ -167,7 +169,7 @@ export const useVaultSettingsStore = defineStore('vaultSettingsStore', () => {
if (!isNameOk.success) return
return currentVault.drizzle
.update(schema.haexSettings)
?.update(schema.haexSettings)
.set({
value: deviceName,
})