-
-
-
-
-
-
- {(column) => (
- {column.name}
- )}
-
-
- {(item) => (
-
- {(columnKey) => (
- {renderCell(item, columnKey)}
- )}
-
- )}
-
-
-
+ switch (columnKey) {
+ case "status":
+ return (
+
+
+ {cellValue}
+
+ );
+ case "createdAt":
+ return
{convertDateFormat(article.createdAt)}
;
- >
- );
+ case "actions":
+ return (
+
+
+
+
+
+
+
+
+
+ Detail
+
+
+
+
+
+ Edit
+
+
+ handleDelete(article.id)}>
+
+ Delete
+
+
+
+
+ );
+
+ default:
+ return cellValue;
+ }
+ }, []);
+
+ let typingTimer: NodeJS.Timeout;
+ const doneTypingInterval = 1500;
+
+ const handleKeyUp = () => {
+ clearTimeout(typingTimer);
+ typingTimer = setTimeout(doneTyping, doneTypingInterval);
+ };
+
+ const handleKeyDown = () => {
+ clearTimeout(typingTimer);
+ };
+
+ async function doneTyping() {
+ initState();
+ }
+
+ return (
+ <>
+
+
+
+
+
Pencarian
+
+ }
+ type="text"
+ onChange={(e) => setSearch(e.target.value)}
+ onKeyUp={handleKeyUp}
+ onKeyDown={handleKeyDown}
+ />
+
+
+
Data
+
+
+
+
Kategori
+
+
+
+
Tanggal
+
setStartDateValue(e)}
+ inputClassName="z-50 w-full text-sm bg-transparent border-1 border-gray-200 px-2 py-[6px] rounded-xl h-[40px] text-gray-600 dark:text-gray-300"
+ />
+
+
+
+
+ {(column) => (
+ {column.name}
+ )}
+
+ }
+ >
+ {(item) => (
+
+ {(columnKey) => (
+ {renderCell(item, columnKey)}
+ )}
+
+ )}
+
+
+
+
+
+ >
+ );
}
diff --git a/service/magazine.tsx b/service/magazine.tsx
index efda83a..e242546 100644
--- a/service/magazine.tsx
+++ b/service/magazine.tsx
@@ -1,3 +1,4 @@
+import { PaginationRequest } from "@/types/globals";
import {
httpDeleteInterceptor,
httpGet,
@@ -16,3 +17,16 @@ export async function createMagazine(data: any) {
const pathUrl = `/magazines`;
return await httpPost(pathUrl, headers, data);
}
+
+export async function getListMagazine(props: PaginationRequest) {
+ const { page, limit, search, startDate, endDate } = props;
+ const headers = {
+ "content-type": "application/json",
+ };
+ return await httpGet(
+ `/magazines?limit=${limit}&page=${page}&title=${search}&startDate=${
+ startDate || ""
+ }&endDate=${endDate || ""}`,
+ headers
+ );
+}