From 88501ac84ff26094b613483944cf5cf382577378 Mon Sep 17 00:00:00 2001 From: Anang Yusman Date: Tue, 3 Jun 2025 23:13:51 +0800 Subject: [PATCH] feat:update calendar-polri --- .../admin/settings/iklan/component/column.tsx | 20 +- .../admin/settings/iklan/component/table.tsx | 11 +- .../(protected)/admin/settings/iklan/page.tsx | 10 +- .../component/calendar-polri-table.tsx | 14 +- .../calendar-polri/component/columns.tsx | 121 +++-- .../schedule/calendar-polri/create/page.tsx | 3 +- .../calendar-polri/detail/[id]/page.tsx | 3 +- .../calendar-polri/update/[id]/page.tsx | 3 +- components/form/content/spit-convert-form.tsx | 26 +- .../schedule/form-calendar-polri-detail.tsx | 482 +++++++++++++++++ .../schedule/form-calendar-polri-update.tsx | 453 ++++++++++++++++ .../form/schedule/form-calendar-polri.tsx | 495 +++++++++++++++--- messages/en.json | 3 +- messages/in.json | 3 +- service/broadcast/broadcast.ts | 12 + service/schedule/schedule.ts | 30 ++ 16 files changed, 1527 insertions(+), 162 deletions(-) create mode 100644 components/form/schedule/form-calendar-polri-detail.tsx create mode 100644 components/form/schedule/form-calendar-polri-update.tsx diff --git a/app/[locale]/(protected)/admin/settings/iklan/component/column.tsx b/app/[locale]/(protected)/admin/settings/iklan/component/column.tsx index 6ffd551f..c137ec06 100644 --- a/app/[locale]/(protected)/admin/settings/iklan/component/column.tsx +++ b/app/[locale]/(protected)/admin/settings/iklan/component/column.tsx @@ -45,18 +45,20 @@ const columns: ColumnDef[] = [ { accessorKey: "title", header: "Judul", - cell: ({ row }) => {row.getValue("title")}, + cell: ({ row }) =>
{row.getValue("title")}
, }, { - accessorKey: "categoryName", - header: "Kategori", - cell: ({ row }) => {row.getValue("categoryName")}, - }, - { - accessorKey: "createdAt", - header: "Tanggal Unggah", + accessorKey: "contentFileName", + header: "Judul Gambar", cell: ({ row }) => ( - {formatDateToIndonesian(row.getValue("createdAt"))} +
{row.getValue("contentFileName")}
+ ), + }, + { + accessorKey: "placements", + header: "Posisi", + cell: ({ row }) => ( +
{row.getValue("placements")}
), }, diff --git a/app/[locale]/(protected)/admin/settings/iklan/component/table.tsx b/app/[locale]/(protected)/admin/settings/iklan/component/table.tsx index e9d72d23..4fc2216c 100644 --- a/app/[locale]/(protected)/admin/settings/iklan/component/table.tsx +++ b/app/[locale]/(protected)/admin/settings/iklan/component/table.tsx @@ -61,14 +61,17 @@ import { PopoverContent, PopoverTrigger, } from "@/components/ui/popover"; -import { listDataMedia } from "@/service/broadcast/broadcast"; +import { + listDataAdvertisements, + listDataMedia, +} from "@/service/broadcast/broadcast"; import { listEnableCategory } from "@/service/content/content"; import { Checkbox } from "@/components/ui/checkbox"; import { close, loading } from "@/config/swal"; import { Link } from "@/i18n/routing"; import { TambahIklanModal } from "@/components/form/setting/form-add-iklan"; -const IklanList = () => { +const AdvertisementsList = () => { const router = useRouter(); const searchParams = useSearchParams(); const [showData, setShowData] = React.useState("10"); @@ -146,7 +149,7 @@ const IklanList = () => { async function fetchData() { try { loading(); - const res = await listDataMedia( + const res = await listDataAdvertisements( page - 1, showData, "", @@ -395,4 +398,4 @@ const IklanList = () => { ); }; -export default IklanList; +export default AdvertisementsList; diff --git a/app/[locale]/(protected)/admin/settings/iklan/page.tsx b/app/[locale]/(protected)/admin/settings/iklan/page.tsx index 3571c256..a207465b 100644 --- a/app/[locale]/(protected)/admin/settings/iklan/page.tsx +++ b/app/[locale]/(protected)/admin/settings/iklan/page.tsx @@ -1,20 +1,16 @@ "use client"; import SiteBreadcrumb from "@/components/site-breadcrumb"; import { useState } from "react"; -import { Button } from "@/components/ui/button"; -import PopUpList from "../popup/component/table"; -import PopUpListTable from "../popup/component/popup-table"; -import IklanList from "./component/table"; -import IklanListTable from "./component/popup-table"; +import AdvertisementsList from "./component/table"; -export default function AdminIklan() { +export default function AdminAdvertisements() { const [selectedTab, setSelectedTab] = useState("content"); return (
- +
); diff --git a/app/[locale]/(protected)/contributor/schedule/calendar-polri/component/calendar-polri-table.tsx b/app/[locale]/(protected)/contributor/schedule/calendar-polri/component/calendar-polri-table.tsx index 3dc28244..bc7254ce 100644 --- a/app/[locale]/(protected)/contributor/schedule/calendar-polri/component/calendar-polri-table.tsx +++ b/app/[locale]/(protected)/contributor/schedule/calendar-polri/component/calendar-polri-table.tsx @@ -43,7 +43,10 @@ import { InputGroup, InputGroupText } from "@/components/ui/input-group"; import { useRouter, useSearchParams } from "next/navigation"; import TablePagination from "@/components/table/table-pagination"; import columns from "./columns"; -import { paginationSchedule } from "@/service/schedule/schedule"; +import { + paginationCalendar, + paginationSchedule, +} from "@/service/schedule/schedule"; import { CardHeader, CardTitle } from "@/components/ui/card"; import { Link } from "@/i18n/routing"; import { useTranslations } from "next-intl"; @@ -117,7 +120,7 @@ const CalendarPolriTable = () => { async function fetchData() { try { - const res = await paginationSchedule( + const res = await paginationCalendar( showData, page - 1, 1, @@ -162,7 +165,12 @@ const CalendarPolriTable = () => { {t("calendar-polri")} {t("schedule")}
- + + +
diff --git a/app/[locale]/(protected)/contributor/schedule/calendar-polri/component/columns.tsx b/app/[locale]/(protected)/contributor/schedule/calendar-polri/component/columns.tsx index 1a3a3ae3..33471915 100644 --- a/app/[locale]/(protected)/contributor/schedule/calendar-polri/component/columns.tsx +++ b/app/[locale]/(protected)/contributor/schedule/calendar-polri/component/columns.tsx @@ -13,6 +13,10 @@ import { Button } from "@/components/ui/button"; import { Badge } from "@/components/ui/badge"; import { Link } from "@/components/navigation"; import { useTranslations } from "next-intl"; +import withReactContent from "sweetalert2-react-content"; +import Swal from "sweetalert2"; +import { error } from "@/lib/swal"; +import { deleteCalendar } from "@/service/schedule/schedule"; const useTableColumns = () => { const t = useTranslations("Table"); // Panggil di dalam hook @@ -58,76 +62,33 @@ const useTableColumns = () => { {row.getValue("endDate")} ), }, + { - accessorKey: "time", - header: t("time"), - cell: ({ row }: { row: { original: any } }) => { - console.log("Row Original Data:", row.original); - const { startTime, endTime } = row.original; - return ( - - {startTime || "N/A"} - {endTime || "N/A"} - - ); - }, - }, - { - accessorKey: "address", - header: t("address"), - cell: ({ row }: { row: { getValue: (key: string) => string } }) => { - const address: string = row.getValue("address"); - return ( - - {address.length > 50 ? `${address.slice(0, 40)}...` : address} - - ); - }, - }, - { - accessorKey: "statusName", + accessorKey: "isActive", header: "Status", cell: ({ row }) => { - const statusColors: Record = { - diterima: "bg-green-100 text-green-600", - "menunggu review": "bg-orange-100 text-orange-600", - }; + const isActive = row.getValue("isActive") as boolean; - // Mengambil `statusName` dari data API - const status = row.getValue("statusName") as string; - const statusName = status?.toLocaleLowerCase(); // Ubah ke huruf kecil - - // Gunakan `statusName` untuk pencocokan - const statusStyles = - statusColors[statusName] || "bg-gray-100 text-gray-600"; + const status = isActive ? "Aktif" : "Tidak Aktif"; + const statusStyles = isActive + ? "bg-green-100 text-green-600" + : "bg-gray-100 text-gray-600"; return ( - {status} {/* Tetap tampilkan nilai asli */} + {status} ); }, }, { - accessorKey: "speaker", - header: t("speaker"), - cell: ({ row }: { row: { original: any } }) => { - console.log("Row Original Data:", row.original); - const { speakerTitle, speakerName } = row.original; - return ( - - {speakerTitle || ""} {speakerName || ""} - - ); - }, - }, - { - accessorKey: "uploaderName", + accessorKey: "createdByName", header: t("source"), cell: ({ row }) => ( - {row.getValue("uploaderName")} + {row.getValue("createdByName")} ), }, @@ -138,6 +99,51 @@ const useTableColumns = () => { header: t("action"), enableHiding: false, cell: ({ row }) => { + const MySwal = withReactContent(Swal); + + async function doDelete(id: any) { + // loading(); + const data = { + id, + }; + + const response = await deleteCalendar(id); + + if (response?.error) { + error(response.message); + return false; + } + success(); + } + + function success() { + MySwal.fire({ + title: "Sukses", + icon: "success", + confirmButtonColor: "#3085d6", + confirmButtonText: "OK", + }).then((result) => { + if (result.isConfirmed) { + window.location.reload(); + } + }); + } + + const handleDeleteCalendars = (id: any) => { + MySwal.fire({ + title: "Hapus Data", + text: "", + icon: "warning", + showCancelButton: true, + cancelButtonColor: "#3085d6", + confirmButtonColor: "#d33", + confirmButtonText: "Hapus", + }).then((result) => { + if (result.isConfirmed) { + doDelete(id); + } + }); + }; return ( @@ -151,7 +157,7 @@ const useTableColumns = () => { @@ -159,14 +165,17 @@ const useTableColumns = () => { Edit - + handleDeleteCalendars(row.original.id)} + className="p-2 border-b text-destructive bg-destructive/30 focus:bg-destructive focus:text-destructive-foreground rounded-none" + > Delete diff --git a/app/[locale]/(protected)/contributor/schedule/calendar-polri/create/page.tsx b/app/[locale]/(protected)/contributor/schedule/calendar-polri/create/page.tsx index 250cc651..1ac121ed 100644 --- a/app/[locale]/(protected)/contributor/schedule/calendar-polri/create/page.tsx +++ b/app/[locale]/(protected)/contributor/schedule/calendar-polri/create/page.tsx @@ -2,13 +2,14 @@ import { Card, CardContent } from "@/components/ui/card"; import SiteBreadcrumb from "@/components/site-breadcrumb"; import FormTask from "@/components/form/task/task-form"; import FormPressConference from "@/components/form/schedule/press-conference-form"; +import { CalendarPolriAdd } from "@/components/form/schedule/form-calendar-polri"; const CalendarPolriCreatePage = () => { return (
- +
); diff --git a/app/[locale]/(protected)/contributor/schedule/calendar-polri/detail/[id]/page.tsx b/app/[locale]/(protected)/contributor/schedule/calendar-polri/detail/[id]/page.tsx index f3347ffb..f9a614f9 100644 --- a/app/[locale]/(protected)/contributor/schedule/calendar-polri/detail/[id]/page.tsx +++ b/app/[locale]/(protected)/contributor/schedule/calendar-polri/detail/[id]/page.tsx @@ -6,13 +6,14 @@ import FormPressConference from "@/components/form/schedule/press-conference-for import FormDetailPressConference from "@/components/form/schedule/press-conference-detail-form"; import { useParams } from "next/navigation"; import { id } from "date-fns/locale"; +import { CalendarPolriAddDetail } from "@/components/form/schedule/form-calendar-polri-detail"; const CalendarPolriDetailPage = () => { return (
- +
); diff --git a/app/[locale]/(protected)/contributor/schedule/calendar-polri/update/[id]/page.tsx b/app/[locale]/(protected)/contributor/schedule/calendar-polri/update/[id]/page.tsx index ce527b9a..dad6f5b1 100644 --- a/app/[locale]/(protected)/contributor/schedule/calendar-polri/update/[id]/page.tsx +++ b/app/[locale]/(protected)/contributor/schedule/calendar-polri/update/[id]/page.tsx @@ -7,13 +7,14 @@ import FormDetailPressConference from "@/components/form/schedule/press-conferen import { useParams } from "next/navigation"; import { id } from "date-fns/locale"; import FormUpdatePressConference from "@/components/form/schedule/press-conference-update-form"; +import { CalendarPolriAddUpdate } from "@/components/form/schedule/form-calendar-polri-update"; const CalendarPolriUpdatePage = () => { return (
- +
); diff --git a/components/form/content/spit-convert-form.tsx b/components/form/content/spit-convert-form.tsx index 6e1e00c1..0222f302 100644 --- a/components/form/content/spit-convert-form.tsx +++ b/components/form/content/spit-convert-form.tsx @@ -169,6 +169,8 @@ export default function FormConvertSPIT() { const [filePlacements, setFilePlacements] = useState([]); const [isUserMabesApprover, setIsUserMabesApprover] = useState(false); const [files, setFiles] = useState([]); + const [selectedWritingStyle, setSelectedWritingStyle] = + useState("profesional"); const options: Option[] = [ { id: "all", label: "SEMUA" }, @@ -494,7 +496,7 @@ export default function FormConvertSPIT() { const handleRewriteClick = async () => { const request = { - style: "friendly", + style: selectedWritingStyle, lang: "id", contextType: "text", urlContext: null, @@ -702,6 +704,28 @@ export default function FormConvertSPIT() {

)} +
+ + +
+ + + + + +
+ +
+

Publish Area

+
+
+ {Object.keys(unitSelection).map((key) => ( +
+ + handleUnitChange( + key as keyof typeof unitSelection, + value as boolean + ) + } + /> + +
+ ))} +
+
+ + + + + + + + Daftar Wilayah Polda dan Polres + + +
+ {listDest.map((polda: any) => ( +
+ + {expandedPolda[polda.id] && ( +
+ + {polda?.subDestination?.map((polres: any) => ( + + ))} +
+ )} +
+ ))} +
+
+
+
+
+
+ +
+

Nama Acara

+ ( + + )} + /> + {errors.title?.message && ( +

{errors.title.message}

+ )} +
+ +
+ + + +
+ Drag your file(s) or{" "} + + browse + +
+
Max 10 MB files are allowed
+
+ +
+

Deskripsi

+ ( +