Files
marmarislocal/app/[locale]/admin/trash/TrashActionButtons.tsx
T

44 lines
1.4 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
'use client'
import { restoreListingAction, hardDeleteListingAction } from '@/app/actions'
import { RotateCcw, Trash2 } from 'lucide-react'
export function TrashActionButtons({ id, type }: { id: string; type: 'listing' | 'event' }) {
const handleRestore = async () => {
if (!confirm('Bu ögeyi geri yüklemek istediğinize emin misiniz? Ana listeye eklenecektir.')) return
if (type === 'listing') {
const res = await restoreListingAction(id)
if (res?.error) alert(res.error)
}
}
const handleHardDelete = async () => {
if (!confirm('DİKKAT: Bu ögeyi kalıcı olarak silmek istediğinize emin misiniz? Bu işlem geri alınamaz!')) return
if (type === 'listing') {
const res = await hardDeleteListingAction(id)
if (res?.error) alert(res.error)
}
}
return (
<div className="flex justify-end gap-2">
<button
onClick={handleRestore}
className="p-2 text-shutter hover:text-turquoise hover:bg-turquoise/10 rounded-lg transition-colors"
title="Geri Yükle"
>
<RotateCcw className="w-4 h-4" />
</button>
<button
onClick={handleHardDelete}
className="p-2 text-shutter hover:text-red-500 hover:bg-red-500/10 rounded-lg transition-colors"
title="Kalıcı Olarak Sil"
>
<Trash2 className="w-4 h-4" />
</button>
</div>
)
}