122 lines
3.3 KiB
TypeScript
122 lines
3.3 KiB
TypeScript
|
|
import * as React from "react";
|
||
|
|
import { ColumnDef } from "@tanstack/react-table";
|
||
|
|
|
||
|
|
import { Eye, MoreVertical, SquarePen, Trash2 } from "lucide-react";
|
||
|
|
import { cn } from "@/lib/utils";
|
||
|
|
import {
|
||
|
|
DropdownMenu,
|
||
|
|
DropdownMenuContent,
|
||
|
|
DropdownMenuTrigger,
|
||
|
|
DropdownMenuItem,
|
||
|
|
} from "@/components/ui/dropdown-menu";
|
||
|
|
import { Button } from "@/components/ui/button";
|
||
|
|
import { Badge } from "@/components/ui/badge";
|
||
|
|
|
||
|
|
import { Link, useRouter } from "@/i18n/routing";
|
||
|
|
import { error } from "@/config/swal";
|
||
|
|
import { deleteCategory, deleteDataFAQ } from "@/service/settings/settings";
|
||
|
|
import { useToast } from "@/components/ui/use-toast";
|
||
|
|
// import EditCategoryModal from "./edit";
|
||
|
|
import {
|
||
|
|
Popover,
|
||
|
|
PopoverContent,
|
||
|
|
PopoverTrigger,
|
||
|
|
} from "@/components/ui/popover";
|
||
|
|
import {
|
||
|
|
Menubar,
|
||
|
|
MenubarContent,
|
||
|
|
MenubarMenu,
|
||
|
|
MenubarTrigger,
|
||
|
|
} from "@/components/ui/menubar";
|
||
|
|
import { htmlToString } from "@/utils/globals";
|
||
|
|
import EditFAQModal from "./edit";
|
||
|
|
import EditFeedbackModal from "./edit";
|
||
|
|
|
||
|
|
const columns: ColumnDef<any>[] = [
|
||
|
|
{
|
||
|
|
accessorKey: "no",
|
||
|
|
header: "No",
|
||
|
|
cell: ({ row }) => <span>{row.getValue("no")}</span>,
|
||
|
|
},
|
||
|
|
|
||
|
|
{
|
||
|
|
accessorKey: "question",
|
||
|
|
header: "Poin Penilaian",
|
||
|
|
cell: ({ row }) => (
|
||
|
|
<span className="normal-case">
|
||
|
|
{htmlToString(row.getValue("question"))}
|
||
|
|
</span>
|
||
|
|
),
|
||
|
|
},
|
||
|
|
{
|
||
|
|
accessorKey: "isInternational",
|
||
|
|
header: "Wilayah Publish",
|
||
|
|
cell: ({ row }) => (
|
||
|
|
<span className="normal-case">
|
||
|
|
{row.getValue("isInternational") ? "Internasional" : "Wilayah"}
|
||
|
|
</span>
|
||
|
|
),
|
||
|
|
},
|
||
|
|
|
||
|
|
{
|
||
|
|
id: "actions",
|
||
|
|
accessorKey: "action",
|
||
|
|
header: "Actions",
|
||
|
|
enableHiding: false,
|
||
|
|
cell: ({ row }) => {
|
||
|
|
const router = useRouter();
|
||
|
|
const { toast } = useToast();
|
||
|
|
|
||
|
|
const faqDelete = async (id: string) => {
|
||
|
|
const response = await deleteDataFAQ(id);
|
||
|
|
console.log(response);
|
||
|
|
if (response?.error) {
|
||
|
|
error(response.message);
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
toast({
|
||
|
|
title: "Sukses",
|
||
|
|
description: "Berhasil Delete",
|
||
|
|
});
|
||
|
|
router.push("/admin/settings/feedback?dataChange=true");
|
||
|
|
};
|
||
|
|
return (
|
||
|
|
<Menubar className="border-none">
|
||
|
|
<MenubarMenu>
|
||
|
|
<MenubarTrigger>
|
||
|
|
<Button
|
||
|
|
size="icon"
|
||
|
|
className="bg-transparent ring-offset-transparent hover:bg-transparent hover:ring-0 hover:ring-transparent"
|
||
|
|
>
|
||
|
|
<MoreVertical className="h-4 w-4 text-default-800" />
|
||
|
|
</Button>
|
||
|
|
</MenubarTrigger>
|
||
|
|
<MenubarContent className="flex flex-col gap-2 justify-center items-start p-4">
|
||
|
|
<EditFeedbackModal
|
||
|
|
id={row.original.id}
|
||
|
|
isDetail={true}
|
||
|
|
data={row.original}
|
||
|
|
/>
|
||
|
|
|
||
|
|
<EditFeedbackModal
|
||
|
|
id={row.original.id}
|
||
|
|
isDetail={false}
|
||
|
|
data={row.original}
|
||
|
|
/>
|
||
|
|
|
||
|
|
<a
|
||
|
|
onClick={() => faqDelete(row.original.id)}
|
||
|
|
className="hover:underline cursor-pointer hover:text-destructive"
|
||
|
|
>
|
||
|
|
Delete
|
||
|
|
</a>
|
||
|
|
</MenubarContent>
|
||
|
|
</MenubarMenu>
|
||
|
|
</Menubar>
|
||
|
|
);
|
||
|
|
},
|
||
|
|
},
|
||
|
|
];
|
||
|
|
|
||
|
|
export default columns;
|