From 62304601484a4a2eadcb3a70da3e278245d03c26 Mon Sep 17 00:00:00 2001 From: Sabda Yagra Date: Fri, 12 Sep 2025 17:51:33 +0700 Subject: [PATCH] fix: adjust layout in spv menus --- .../[title]/components/questions-table.tsx | 85 +++++++++++++- .../supervisor/ticketing/components/table.tsx | 14 ++- .../form/ticketing/ticketing-detail-form.tsx | 11 +- lib/menus.ts | 110 +++++++++--------- service/communication/communication.ts | 19 ++- 5 files changed, 174 insertions(+), 65 deletions(-) diff --git a/app/[locale]/(protected)/supervisor/communications/questions/[title]/components/questions-table.tsx b/app/[locale]/(protected)/supervisor/communications/questions/[title]/components/questions-table.tsx index 98efd8e3..891baac0 100644 --- a/app/[locale]/(protected)/supervisor/communications/questions/[title]/components/questions-table.tsx +++ b/app/[locale]/(protected)/supervisor/communications/questions/[title]/components/questions-table.tsx @@ -98,6 +98,12 @@ const QuestionsTable = (props: { const [page, setPage] = React.useState(1); const [totalPage, setTotalPage] = React.useState(1); const [search, setSearch] = React.useState(""); + const [activeTab, setActiveTab] = React.useState<"publik" | "rutin">( + "publik" + ); + const [reportType, setReportType] = React.useState<"general" | "routine">( + "general" + ); const roleId = getCookiesDecrypt("urie"); @@ -136,13 +142,21 @@ const QuestionsTable = (props: { } }, [searchParams]); + // React.useEffect(() => { + // fetchData(); + // setPagination({ + // pageIndex: 0, + // pageSize: Number(showData), + // }); + // }, [page, showData]); + // ✅ update useEffect, tambahin reportType supaya reload saat tab diganti React.useEffect(() => { fetchData(); setPagination({ pageIndex: 0, pageSize: Number(showData), }); - }, [page, showData]); + }, [page, showData, reportType]); let typingTimer: any; const doneTypingInterval = 1500; @@ -160,6 +174,52 @@ const QuestionsTable = (props: { fetchData(); } + // async function fetchData() { + // const typeNow = + // title === "comment" + // ? "1" + // : title === "facebook" + // ? "2" + // : title === "instagram" + // ? "3" + // : title === "x" + // ? "4" + // : title === "youtube" + // ? "5" + // : title === "emergency" + // ? "6" + // : title === "email" + // ? "7" + // : title === "inbox" + // ? "8" + // : title === "whatsapp" + // ? "9" + // : title === "tiktok" + // ? "10" + // : ""; + + // try { + // const res = await getQuestionPagination( + // search, + // page - 1, + // typeNow, + // showData + // ); + // const data = res?.data?.data; + // const contentData = data?.page?.content; + // console.log("contentDatassss : ", data); + + // contentData.forEach((item: any, index: number) => { + // item.no = (page - 1) * Number(showData) + index + 1; + // }); + // setDataTable(contentData); + // props.statisticData(data?.statistic); + // setTotalData(data?.page?.totalElements); + // setTotalPage(data?.page?.totalPages); + // } catch (error) { + // console.error("Error fetching tasks:", error); + // } + // } async function fetchData() { const typeNow = title === "comment" @@ -185,12 +245,15 @@ const QuestionsTable = (props: { : ""; try { + // ⬇️ tambahan param khusus untuk emergency const res = await getQuestionPagination( search, page - 1, typeNow, - showData + showData, + title === "emergency" ? reportType : undefined ); + const data = res?.data?.data; const contentData = data?.page?.content; console.log("contentDatassss : ", data); @@ -198,6 +261,7 @@ const QuestionsTable = (props: { contentData.forEach((item: any, index: number) => { item.no = (page - 1) * Number(showData) + index + 1; }); + setDataTable(contentData); props.statisticData(data?.statistic); setTotalData(data?.page?.totalElements); @@ -267,6 +331,23 @@ const QuestionsTable = (props: { + {title === "emergency" && ( +
+ + +
+ )} + {table.getHeaderGroups().map((headerGroup) => ( diff --git a/app/[locale]/(protected)/supervisor/ticketing/components/table.tsx b/app/[locale]/(protected)/supervisor/ticketing/components/table.tsx index 0427ea81..87860937 100644 --- a/app/[locale]/(protected)/supervisor/ticketing/components/table.tsx +++ b/app/[locale]/(protected)/supervisor/ticketing/components/table.tsx @@ -80,7 +80,12 @@ export default function TicketingTable() { async function fetchData() { try { - const res = await ticketingPagination(search, pageSize, page - 1, mediaId == 'all' ? "" : mediaId as string); + const res = await ticketingPagination( + search, + pageSize, + page - 1, + mediaId == "all" ? "" : (mediaId as string) + ); const data = res?.data?.data; const content = data?.content || []; const mapped: Issue[] = content.map((it: any, idx: number) => ({ @@ -413,7 +418,7 @@ export default function TicketingTable() { {src.short}
-
+ {/*
{(it.title ?? "") .split(" ") .slice(0, 25) @@ -421,6 +426,11 @@ export default function TicketingTable() { ((it.title ?? "").split(" ").length > 25 ? "..." : "")} +
*/} +
+ {(it.title ?? "").length > 60 + ? (it.title ?? "").substring(0, 60) + "..." + : it.title}
diff --git a/components/form/ticketing/ticketing-detail-form.tsx b/components/form/ticketing/ticketing-detail-form.tsx index ef31dbf5..c816f5a5 100644 --- a/components/form/ticketing/ticketing-detail-form.tsx +++ b/components/form/ticketing/ticketing-detail-form.tsx @@ -709,9 +709,9 @@ export default function FormDetailTicketing({ id }: Props) { }; return ( -
+
{/* Header */} -
+
{(detail?.title ?? "").split(" ").slice(0, 25).join(" ") + @@ -723,12 +723,13 @@ export default function FormDetailTicketing({ id }: Props) {
- {/* Chat Messages */} -
+ {/* Chat Messages (scrollable only this part) */} +
{!detail ? (
+ {/* Icon kosong */} {/* Input Box */} -
+