feat:delete iklan

This commit is contained in:
Anang Yusman 2025-06-08 22:54:54 +08:00
parent 1f7c07121a
commit f3abd767ba
4 changed files with 25 additions and 22 deletions

View File

@ -31,7 +31,7 @@ import {
DialogTrigger, DialogTrigger,
} from "@/components/ui/dialog"; } from "@/components/ui/dialog";
import { Collapsible, CollapsibleContent } from "@/components/ui/collapsible"; import { Collapsible, CollapsibleContent } from "@/components/ui/collapsible";
import { setBanner } from "@/service/settings/settings"; import { deleteAdvertisements, setBanner } from "@/service/settings/settings";
import { error } from "@/config/swal"; import { error } from "@/config/swal";
import { useToast } from "@/components/ui/use-toast"; import { useToast } from "@/components/ui/use-toast";
import withReactContent from "sweetalert2-react-content"; import withReactContent from "sweetalert2-react-content";
@ -85,7 +85,7 @@ const columns: ColumnDef<any>[] = [
id, id,
}; };
const response = await deleteMedia(data); const response = await deleteAdvertisements(id);
if (response?.error) { if (response?.error) {
error(response.message); error(response.message);
@ -107,7 +107,7 @@ const columns: ColumnDef<any>[] = [
}); });
} }
const handleDeleteMedia = (id: any) => { const handleDeleteAdvertisements = (id: any) => {
MySwal.fire({ MySwal.fire({
title: "Hapus Data", title: "Hapus Data",
text: "", text: "",
@ -146,7 +146,7 @@ const columns: ColumnDef<any>[] = [
</DropdownMenuItem> </DropdownMenuItem>
</Link> </Link>
<DropdownMenuItem <DropdownMenuItem
onClick={() => handleDeleteMedia(row.original.id)} onClick={() => handleDeleteAdvertisements(row.original.id)}
className="p-2 border-b text-destructive bg-destructive/30 focus:bg-destructive focus:text-destructive-foreground rounded-none" className="p-2 border-b text-destructive bg-destructive/30 focus:bg-destructive focus:text-destructive-foreground rounded-none"
> >
<Trash2 className="w-4 h-4 me-1.5" /> <Trash2 className="w-4 h-4 me-1.5" />

View File

@ -524,15 +524,14 @@ export function TambahIklanDetail() {
<p className="text-xs text-red-500"> <p className="text-xs text-red-500">
(Warning: Foto yang di upload adalah Foto Potrait) (Warning: Foto yang di upload adalah Foto Potrait)
</p> </p>
<Card className="mt-2">
<Image <Image
src={`https://netidhub.com/api/advertisements/viewer/${id}`} src={`https://netidhub.com/api/advertisements/viewer/${id}`}
alt="Thumbnail Gambar Utama" alt="Thumbnail Gambar Utama"
className=" rounded-md" className=" rounded-md my-3"
width={300} width={300}
height={500} height={500}
/> />
</Card>
</div> </div>
<div> <div>
<p className="font-medium">Deskripsi</p> <p className="font-medium">Deskripsi</p>

View File

@ -508,15 +508,14 @@ export function TambahIklanUpdate() {
</div> </div>
</div> </div>
))} ))}
<Card className="mt-2">
<Image <Image
src={`https://netidhub.com/api/advertisements/viewer/${id}`} src={`https://netidhub.com/api/advertisements/viewer/${id}`}
alt="Thumbnail Gambar Utama" alt="Thumbnail Gambar Utama"
className=" rounded-md" className=" rounded-md my-3"
width={300} width={300}
height={500} height={500}
/> />
</Card>
</div> </div>
<div> <div>

View File

@ -142,3 +142,8 @@ export async function detailAdvertisements(id: any) {
const url = `advertisements?id=${id}`; const url = `advertisements?id=${id}`;
return httpGetInterceptor(url); return httpGetInterceptor(url);
} }
export async function deleteAdvertisements(id: string | number) {
const url = `advertisements?id=${id}`;
return httpDeleteInterceptor(url);
}