Files
preis-tracker/src/components/ProductActions.tsx

20 lines
735 B
TypeScript

'use client'
export function ProductActions({ productId }: { productId: string }) {
async function refresh() {
const res = await fetch(`/api/products/${productId}/scrape`, { method: 'POST' })
if (res.ok) location.reload()
}
async function del() {
if (!confirm('Wirklich löschen?')) return
const res = await fetch(`/api/products/${productId}`, { method: 'DELETE' })
if (res.ok) location.href = '/'
}
return (
<div className="flex gap-2">
<button onClick={refresh} className="rounded bg-zinc-800 px-3 py-1.5 text-sm hover:bg-zinc-700">Jetzt aktualisieren</button>
<button onClick={del} className="rounded bg-red-900 px-3 py-1.5 text-sm hover:bg-red-800">Löschen</button>
</div>
)
}