diff --git a/app/[locale]/(protected)/admin/settings/banner/component/banner-column.tsx b/app/[locale]/(protected)/admin/settings/banner/component/banner-column.tsx index 899f2124..4cb46316 100644 --- a/app/[locale]/(protected)/admin/settings/banner/component/banner-column.tsx +++ b/app/[locale]/(protected)/admin/settings/banner/component/banner-column.tsx @@ -58,16 +58,6 @@ const columns: ColumnDef[] = [ {formatDateToIndonesian(row.getValue("createdAt"))} ), }, - { - accessorKey: "isStaticBanner", - header: "Static Banner", - cell: ({ row }) => ( - - ), - }, { accessorKey: "statusName", header: "Status Banner", @@ -75,7 +65,6 @@ const columns: ColumnDef[] = [ ), }, - { id: "actions", accessorKey: "action", diff --git a/app/[locale]/(protected)/admin/settings/banner/component/table.tsx b/app/[locale]/(protected)/admin/settings/banner/component/table.tsx index 8ce6c17f..18d20f4c 100644 --- a/app/[locale]/(protected)/admin/settings/banner/component/table.tsx +++ b/app/[locale]/(protected)/admin/settings/banner/component/table.tsx @@ -94,9 +94,7 @@ const ContentListBanner = () => { const [selectedItems, setSelectedItems] = React.useState([]); const [page, setPage] = React.useState(1); const [totalPage, setTotalPage] = React.useState(1); - - let typingTimer: any; - const doneTypingInterval = 1500; + const [searchQuery, setSearchQuery] = React.useState(""); const handleKeyUp = () => { clearTimeout(typingTimer); @@ -108,6 +106,21 @@ const ContentListBanner = () => { typingTimer = setTimeout(doneTyping, doneTypingInterval); }; + let typingTimer: NodeJS.Timeout; + const doneTypingInterval = 1500; + + const handleTyping = () => { + clearTimeout(typingTimer); + typingTimer = setTimeout(() => { + setPage(1); + fetchData(); + }, doneTypingInterval); + }; + + React.useEffect(() => { + fetchData(); + }, [categoryFilter, statusFilter]); + async function doneTyping() { fetchData(); } @@ -133,10 +146,11 @@ const ContentListBanner = () => { const res = await listDataMedia( page - 1, showData, - "", + searchQuery, categoryFilter?.sort().join(","), statusFilter?.sort().join(",") ); + const data = res?.data?.data; const contentData = data?.content; contentData.forEach((item: any, index: number) => { @@ -224,10 +238,19 @@ const ContentListBanner = () => { { + setSearchQuery(e.target.value); + handleTyping(); + }} className="max-w-[300px]" + onKeyDown={(e) => { + if (e.key === "Enter") { + fetchData(); + } + }} /> + {/*
@@ -393,9 +416,12 @@ const ContentListBanner = () => { alt={item.title} className="w-full h-48 object-cover" /> -
-

{item.title}

-
+ +

{item.title}

+
))} diff --git a/app/[locale]/(protected)/admin/settings/banner/page.tsx b/app/[locale]/(protected)/admin/settings/banner/page.tsx index 8385b071..510e102c 100644 --- a/app/[locale]/(protected)/admin/settings/banner/page.tsx +++ b/app/[locale]/(protected)/admin/settings/banner/page.tsx @@ -28,7 +28,7 @@ export default function AdminBanner() { : "bg-white text-black " }`} > - Kontent + Konten