feat: add wishlist

This commit is contained in:
2026-09-30 19:15:57 +02:00
parent ab3bbb6338
commit 1f6061b998
57 changed files with 638 additions and 232 deletions
@@ -0,0 +1,29 @@
function capitalize(word: string): string {
return word.charAt(0).toUpperCase() + word.slice(1)
}
export function useSaveEntry(options: { url: string, dataKey: string | string[], noun: string, onSaved: () => void }) {
const toast = useToast()
const saving = ref(false)
async function save(body: Record<string, unknown>) {
saving.value = true
try {
await $fetch(options.url, { method: 'POST', body })
await refreshNuxtData(options.dataKey)
toast.add({ title: `${capitalize(options.noun)} saved`, color: 'success', icon: 'i-lucide-check' })
options.onSaved()
} catch (error) {
toast.add({
title: `Couldn't save the ${options.noun}`,
description: errorMessage(error),
color: 'error',
icon: 'i-lucide-triangle-alert'
})
} finally {
saving.value = false
}
}
return { saving, save }
}