- {/* Sidebar Kiri */}
Filter
- {/* Pencarian */}
- {/* Tahun & Bulan */}
- {/* Tanggal */}
- {/* Kategori */}
Kategori
@@ -119,57 +172,42 @@ const FilterPage = () => {
{/* Konten Kanan */}
-
-
-
Urutkan berdasarkan
-
-
+
+
+
+
Urutkan berdasarkan
+
+
-
- {dummyImage.map((image) => (
-
- router.push(generateLocalizedPath(`/image/detail/${image.id}`, String(locale)))} className="flex flex-col text-xs lg:text-sm p-0">
-
-
- {image.date} {image.time} |
518{" "}
-
{" "}
-
- {image.title}
-
-
- ))}
+
+ {imageData?.map((image: any) => (
+
+
+
+
+
+ {formatDateToIndonesian(new Date(image?.createdAt))} {image?.timezone ? image?.timezone : "WIB"}|
+ {image?.clickCount}{" "}
+
{" "}
+
+ {image?.title}
+
+
+
+ ))}
+
+
-
+
-
-
-
-
-
-
- 1
-
-
-
- 2
-
-
-
- 3
-
-
-
-
-
-
-
-
-
);
};
diff --git a/app/[locale]/(public)/indeks/detail/[slug]/page.tsx b/app/[locale]/(public)/indeks/detail/[slug]/page.tsx
index 8f1faeee..8d00a23e 100644
--- a/app/[locale]/(public)/indeks/detail/[slug]/page.tsx
+++ b/app/[locale]/(public)/indeks/detail/[slug]/page.tsx
@@ -1,129 +1,71 @@
"use client";
-import { Card, CardContent } from "@/components/ui/card";
-import { Carousel, CarouselContent, CarouselItem, CarouselNext, CarouselPrevious } from "@/components/ui/carousel";
import { Textarea } from "@/components/ui/textarea";
-import Link from "next/link";
-import { usePathname, useRouter } from "next/navigation";
-import React, { useState } from "react";
-import { textEllipsis } from "@/utils/globals";
-
-const dummyImage = [
- {
- id: 1,
- title: "Giat Polri",
- thumbnail: "/assets/banner-sample.png",
- htmlDescription:
- "Lorem ipsum dolor sit amet consectetur, adipisicing elit. Quia ratione qui quidem, saepe blanditiis vero reiciendis commodi adipisci libero voluptatum, nisi eum hic quis dolorem, et aperiam consectetur perspiciatis error optio rem dolores tempore ducimus quos officia! Dicta odio dolorem quam necessitatibus libero mollitia reiciendis? Veniam, fugit incidunt? Quidem, consectetur.",
- },
- {
- id: 2,
- title: "Giat Polri",
- thumbnail: "https://mediahub.polri.go.id/api/media/categories/view-thumbnail?id=125¤tMilis=1732769540018",
- htmlDescription:
- "Lorem ipsum dolor sit amet consectetur, adipisicing elit. Quia ratione qui quidem, saepe blanditiis vero reiciendis commodi adipisci libero voluptatum, nisi eum hic quis dolorem, et aperiam consectetur perspiciatis error optio rem dolores tempore ducimus quos officia! Dicta odio dolorem quam necessitatibus libero mollitia reiciendis? Veniam, fugit incidunt? Quidem, consectetur.",
- },
- {
- id: 3,
- title: "Giat Polri",
- thumbnail: "https://mediahub.polri.go.id/api/media/categories/view-thumbnail?id=128¤tMilis=1732769540018",
- htmlDescription:
- "Lorem ipsum dolor sit amet consectetur, adipisicing elit. Quia ratione qui quidem, saepe blanditiis vero reiciendis commodi adipisci libero voluptatum, nisi eum hic quis dolorem, et aperiam consectetur perspiciatis error optio rem dolores tempore ducimus quos officia! Dicta odio dolorem quam necessitatibus libero mollitia reiciendis? Veniam, fugit incidunt? Quidem, consectetur.",
- },
- {
- id: 4,
- thumbnail: "https://mediahub.polri.go.id/api/media/categories/view-thumbnail?id=127¤tMilis=1732769540018",
- htmlDescription:
- "Lorem ipsum dolor sit amet consectetur, adipisicing elit. Quia ratione qui quidem, saepe blanditiis vero reiciendis commodi adipisci libero voluptatum, nisi eum hic quis dolorem, et aperiam consectetur perspiciatis error optio rem dolores tempore ducimus quos officia! Dicta odio dolorem quam necessitatibus libero mollitia reiciendis? Veniam, fugit incidunt? Quidem, consectetur.",
- },
- {
- id: 5,
- title: "Giat Polri",
- thumbnail: "https://mediahub.polri.go.id/api/media/categories/view-thumbnail?id=93¤tMilis=1732769540018",
- htmlDescription:
- "Lorem ipsum dolor sit amet consectetur, adipisicing elit. Quia ratione qui quidem, saepe blanditiis vero reiciendis commodi adipisci libero voluptatum, nisi eum hic quis dolorem, et aperiam consectetur perspiciatis error optio rem dolores tempore ducimus quos officia! Dicta odio dolorem quam necessitatibus libero mollitia reiciendis? Veniam, fugit incidunt? Quidem, consectetur.",
- },
-];
-
-const dummyData = {
- id: 12312,
- title: "TITLE",
- createdBy: "Mabes",
- createdAt: "21-21-2021",
- time: "18:23",
- desc: "halooo",
- htmlDescription:
- '
Polres Kobar - Polres Kotawaringin Barat (Kobar) memberikan bantuan sosial kepada warga yang berada di Daerah Aliran Sungai (DAS) Arut khususnya yang terdampak banjir, Sabtu (30/11/2024) pagi.
Kapolda Kalteng Irjen Pol Drs. Djoko Poerwanto melalui Kapolres Kobar AKBP Yusfandi Usman, S.I.K., M.I.K., menjelaskan bahwa pihaknya membagikan 200 paket sembako sebagai bentuk kepedulian kepada masyarakat.
"Saya bersama personel turun langsung membagikan bantuan berupa paket sembako yang diserahkan kepada masyarakat sekaligus monitoring ke lokasi pinggiran sungai yang mulai sebagain terdampak banjir akibat curah hujan tinggi,” ungkap Kapolres.
Lebih lanjut, orang nomor satu di Polres Kobar ini, mengungkapkan kegiatan tersebut dilakukan dalam rangka tanggap waspada dan antisipasi bencana banjir di wilayah Kabupaten Kobar.
“Kami minta masyarakat tetap waspada banjir menyikapi cuaca yang berubah-ubah saat ini, tidak menutup kemungkinan bertambahnya volume air sungai, jika diguyur hujan terus menerus,” jelasnya.
',
-};
+import { useParams, usePathname, useRouter } from "next/navigation";
+import React, { useEffect, useState } from "react";
+import NewContent from "@/components/landing-page/new-content";
+import { Link } from "@/i18n/routing";
+import { getDetailIndeks } from "@/service/landing/landing";
+import { formatDateToIndonesian } from "@/utils/globals";
const IndeksDetail = () => {
- const [selectedSize, setSelectedSize] = useState
("L");
- const [selectedTab, setSelectedTab] = useState("video");
- const router = useRouter();
- const pathname = usePathname();
+ const [indeksData, setIndeksData] = useState();
+ const params = useParams();
+ const slug = params?.slug;
+
+ useEffect(() => {
+ initFetch();
+ }, []);
+ const initFetch = async () => {
+ const response = await getDetailIndeks();
+ console.log(response);
+ setIndeksData(response?.data?.data?.content);
+ };
return (
-
- {/* Judul */}
-
-
INDEKS / DETAIL
- {dummyData.title}
-
- {/* Gambar Utama */}
-
-

-
- {/* Footer Informasi */}
-
-
- oleh {dummyData.createdBy} | Diupdate pada {dummyData.createdAt} {dummyData.time} WIB | 👁️ 65
-
+ <>
+
+ {/* Judul */}
+
+
{indeksData?.title}
+
+ {/* Gambar Utama */}
+
+

+
+ {/* Footer Informasi */}
+
+
+ {formatDateToIndonesian(new Date(indeksData?.createdAt))} {indeksData?.timezone ? indeksData?.timezone : "WIB"}|{" "}
+ {" "}
+ {indeksData?.clickCount}
+
+
+
+ {/* Keterangan */}
+
- {/* Keterangan */}
-
-
- {/* Comment */}
-
-
Berikan Komentar
-
-
-
-
- {/* Konten Serupa */}
-
-
-
Post Terkait
-
-
-
-
- {dummyImage.map((image) => (
-
-
-
-
- {image.title}
- {textEllipsis(image.htmlDescription, 100)}
-
-
-
- ))}
-
-
-
-
-
+ {/* Comment */}
+
+
Berikan Komentar
+
+
-
-
- LIHAT SEMUA
-
+
+ {/* Konten Serupa */}
+
+
-
+ >
);
};
diff --git a/app/[locale]/(public)/indeks/page.tsx b/app/[locale]/(public)/indeks/page.tsx
index 8543e2a3..cf0057ab 100644
--- a/app/[locale]/(public)/indeks/page.tsx
+++ b/app/[locale]/(public)/indeks/page.tsx
@@ -1,107 +1,116 @@
"use client";
-import Link from "next/link";
+import { Link } from "@/i18n/routing";
+import { getIndeksData } from "@/service/landing/landing";
+import { formatDateToIndonesian } from "@/utils/globals";
import { usePathname } from "next/navigation";
-import React from "react";
+import React, { useEffect, useState } from "react";
-interface ImageCardProps {
- imageUrl: string;
- label: string;
- title: string;
- date: string;
-}
+const Indeks: React.FC = () => {
+ const pathname = usePathname();
+ const [indeksData, setIndeksData] = useState
();
+ let count: number = 0;
+ useEffect(() => {
+ if (indeksData) {
+ const intervalId = setInterval(() => {
+ count = (count + 1) % indeksData.length;
+ }, 5000);
+
+ return () => clearInterval(intervalId);
+ }
+ }, [indeksData]);
+
+ useEffect(() => {
+ initFetch();
+ }, []);
+ const initFetch = async () => {
+ const response = await getIndeksData();
+ console.log(response);
+ setIndeksData(response?.data?.data?.content);
+ };
-const ImageCard: React.FC = ({ imageUrl, label, title, date }) => {
return (
-
-

-
-
{label}
-
{title}
-
{date}
+
+ {/* Hero Left */}
+
+
+ {indeksData?.map(
+ (indeks: any, index: number) =>
+ index == count && (
+
+

+
+
{indeks?.categoryName}
+
+
{indeks?.title}
+
+
+ {formatDateToIndonesian(new Date(indeks?.createdAt))} {indeks?.timezone ? indeks?.timezone : "WIB"}|{" "}
+ {" "}
+ {indeks?.clickCount}
+
+
+
+ )
+ )}
+
+
+ {/* Hero Right */}
+
+ {indeksData?.map(
+ (indeksRight: any, index: number) =>
+ (index == count + 1 || index == count + 2) && (
+
+

+
+
{indeksRight?.categoryName}
+
+
{indeksRight?.title}
+
+
+ {formatDateToIndonesian(new Date(indeksRight?.createdAt))} {indeksRight?.timezone ? indeksRight?.timezone : "WIB"}|{" "}
+ {" "}
+ {indeksRight?.clickCount}
+
+
+
+ )
+ )}
+
+
+
+ {/* Bottom */}
+
+
+ {indeksData?.map(
+ (indeksBottom: any, index: number) =>
+ index < 3 && (
+
+

+
+
{indeksBottom?.date}
+
+ {indeksBottom?.title}
+
+
{indeksBottom?.description}
+
+
+ )
+ )}
+
);
};
-const ImageGallery: React.FC = () => {
- const pathname = usePathname();
-
- const images = [
- {
- imageUrl: "/assets/banner-sample.png",
- label: "Giat Pimpinan",
- title: "Foto Kapolri Dorong Transformasi Polri Presisi",
- date: "2024-11-12 10:09:20 WIB",
- },
- {
- imageUrl: "/assets/hot-topik-1.jpg",
- label: "Giat Polri",
- title: "Foto Kapolri Tinjau Pengungsi Gunung",
- date: "2024-11-19 09:35:27 WIB",
- },
- {
- imageUrl: "/assets/hot-topik-2.jpg",
- label: "Giat Polri",
- title: "Foto Kapolri dalam Acara Bersama TNI",
- date: "2024-11-20 15:45:00 WIB",
- },
- ];
-
- const imageBottom = [
- {
- id: 1,
- imageUrl: "/assets/hot-topik-1.jpg",
- title: "Foto Kakorlantas Polri Tekankan Intervensi",
- description:
- "Kepala Korps Lalu Lintas (Kakorlantas) Polri Irjen. Pol. Dr. Drs. Aan Suhanan, M.Si. memimpin apel pagi di NTMC pada Senin (2/12/2024) dan menekankan pentingnya pengelolaan ekstra dalam pengamanan Natal dan Tahun Baru 2024.",
- },
- {
- id: 2,
- imageUrl: "/assets/hot-topik-1.jpg",
- title: "Foto Kakorlantas Tinjau Jalur Tol, Jalur Wisata",
- description: "Kakorlantas Polri Irjen.Pol. Dr. Drs. Aan Suhanan, M.Si. memimpin survei jalur tol dari Cikopo, Purwakarta hingga Kalikangkung, Jawa Tengah, untuk persiapan Operasi Lilin 2024.",
- },
- {
- id: 3,
- imageUrl: "/assets/hot-topik-2.jpg",
- title: "Foto Kapolri Pastikan Kesiapan Polri Kawal Pilkada",
- description: "Kapolri Jenderal Polisi Drs. Listyo Sigit Prabowo, M.Si menegaskan kesiapan Polri dalam mengawal Pilkada Serentak 2024 yang digelar Rabu, 27 November 2024.",
- },
- ];
-
- return (
- <>
- {/* Hero */}
-
- {/* Bottom */}
-
-
- {imageBottom.map((image) => (
-
-
-

-
-
-
- {image.title}
-
-
{image.description}
-
-
- ))}
-
-
- >
- );
-};
-
-export default ImageGallery;
+export default Indeks;
diff --git a/app/[locale]/(public)/schedule/page.tsx b/app/[locale]/(public)/schedule/page.tsx
index 371a1fce..1a7be29d 100644
--- a/app/[locale]/(public)/schedule/page.tsx
+++ b/app/[locale]/(public)/schedule/page.tsx
@@ -9,64 +9,149 @@ import { format } from "date-fns";
import { cn } from "@/lib/utils";
import { Checkbox } from "@/components/ui/checkbox";
import { Icon } from "@iconify/react/dist/iconify.js";
+import { listSchedule, listScheduleNextPublic, listSchedulePrevPublic, listScheduleTodayPublic } from "@/service/schedule/schedule";
+import { useRouter } from "@/i18n/routing";
+import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "@/components/ui/collapsible";
+import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, AlertDialogTrigger } from "@/components/ui/alert-dialog";
+import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from "@/components/ui/accordion";
+
+const timeList = [
+ {
+ id: "6",
+ time: "06:00",
+ },
+ {
+ id: "7",
+ time: "07:00",
+ },
+ {
+ id: "8",
+ time: "08:00",
+ },
+ {
+ id: "9",
+ time: "09:00",
+ },
+ {
+ id: "10",
+ time: "10:00",
+ },
+ {
+ id: "11",
+ time: "11:00",
+ },
+ {
+ id: "12",
+ time: "12:00",
+ },
+ {
+ id: "13",
+ time: "13:00",
+ },
+ {
+ id: "14",
+ time: "14:00",
+ },
+ {
+ id: "15",
+ time: "15:00",
+ },
+ {
+ id: "16",
+ time: "16:00",
+ },
+ {
+ id: "17",
+ time: "17:00",
+ },
+ {
+ id: "18",
+ time: "18:00",
+ },
+ {
+ id: "19",
+ time: "19:00",
+ },
+ {
+ id: "20",
+ time: "20:00",
+ },
+ {
+ id: "21",
+ time: "21:00",
+ },
+ {
+ id: "22",
+ time: "22:00",
+ },
+ {
+ id: "23",
+ time: "23:00",
+ },
+ {
+ id: "24",
+ time: "24:00",
+ },
+ {
+ id: "1",
+ time: "01:00",
+ },
+ {
+ id: "2",
+ time: "02:00",
+ },
+ {
+ id: "3",
+ time: "03:00",
+ },
+ {
+ id: "4",
+ time: "04:00",
+ },
+ {
+ id: "5",
+ time: "05:00",
+ },
+];
const Schedule = () => {
- const city = [
- {
- key: 1,
- id: "metro-jaya",
- name: "Polda Metro Jaya",
- },
- {
- key: 2,
- id: "jawa-barat",
- name: "Polda Jawa Barat",
- },
- {
- key: 3,
- id: "banten",
- name: "Polda Banten",
- },
- {
- key: 4,
- id: "jawa-tengah",
- name: "Polda Jawa Tengah",
- },
- {
- key: 5,
- id: "daerah-istimewa-yogyakarta",
- name: "Polda D.I Yogyakarta",
- },
- {
- key: 6,
- id: "jawa-timur",
- name: "Polda Jawa Timur",
- },
- {
- key: 7,
- id: "aceh",
- name: "Polda Aceh",
- },
- {
- key: 8,
- id: "sumatera-utara",
- name: "Polda Sumatera Utara",
- },
- {
- key: 9,
- id: "sumatera-barat",
- name: "Polda Sumatera Barat",
- },
- ];
-
- const days = ["S", "S", "R", "K", "J", "S", "M"];
-
- const months = ["Januari", "Februari", "Maret", "April", "Mei", "Juni", "Juli", "Agustus", "September", "Oktober", "November", "Desember"];
-
+ const router = useRouter();
const [startDate, setStartDate] = useState
(new Date());
const [dateAWeek, setDateAWeek] = useState([]);
const [scheduleSearch, setScheduleSearch] = useState();
const [todayList, setTodayList] = useState([]);
+ const [prevdayList, setPrevdayList] = useState([]);
+ const [nextdayList, setNextdayList] = useState([]);
+ const [isOpen, setIsOpen] = React.useState(false);
+ const [schedules, setSchedules] = useState([]);
+ const [openDialog, setOpenDialog] = useState(false);
+
+ useEffect(() => {
+ async function initState() {
+ getDataByDate();
+ // const group = isPolda ? asPath.split("/")[2] : regionFilter?.join(",");
+ const resSchedule = await listSchedule();
+ setSchedules(resSchedule.data?.data);
+ console.log(resSchedule);
+ setDateAWeek(dateList);
+ }
+
+ initState();
+ }, []);
+
+ async function getDataByDate() {
+ const resToday = await listScheduleTodayPublic();
+ const today = resToday.data?.data;
+ setTodayList(today);
+ const resNext = await listScheduleNextPublic();
+ const next = resNext.data?.data;
+
+ setNextdayList(next);
+ const resPrev = await listSchedulePrevPublic();
+ const prev = resPrev.data?.data;
+
+ setPrevdayList(prev);
+ }
const curr = new Date();
const startDays = (curr.getDay() + 7 - 1) % 7;
@@ -80,14 +165,6 @@ const Schedule = () => {
}
const [dateList, setDateList] = useState(dateListInit);
- useEffect(() => {
- async function initState() {
- setDateAWeek(dateList);
- }
-
- initState();
- }, []);
-
const handleChangeDate = (date: Date | undefined) => {
setStartDate(date);
const dateListTemp = [];
@@ -179,17 +256,64 @@ const Schedule = () => {
}
};
- const categories = [
- { id: 1, title: "POLDA METRO JAYA" },
- { id: 2, title: "POLDA JAWA BARAT" },
- { id: 3, title: "POLDA BANTEN" },
- { id: 4, title: "POLDA JAWA TENGAH" },
- { id: 5, title: "POLDA D.I YOGYAKARTA" },
- { id: 6, title: "POLDA JAWA TIMUR" },
- { id: 7, title: "POLDA ACEH" },
- { id: 8, title: "POLDA SUMATERA UTARA" },
- { id: 9, title: "POLDA SUMATERA BARAT" },
- ];
+ const getItem = (itemFound: any) => {
+ setOpenDialog(true);
+ };
+
+ function setItemSchedule(id: string, date: string) {
+ const itemFound: any = schedules?.filter((s: any) => s.dateInRange.includes(date) && s.timeIndex.split(",").includes(id));
+
+ if (itemFound?.length > 0) {
+ if (itemFound?.length == 1) {
+ return (
+ {
+ getItem(itemFound[0]);
+ }}
+ >
+
+ {itemFound[0]?.title}
+
+ {itemFound[0].isYoutube == true ? LIVE
: ""}
+ {/* {itemFound[0].address}
*/}
+
+ );
+ }
+
+ // for (let i = 0; i < itemFound.length; i++) {
+ // const item = itemFound[i];
+ // }
+ return (
+
+
+ {`${itemFound?.length} Jadwal Bersamaan`}
+
+
+ Lihat Jadwal
+
+ {itemFound?.map((list: any) => (
+ {
+ getItem(itemFound[0]);
+ }}
+ >
+
+ {list.title}
+
+ {list.isYoutube == true ? LIVE
: ""}
+ {/* {list.address}
*/}
+
+ ))}
+
+
+
+
+ );
+ }
+ }
return (
<>
@@ -286,315 +410,72 @@ const Schedule = () => {
| Time Table |
-
- changePrevWeek()}>
+ | changePrevWeek()}
+ className={`text-center cursor-pointer border h-full border-gray-100 dark:border-gray-700 py-6 min-w-[100px] ${new Date().toISOString().slice(0, 10) == dateAWeek[0] ? "bg-red-600 text-white" : ""}`}
+ >
+ {/*
- {" "}
-
- {dateAWeek[0]?.split("-")[2]}
+ {" "} */}
+
+ {dateAWeek[0]?.split("-")[2]}
Monday
|
-
- {dateAWeek[1]?.split("-")[2]} Tuesday
+ |
+ {dateAWeek[1]?.split("-")[2]} Tuesday
|
-
- {dateAWeek[2]?.split("-")[2]} Wednesday
+ |
+ {dateAWeek[2]?.split("-")[2]} Wednesday
|
-
- {dateAWeek[3]?.split("-")[2]} Thursday
+ |
+ {dateAWeek[3]?.split("-")[2]} Thursday
|
-
- {dateAWeek[4]?.split("-")[2]} Friday
+ |
+ {dateAWeek[4]?.split("-")[2]} Friday
|
-
- {dateAWeek[5]?.split("-")[2]} Saturday
+ |
+ {dateAWeek[5]?.split("-")[2]} Saturday
|
-
+ | changeNextWeek()}
+ className={`text-center border cursor-pointer border-gray-100 dark:border-gray-700 py-6 min-w-[100px] ${new Date().toISOString().slice(0, 10) == dateAWeek[6] ? "bg-[#BE0106] text-white rounded-lg" : ""}`}
+ >
- {dateAWeek[6]?.split("-")[2]}
+ {dateAWeek[6]?.split("-")[2]}
Sunday
- changeNextWeek()} className="cursor-pointer h-fit p-0 m-0 self-center">
+ {/*
-
+ */}
|
-
- | 06:00 |
- |
- |
- |
- |
- |
- |
- |
-
-
-
- | 07:00 |
- |
- |
- |
- |
- |
- |
- |
-
-
-
- | 08:00 |
- |
- |
- |
- |
- |
- |
- |
-
-
-
- | 09:00 |
- |
- |
- |
- |
- |
- |
- |
-
-
-
- | 10:00 |
- |
- |
- |
- |
- |
- |
- |
-
-
-
- | 11:00 |
- |
- |
- |
- |
- |
- |
- |
-
-
-
- | 12:00 |
- |
- |
- |
- |
- |
- |
- |
-
-
-
- | 13:00 |
- |
- |
- |
- |
- |
- |
- |
-
-
-
- | 14:00 |
- |
- |
- |
- |
- |
- |
- |
-
-
-
- | 15:00 |
- |
- |
- |
- |
- |
- |
- |
-
-
-
- | 16:00 |
- |
- |
- |
- |
- |
- |
- |
-
-
-
- | 17:00 |
- |
- |
- |
- |
- |
- |
- |
-
-
-
- | 18:00 |
- |
- |
- |
- |
- |
- |
- |
-
-
-
- | 19:00 |
- |
- |
- |
- |
- |
- |
- |
-
-
-
- | 20:00 |
- |
- |
- |
- |
- |
- |
- |
-
-
-
- | 21:00 |
- |
- |
- |
- |
- |
- |
- |
-
-
-
- | 22:00 |
- |
- |
- |
- |
- |
- |
- |
-
-
-
- | 23:00 |
- |
- |
- |
- |
- |
- |
- |
-
-
-
- | 24:00 |
- |
- |
- |
- |
- |
- |
- |
-
-
-
- | 01:00 |
- |
- |
- |
- |
- |
- |
- |
-
-
-
- | 02:00 |
- |
- |
- |
- |
- |
- |
- |
-
-
-
- | 03:00 |
- |
- |
- |
- |
- |
- |
- |
-
-
-
- | 04:00 |
- |
- |
- |
- |
- |
- |
- |
-
-
-
- | 05:00 |
- |
- |
- |
- |
- |
- |
- |
-
+ {timeList.map((times) => (
+
+ | {times.time} |
+ {setItemSchedule(times.id, dateList[0])} |
+ {setItemSchedule(times.id, dateList[1])} |
+ {setItemSchedule(times.id, dateList[2])} |
+ {setItemSchedule(times.id, dateList[3])} |
+ {setItemSchedule(times.id, dateList[4])} |
+ {setItemSchedule(times.id, dateList[5])} |
+ {setItemSchedule(times.id, dateList[6])} |
+
+ ))}
+
+ {/* Component Kanan */}
@@ -607,45 +488,214 @@ const Schedule = () => {
-
-
-
+
+ {/* jadwal hari ini */}
+ {/*
+
+
+ Jadwal Hari Ini
+
+
+
+
+
+ {todayList?.map((list: any) => (
+
+ {new Date(list.startDate).getDate()}
+
+
{list?.title}
+
+
+ {list?.startTime} - {list?.endTime} WIB
+
+
+
+ {list?.address}
+
+
Pembicara :
+
+
+ {list?.speakerTitle} {list?.speakerName}
+
+
+
+ ))}
+ */}
+
+
+ Jadwal Sebelumnya
+ {prevdayList?.map((list: any) => (
+
+ {new Date(list.startDate).getDate()}
+
+
{list?.title}
+
+
+ {list?.startTime} - {list?.endTime} WIB
+
+
+
+ {list?.address}
+
+
Pembicara :
+
+
+ {list?.speakerTitle} {list?.speakerName}
+
+
+
+ ))}
+
+
+
+ Jadwal Hari ini
+ {todayList?.map((list: any) => (
+
+ {new Date(list.startDate).getDate()}
+
+
{list?.title}
+
+
+ {list?.startTime} - {list?.endTime} WIB
+
+
+
+ {list?.address}
+
+
Pembicara :
+
+
+ {list?.speakerTitle} {list?.speakerName}
+
+
+
+ ))}
+
+
+
+ Jadwal Selanjutnya
+ {nextdayList?.map((list: any) => (
+
+ {new Date(list.startDate).getDate()}
+
+
{list?.title}
+
+
+ {list?.startTime} - {list?.endTime} WIB
+
+
+
+ {list?.address}
+
+
Pembicara :
+
+
+ {list?.speakerTitle} {list?.speakerName}
+
+
+
+ ))}
+
+
+
+ {/* jadwal sebelumnya */}
+ {/*
+
+
+ Jadwal Sebelumnya
+
+
+
+
+
+ {prevdayList?.map((list: any) => (
+
+ {new Date(list.startDate).getDate()}
+
+
{list?.title}
+
+
+ {list?.startTime} - {list?.endTime} WIB
+
+
+
+ {list?.address}
+
+
Pembicara :
+
+
+ {list?.speakerTitle} {list?.speakerName}
+
+
+
+ ))}
+ */}
+
+ {/* jadwal selanjutnya */}
+ {/*
+
+
+ Jadwal Selanjutnya
+
+
+
+
+
+ {nextdayList?.map((list: any) => (
+
+ {new Date(list.startDate).getDate()}
+
+
{list?.title}
+
+
+ {list?.startTime} - {list?.endTime} WIB
+
+
+
+ {list?.address}
+
+
Pembicara :
+
+
+ {list?.speakerTitle} {list?.speakerName}
+
+
+
+ ))}
+ */}
+
+
+
+
+ Test Event
+
+
+
+ 08.00 - 12.00 WIB
+
+
+
+
+
+ Jl. Trunojoyo No.3 2, RT.2/RW.1, Selong, Kec. Kby. Baru, Kota Jakarta Selatan, Daerah Khusus Ibukota Jakarta 12110, Indonesia.
+
+
+
+
+
+ Hanif Salafi
+
+
+
+
+ Cancel
+ Continue
+
+
+
>
);
};
diff --git a/app/[locale]/(public)/video/detail/[slug]/page.tsx b/app/[locale]/(public)/video/detail/[slug]/page.tsx
index 9c135339..ad5742b5 100644
--- a/app/[locale]/(public)/video/detail/[slug]/page.tsx
+++ b/app/[locale]/(public)/video/detail/[slug]/page.tsx
@@ -1,53 +1,15 @@
"use client";
-import { Card, CardContent } from "@/components/ui/card";
-import { Carousel, CarouselContent, CarouselItem, CarouselNext, CarouselPrevious } from "@/components/ui/carousel";
-import { Tabs, TabsList, TabsTrigger } from "@/components/ui/tabs";
-import { Textarea } from "@/components/ui/textarea";
-import Link from "next/link";
+
+
import { useParams, usePathname, useRouter } from "next/navigation";
-import React, { useState } from "react";
+import React, { useEffect, useState } from "react";
import { Icon } from "@iconify/react/dist/iconify.js";
-import { textEllipsis } from "@/utils/globals";
+import { getDetail } from "@/service/landing/landing";
+import VideoPlayer from "@/utils/video-player";
+import NewContent from "@/components/landing-page/new-content";
+import { Link } from "@/i18n/routing";
+import { Textarea } from "@/components/ui/textarea";
-const dummyImage = [
- { id: 1, thumbnail: "/assets/banner-sample.png" },
- { id: 2, thumbnail: "https://mediahub.polri.go.id/api/media/categories/view-thumbnail?id=125¤tMilis=1732769540018" },
- { id: 3, thumbnail: "https://mediahub.polri.go.id/api/media/categories/view-thumbnail?id=128¤tMilis=1732769540018" },
- { id: 4, thumbnail: "https://mediahub.polri.go.id/api/media/categories/view-thumbnail?id=127¤tMilis=1732769540018" },
- { id: 5, thumbnail: "https://mediahub.polri.go.id/api/media/categories/view-thumbnail?id=93¤tMilis=1732769540018" },
-];
-
-const dummyData = {
- id: 12312,
- title: "TITLE",
- createdBy: "Mabes",
- createdAt: "21-21-2021",
- time: "18:23",
- desc: "sdaasd",
- htmlDescription:
- '
Polres Kobar - Polres Kotawaringin Barat (Kobar) memberikan bantuan sosial kepada warga yang berada di Daerah Aliran Sungai (DAS) Arut khususnya yang terdampak banjir, Sabtu (30/11/2024) pagi.
Kapolda Kalteng Irjen Pol Drs. Djoko Poerwanto melalui Kapolres Kobar AKBP Yusfandi Usman, S.I.K., M.I.K., menjelaskan bahwa pihaknya membagikan 200 paket sembako sebagai bentuk kepedulian kepada masyarakat.
"Saya bersama personel turun langsung membagikan bantuan berupa paket sembako yang diserahkan kepada masyarakat sekaligus monitoring ke lokasi pinggiran sungai yang mulai sebagain terdampak banjir akibat curah hujan tinggi,” ungkap Kapolres.
Lebih lanjut, orang nomor satu di Polres Kobar ini, mengungkapkan kegiatan tersebut dilakukan dalam rangka tanggap waspada dan antisipasi bencana banjir di wilayah Kabupaten Kobar.
“Kami minta masyarakat tetap waspada banjir menyikapi cuaca yang berubah-ubah saat ini, tidak menutup kemungkinan bertambahnya volume air sungai, jika diguyur hujan terus menerus,” jelasnya.
',
-};
-
-const dummyImageContent = [
- { id: 1, thumbnail: "/assets/banner-sample.png", date: "17 MEI 2024", title: "Kapolres Batam Berikan pengarahan pagi kepada para anggota dan staf yang terkait", time: "18.00 WIB" },
- { id: 2, thumbnail: "/assets/banner-sample.png", date: "17 MEI 2024", title: "Kapolres Batam Berikan pengarahan pagi kepada para anggota dan staf yang terkait", time: "18.00 WIB" },
- { id: 3, thumbnail: "/assets/banner-sample.png", date: "17 MEI 2024", title: "Kapolres Batam Berikan pengarahan pagi kepada para anggota dan staf yang terkait", time: "18.00 WIB" },
- { id: 4, thumbnail: "/assets/banner-sample.png", date: "17 MEI 2024", title: "Kapolres Batam Berikan pengarahan pagi kepada para anggota dan staf yang terkait", time: "18.00 WIB" },
- { id: 5, thumbnail: "/assets/banner-sample.png", date: "17 MEI 2024", title: "Kapolres Batam Berikan pengarahan pagi kepada para anggota dan staf yang terkait", time: "18.00 WIB" },
- { id: 6, thumbnail: "/assets/banner-sample.png", date: "17 MEI 2024", title: "Kapolres Batam Berikan pengarahan pagi kepada para anggota dan staf yang terkait", time: "18.00 WIB" },
- { id: 7, thumbnail: "/assets/banner-sample.png", date: "17 MEI 2024", title: "Kapolres Batam Berikan pengarahan pagi kepada para anggota dan staf yang terkait", time: "18.00 WIB" },
- { id: 8, thumbnail: "/assets/banner-sample.png", date: "17 MEI 2024", title: "Kapolres Batam Berikan pengarahan pagi kepada para anggota dan staf yang terkait", time: "18.00 WIB" },
- { id: 9, thumbnail: "/assets/banner-sample.png", date: "17 MEI 2024", title: "Kapolres Batam Berikan pengarahan pagi kepada para anggota dan staf yang terkait", time: "18.00 WIB" },
-];
-
-const dummyDescription = [
- { id: 1, title: "Kapolres Batam Berikan pengarahan pagi kepada para anggota dan staf yang terkait", date: "28 November 2024", time: "11.15 WIB", duration: "00:24:55" },
- { id: 2, title: "Kapolres Lahat Himbau Cipta Kondisi Cooling System Pasca Pemungutan Suara Pilkada 2024", date: "28 November 2024", time: "11.15 WIB", duration: "00:24:55" },
- { id: 3, title: "17 Ton Pupuk Bersubsidi yang Akan Diselewengkan ke Banyuasin Berhasil Digagalkan", date: "28 November 2024", time: "11.15 WIB", duration: "00:24:55" },
- { id: 4, title: "Kapolda Sumsel Apelkan 1471 Personel Persiapan Pengamanan Pengawalan Tahan Pungut dan Hitung Suara", date: "28 November 2024", time: "11.15 WIB", duration: "00:24:55" },
- { id: 5, title: "Polrestabes Palembang Berhasil Mengungkap Kasus Penganiayaan Berat di Ilir Barat II", date: "28 November 2024", time: "11.15 WIB", duration: "00:24:55" },
- { id: 6, title: "Tahapan Pilkada di Sumsel Berlangsung Kondusif", date: "28 November 2024", time: "11.15 WIB", duration: "00:24:55" },
-];
const DetailVideo = () => {
const [selectedSize, setSelectedSize] = useState
("L");
@@ -55,7 +17,18 @@ const DetailVideo = () => {
const router = useRouter();
const pathname = usePathname();
const params = useParams();
- const locale = params?.locale;
+ const slug = params?.slug;
+ const [detailDataVideo, setDetailDataVideo] = useState();
+
+ useEffect(() => {
+ initFetch();
+ }, []);
+
+ const initFetch = async () => {
+ const response = await getDetail(String(slug));
+ console.log("detailVideo", response);
+ setDetailDataVideo(response?.data?.data);
+ };
const sizes = [
{ label: "XL", value: "3198 x 1798 px" },
@@ -66,264 +39,105 @@ const DetailVideo = () => {
];
return (
-
- {/* Container Utama */}
-
- {/* Bagian Kiri */}
-
- {/* Gambar Utama */}
-
-

-
+ <>
+
+ {/* Container Utama */}
+
+ {/* Bagian Kiri */}
+
- {/* Thumbnail */}
-
- {[1, 2, 3, 4].map((_, index) => (
-

- ))}
-
-
+ {/* Bagian Kanan */}
+
+
+ {/* garis */}
+
- {/* Bagian Kanan */}
-
-
- {/* garis */}
-
+
+ {detailDataVideo?.category?.name}
+
-
- OPS MANTAP PRAJA & PILKADA 2024
-
+
+
poldajabar
+
pilkadamai2024
+
-
-
poldajabar
-
pilkadamai2024
-
+
-
+ {/* Opsi Ukuran Foto */}
+
Opsi Ukuran Foto
- {/* Opsi Ukuran Foto */}
-
Opsi Ukuran Foto
+
-
+
+ {sizes.map((size) => (
+
+ ))}
+
-
- {/* Download Semua */}
-
-
-
-
- {/* Tombol Download */}
-
-
-
-
- {/* Footer Informasi */}
-
-
- oleh {dummyData.createdBy} | Diupdate pada {dummyData.createdAt} {dummyData.time} WIB | 👁️ 65
-
-
Kreator: poppy-PID-poldajabar
-
-
- {/* Keterangan */}
-
-
- {/* Comment */}
-
-
Berikan Komentar
-
-
-
-
- {/* Konten Serupa */}
-
-
-
-
- Konten Terbaru
-
-
-
-
- Audio Visual
-
-
- Audio
-
-
- Foto
-
-
- Teks
-
-
-
-
-
- {selectedTab == "video" ? (
-
-
- {dummyImageContent.map((image) => (
-
-
-
- {image.date} {image.time} |
518{" "}
-
{" "}
-
- {image.title}
-
- ))}
-
-
-
-
- ) : selectedTab == "audio" ? (
-
-
- {dummyDescription.map((description) => (
-
-
-
- ))}
-
-
-
-
- ) : selectedTab == "image" ? (
-
-
- {dummyImageContent.map((image) => (
-
-
-
- {image.date} {image.time} |
518{" "}
-
{" "}
-
- {image.title}
-
- ))}
-
-
-
-
- ) : (
-
-
- {dummyImageContent.map((description) => (
-
-
-
- ))}
-
-
-
-
- )}
+ {/* Tombol Download */}
+
-
-
- LIHAT SEMUA
-
+
+ {/* Footer Informasi */}
+
+
+ oleh {detailDataVideo?.uploadedBy?.userLevel?.name} | Diupdate pada {detailDataVideo?.updatedAt} WIB |
+
+
+ {detailDataVideo?.clickCount}
+
+
Kreator: {detailDataVideo?.creatorName}
+
+
+ {/* Keterangan */}
+
+
{detailDataVideo?.title}
+
-
+
+ {/* Comment */}
+
+
Berikan Komentar
+
+
+
+
+ {/* Konten Serupa */}
+
+
+
+
+ >
);
};
diff --git a/app/[locale]/(public)/video/filter/page.tsx b/app/[locale]/(public)/video/filter/page.tsx
index 2436984f..5954131d 100644
--- a/app/[locale]/(public)/video/filter/page.tsx
+++ b/app/[locale]/(public)/video/filter/page.tsx
@@ -1,20 +1,22 @@
"use client";
-import React, { useState } from "react";
-import { Pagination, PaginationContent, PaginationEllipsis, PaginationItem, PaginationLink, PaginationNext, PaginationPrevious } from "@/components/ui/pagination";
+import React, { useEffect, useState } from "react";
import { Card, CardContent } from "@/components/ui/card";
import { Checkbox } from "@/components/ui/checkbox";
import { Icon } from "@iconify/react/dist/iconify.js";
+import { getListContent } from "@/service/landing/landing";
+import { formatDateToIndonesian } from "@/utils/globals";
+import { useParams, usePathname, useRouter, useSearchParams } from "next/navigation";
+import { ColumnDef, ColumnFiltersState, PaginationState, SortingState, VisibilityState, flexRender, getCoreRowModel, getFilteredRowModel, getPaginationRowModel, getSortedRowModel, useReactTable } from "@tanstack/react-table";
+import LandingPagination from "@/components/landing-page/pagination";
+import { Reveal } from "@/components/landing-page/Reveal";
+import { Link } from "@/i18n/routing";
-const dummyImage = [
- { id: 1, thumbnail: "/assets/banner-sample.png", date: "17 MEI 2024", title: "Kapolres Batam Berikan pengarahan pagi kepada para anggota dan staf yang terkait", time: "18.00 WIB" },
- { id: 2, thumbnail: "/assets/banner-sample.png", date: "17 MEI 2024", title: "Kapolres Batam Berikan pengarahan pagi kepada para anggota dan staf yang terkait", time: "18.00 WIB" },
- { id: 3, thumbnail: "/assets/banner-sample.png", date: "17 MEI 2024", title: "Kapolres Batam Berikan pengarahan pagi kepada para anggota dan staf yang terkait", time: "18.00 WIB" },
- { id: 4, thumbnail: "/assets/banner-sample.png", date: "17 MEI 2024", title: "Kapolres Batam Berikan pengarahan pagi kepada para anggota dan staf yang terkait", time: "18.00 WIB" },
- { id: 5, thumbnail: "/assets/banner-sample.png", date: "17 MEI 2024", title: "Kapolres Batam Berikan pengarahan pagi kepada para anggota dan staf yang terkait", time: "18.00 WIB" },
- { id: 6, thumbnail: "/assets/banner-sample.png", date: "17 MEI 2024", title: "Kapolres Batam Berikan pengarahan pagi kepada para anggota dan staf yang terkait", time: "18.00 WIB" },
- { id: 7, thumbnail: "/assets/banner-sample.png", date: "17 MEI 2024", title: "Kapolres Batam Berikan pengarahan pagi kepada para anggota dan staf yang terkait", time: "18.00 WIB" },
- { id: 8, thumbnail: "/assets/banner-sample.png", date: "17 MEI 2024", title: "Kapolres Batam Berikan pengarahan pagi kepada para anggota dan staf yang terkait", time: "18.00 WIB" },
- { id: 9, thumbnail: "/assets/banner-sample.png", date: "17 MEI 2024", title: "Kapolres Batam Berikan pengarahan pagi kepada para anggota dan staf yang terkait", time: "18.00 WIB" },
+const columns: ColumnDef
[] = [
+ {
+ accessorKey: "no",
+ header: "No",
+ cell: ({ row }) => {row.getValue("no")},
+ },
];
const categories = [
@@ -39,6 +41,67 @@ const formatPicture = [
];
const FilterPage = () => {
+ const router = useRouter();
+ const pathname = usePathname();
+ const params = useParams();
+ const searchParams = useSearchParams();
+ const locale = params?.locale;
+ const [imageData, setImageData] = useState();
+ const [totalData, setTotalData] = React.useState(1);
+ const [totalPage, setTotalPage] = React.useState(1);
+ const [sorting, setSorting] = React.useState([]);
+ const [columnFilters, setColumnFilters] = React.useState([]);
+ const [columnVisibility, setColumnVisibility] = React.useState({});
+ const [rowSelection, setRowSelection] = React.useState({});
+ const [pagination, setPagination] = React.useState({
+ pageIndex: 0,
+ pageSize: 6,
+ });
+ const [page, setPage] = useState(1);
+
+ React.useEffect(() => {
+ const pageFromUrl = searchParams?.get("page");
+ if (pageFromUrl) {
+ setPage(Number(pageFromUrl));
+ }
+ }, [searchParams]);
+
+ const table = useReactTable({
+ data: imageData,
+ columns: columns,
+ onSortingChange: setSorting,
+ onColumnFiltersChange: setColumnFilters,
+ getCoreRowModel: getCoreRowModel(),
+ getPaginationRowModel: getPaginationRowModel(),
+ getSortedRowModel: getSortedRowModel(),
+ getFilteredRowModel: getFilteredRowModel(),
+ onColumnVisibilityChange: setColumnVisibility,
+ onRowSelectionChange: setRowSelection,
+ onPaginationChange: setPagination,
+ state: {
+ sorting,
+ columnFilters,
+ columnVisibility,
+ rowSelection,
+ pagination,
+ },
+ });
+
+ const [videoData, setVideoData] = useState();
+ useEffect(() => {
+ initFetch();
+ }, [page]);
+ const initFetch = async () => {
+ const response = await getListContent({ page: page - 1, size: 6, sortBy: "createdAt", contentTypeId: "2" });
+ console.log(response);
+ setVideoData(response?.data?.data?.content);
+ const data = response.data?.data;
+ const contentData = data?.content;
+ setVideoData(contentData);
+ setTotalData(data?.totalElements);
+ setTotalPage(data?.totalPages);
+ };
+
return (
{/* Header */}
@@ -48,123 +111,102 @@ const FilterPage = () => {
Audio Visual {">"}
Semua Audio Visual
|
-
Terdapat 32499 artikel berisi Audio Visual yang dapat diunduh
+
Terdapat 324911 artikel berisi Audio Visual yang dapat diunduh
{/* Left */}
-
-
Filter
-
-
-
-
-
-
+
+ Filter
+
+
+
+
+
-
-
-
-
-
+
+
+
+
-
-
-
-
-
+
+
+
+
-
-
-
Kategori
-
- {categories.map((category) => (
- -
-
-
- ))}
-
+
+
Kategori
+
+ {categories.map((category) => (
+ -
+
+
+ ))}
+
+
+ {/* Garis */}
+
+ {/* Garis */}
+
+
Format Foto
+
+ {formatPicture.map((format) => (
+ -
+
+
+ ))}
+
+
- {/* Garis */}
-
- {/* Garis */}
-
-
Format Foto
-
- {formatPicture.map((format) => (
- -
-
-
- ))}
-
-
-
+
{/* Konten Kanan */}
-
-
Urutkan berdasarkan
-
-
+
+
+
Urutkan berdasarkan
+
+
-
- {dummyImage.map((image) => (
-
-
-
-
- {image.date} {image.time} |
518{" "}
-
{" "}
-
- {image.title}
-
-
- ))}
-
+
+ {videoData?.map((video: any) => (
+
+
+
+
+
+ {formatDateToIndonesian(new Date(video?.createdAt))} {video?.timezone ? video?.timezone : "WIB"}|
+ {video?.clickCount}{" "}
+
{" "}
+
+ {video?.title}
+
+
+
+ ))}
+
+
+
-
-
-
-
-
-
- 1
-
-
-
- 2
-
-
-
- 3
-
-
-
-
-
-
-
-
-
);
};
diff --git a/app/[locale]/page.tsx b/app/[locale]/page.tsx
index 4a6790f3..818ba97b 100644
--- a/app/[locale]/page.tsx
+++ b/app/[locale]/page.tsx
@@ -8,21 +8,24 @@ import Coverage from "@/components/landing-page/coverage";
import Hero from "@/components/landing-page/Hero";
import Footer from "@/components/landing-page/Footer";
import Division from "@/components/landing-page/division";
-import Navbar from "@/components/landing-page/Navbar";
+import Navbar from "@/components/landing-page/navbar";
+import { ReactLenis } from "@studio-freight/react-lenis";
const Home = ({ params: { locale } }: { params: { locale: string } }) => {
return (
<>
-
-
-
-
-
- {/* */}
-
-
-
-
+
+
+
+
+
+
+ {/* */}
+
+
+
+
+
>
);
};
diff --git a/components/form/blog/blog--detail-form.tsx b/components/form/blog/blog--detail-form.tsx
new file mode 100644
index 00000000..6ed692d2
--- /dev/null
+++ b/components/form/blog/blog--detail-form.tsx
@@ -0,0 +1,443 @@
+"use client";
+import React, { ChangeEvent, useEffect, useRef, useState } from "react";
+import { useForm, Controller } from "react-hook-form";
+import { Input } from "@/components/ui/input";
+import { Button } from "@/components/ui/button";
+import { Label } from "@/components/ui/label";
+import { Card } from "@/components/ui/card";
+import { zodResolver } from "@hookform/resolvers/zod";
+import * as z from "zod";
+import Swal from "sweetalert2";
+import withReactContent from "sweetalert2-react-content";
+import { useParams, useRouter } from "next/navigation";
+import {
+ Select,
+ SelectContent,
+ SelectItem,
+ SelectTrigger,
+ SelectValue,
+} from "@/components/ui/select";
+import { Checkbox } from "@/components/ui/checkbox";
+import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group";
+import JoditEditor from "jodit-react";
+import { register } from "module";
+import { Switch } from "@/components/ui/switch";
+import Cookies from "js-cookie";
+import { createTask } from "@/config/api";
+import {
+ createMedia,
+ getTagsBySubCategoryId,
+ listEnableCategory,
+} from "@/service/content/content";
+import { getBlog, postBlog } from "@/service/blog/blog";
+
+const taskSchema = z.object({
+ title: z.string().min(1, { message: "Judul diperlukan" }),
+ slug: z.string().min(1, { message: "Judul diperlukan" }),
+ meta: z.string().min(1, { message: "Judul diperlukan" }),
+ description: z
+ .string()
+ .min(2, { message: "Narasi Penugasan harus lebih dari 2 karakter." }),
+ categoryName: z.string().min(1, { message: "Kategori diperlukan" }),
+});
+
+type Category = {
+ id: string;
+ categoryName: string;
+};
+
+type Detail = {
+ id: string;
+ title: string;
+ description: string;
+ slug: string;
+ metadata: string;
+ categoryName: string;
+ thumbnailLink: string;
+};
+
+const initialCategories: Category[] = [
+ {
+ id: "1",
+ categoryName: "Giat Polri",
+ },
+ {
+ id: "2",
+ categoryName: "Giat Pimpinan",
+ },
+ {
+ id: "3",
+ categoryName: "Liputan Kegiatan",
+ },
+ {
+ id: "4",
+ categoryName: "Seputar Prestasi",
+ },
+];
+
+export default function FormBlogDetail() {
+ const MySwal = withReactContent(Swal);
+ const router = useRouter();
+ const { id } = useParams() as { id: string };
+ console.log(id);
+ const editor = useRef(null);
+ type TaskSchema = z.infer;
+
+ const [selectedFiles, setSelectedFiles] = useState([]);
+ const taskId = Cookies.get("taskId");
+ const scheduleId = Cookies.get("scheduleId");
+ const scheduleType = Cookies.get("scheduleType");
+
+ const [categories] = useState(initialCategories);
+ const [selectedTarget, setSelectedTarget] = useState("");
+ const [selectedCategory, setSelectedCategory] = useState();
+ const [tags, setTags] = useState([]);
+ const [isDraft, setIsDraft] = useState(false);
+
+ const [detail, setDetail] = useState();
+ const [refresh, setRefresh] = useState(false);
+
+ const [unitSelection, setUnitSelection] = useState({
+ allUnit: false,
+ mabes: false,
+ polda: false,
+ polres: false,
+ });
+
+ let fileTypeId = "1";
+
+ const {
+ control,
+ handleSubmit,
+ setValue,
+ formState: { errors },
+ } = useForm({
+ resolver: zodResolver(taskSchema),
+ });
+
+ // const handleKeyDown = (e: any) => {
+ // const newTag = e.target.value.trim(); // Ambil nilai input
+ // if (e.key === "Enter" && newTag) {
+ // e.preventDefault(); // Hentikan submit form
+ // if (!tags.includes(newTag)) {
+ // setTags((prevTags) => [...prevTags, newTag]); // Tambah tag baru
+ // setValue("tags", ""); // Kosongkan input
+ // }
+ // }
+ // };
+
+ const handleRemoveTag = (index: any) => {
+ setTags((prevTags) => prevTags.filter((_, i) => i !== index));
+ };
+
+ const handleImageChange = (event: ChangeEvent) => {
+ if (event.target.files) {
+ const files = Array.from(event.target.files);
+ setSelectedFiles((prevImages: any) => [...prevImages, ...files]);
+ console.log("DATAFILE::", selectedFiles);
+ }
+ };
+
+ const handleRemoveImage = (index: number) => {
+ setSelectedFiles((prevImages) => prevImages.filter((_, i) => i !== index));
+ };
+
+ useEffect(() => {
+ async function initState() {
+ if (id) {
+ const response = await getBlog(id);
+ const details = response.data?.data;
+
+ setDetail(details);
+
+ // Set categoryId dari API ke form dan Select
+ setValue("categoryName", details.categoryName);
+ setSelectedTarget(details.categoryId); // Untuk dropdown
+ }
+ }
+ initState();
+ }, [refresh, setValue]);
+
+ const save = async (data: TaskSchema) => {
+ const requestData = {
+ ...data,
+ title: data.title,
+ description: data.description,
+ categoryId: selectedTarget,
+ slug: data.slug,
+ metadata: data.meta,
+ // tags: data.tags,
+ isDraft,
+ };
+
+ const response = await postBlog(requestData);
+ console.log("Form Data Submitted:", requestData);
+ console.log("response", response);
+
+ MySwal.fire({
+ title: "Sukses",
+ text: "Data berhasil disimpan.",
+ icon: "success",
+ confirmButtonColor: "#3085d6",
+ confirmButtonText: "OK",
+ }).then(() => {
+ router.push("/en/contributor/blog");
+ });
+ };
+
+ const onSubmit = (data: TaskSchema) => {
+ MySwal.fire({
+ title: "Simpan Data",
+ text: "Apakah Anda yakin ingin menyimpan data ini?",
+ icon: "warning",
+ showCancelButton: true,
+ cancelButtonColor: "#d33",
+ confirmButtonColor: "#3085d6",
+ confirmButtonText: "Simpan",
+ }).then((result) => {
+ if (result.isConfirmed) {
+ save(data);
+ }
+ });
+ };
+
+ const handlePublish = () => {
+ setIsDraft(false);
+ };
+
+ const handleSave = () => {
+ setIsDraft(true);
+ };
+
+ return (
+
+ );
+}
diff --git a/components/form/blog/blog-form.tsx b/components/form/blog/blog-form.tsx
new file mode 100644
index 00000000..a35c7a7f
--- /dev/null
+++ b/components/form/blog/blog-form.tsx
@@ -0,0 +1,422 @@
+"use client";
+import React, { ChangeEvent, useEffect, useRef, useState } from "react";
+import { useForm, Controller } from "react-hook-form";
+import { Input } from "@/components/ui/input";
+import { Button } from "@/components/ui/button";
+import { Label } from "@/components/ui/label";
+import { Card } from "@/components/ui/card";
+import { zodResolver } from "@hookform/resolvers/zod";
+import * as z from "zod";
+import Swal from "sweetalert2";
+import withReactContent from "sweetalert2-react-content";
+import { useRouter } from "next/navigation";
+import {
+ Select,
+ SelectContent,
+ SelectItem,
+ SelectTrigger,
+ SelectValue,
+} from "@/components/ui/select";
+import { Checkbox } from "@/components/ui/checkbox";
+import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group";
+import JoditEditor from "jodit-react";
+import { register } from "module";
+import { Switch } from "@/components/ui/switch";
+import Cookies from "js-cookie";
+import { createTask } from "@/config/api";
+import {
+ createMedia,
+ getTagsBySubCategoryId,
+ listEnableCategory,
+} from "@/service/content/content";
+import { postBlog } from "@/service/blog/blog";
+
+const taskSchema = z.object({
+ title: z.string().min(1, { message: "Judul diperlukan" }),
+ slug: z.string().min(1, { message: "Judul diperlukan" }),
+ meta: z.string().min(1, { message: "Judul diperlukan" }),
+ description: z
+ .string()
+ .min(2, { message: "Narasi Penugasan harus lebih dari 2 karakter." }),
+ // tags: z.string().min(1, { message: "Judul diperlukan" }),
+});
+
+type Category = {
+ id: string;
+ name: string;
+};
+
+const initialCategories: Category[] = [
+ {
+ id: "1",
+ name: "Giat Polri",
+ },
+ {
+ id: "2",
+ name: "Giat Pimpinan",
+ },
+ {
+ id: "3",
+ name: "Liputan Kegiatan",
+ },
+ {
+ id: "4",
+ name: "Seputar Prestasi",
+ },
+];
+
+export default function FormBlog() {
+ const MySwal = withReactContent(Swal);
+ const router = useRouter();
+ const editor = useRef(null);
+ type TaskSchema = z.infer;
+
+ const [selectedFiles, setSelectedFiles] = useState([]);
+ const taskId = Cookies.get("taskId");
+ const scheduleId = Cookies.get("scheduleId");
+ const scheduleType = Cookies.get("scheduleType");
+
+ const [categories] = useState(initialCategories); // State untuk kategori
+ const [selectedTarget, setSelectedTarget] = useState("");
+ const [selectedCategory, setSelectedCategory] = useState();
+ const [tags, setTags] = useState([]);
+ const [isDraft, setIsDraft] = useState(false);
+
+ const [unitSelection, setUnitSelection] = useState({
+ allUnit: false,
+ mabes: false,
+ polda: false,
+ polres: false,
+ });
+
+ let fileTypeId = "1";
+
+ const {
+ control,
+ handleSubmit,
+ setValue,
+ formState: { errors },
+ } = useForm({
+ resolver: zodResolver(taskSchema),
+ });
+
+ // const handleKeyDown = (e: any) => {
+ // const newTag = e.target.value.trim(); // Ambil nilai input
+ // if (e.key === "Enter" && newTag) {
+ // e.preventDefault(); // Hentikan submit form
+ // if (!tags.includes(newTag)) {
+ // setTags((prevTags) => [...prevTags, newTag]); // Tambah tag baru
+ // setValue("tags", ""); // Kosongkan input
+ // }
+ // }
+ // };
+
+ const handleRemoveTag = (index: any) => {
+ setTags((prevTags) => prevTags.filter((_, i) => i !== index));
+ };
+
+ const handleImageChange = (event: ChangeEvent) => {
+ if (event.target.files) {
+ const files = Array.from(event.target.files);
+ setSelectedFiles((prevImages: any) => [...prevImages, ...files]);
+ console.log("DATAFILE::", selectedFiles);
+ }
+ };
+
+ const handleRemoveImage = (index: number) => {
+ setSelectedFiles((prevImages) => prevImages.filter((_, i) => i !== index));
+ };
+
+ // useEffect(() => {
+ // async function initState() {
+ // getCategories();
+ // // setVideoActive(fileTypeId == '2');
+ // // getRoles();
+ // }
+
+ // initState();
+ // }, []);
+
+ // const getCategories = async () => {
+ // try {
+ // const category = await listEnableCategory(fileTypeId);
+ // const resCategory: Category[] = category.data.data.content;
+
+ // setCategories(resCategory);
+ // console.log("data category", resCategory);
+
+ // if (scheduleId && scheduleType === "3") {
+ // const findCategory = resCategory.find((o) =>
+ // o.name.toLowerCase().includes("pers rilis")
+ // );
+
+ // if (findCategory) {
+ // // setValue("categoryId", findCategory.id);
+ // setSelectedCategory(findCategory.id); // Set the selected category
+ // const response = await getTagsBySubCategoryId(findCategory.id);
+ // setTags(response?.data.data);
+ // }
+ // }
+ // } catch (error) {
+ // console.error("Failed to fetch categories:", error);
+ // }
+ // };
+
+ const save = async (data: TaskSchema) => {
+ const requestData = {
+ ...data,
+ title: data.title,
+ description: data.description,
+ categoryId: selectedTarget,
+ slug: data.slug,
+ metadata: data.meta,
+ // tags: data.tags,
+ isDraft,
+ };
+
+ const response = await postBlog(requestData);
+ console.log("Form Data Submitted:", requestData);
+ console.log("response", response);
+
+ MySwal.fire({
+ title: "Sukses",
+ text: "Data berhasil disimpan.",
+ icon: "success",
+ confirmButtonColor: "#3085d6",
+ confirmButtonText: "OK",
+ }).then(() => {
+ router.push("/en/contributor/blog");
+ });
+ };
+
+ const onSubmit = (data: TaskSchema) => {
+ MySwal.fire({
+ title: "Simpan Data",
+ text: "Apakah Anda yakin ingin menyimpan data ini?",
+ icon: "warning",
+ showCancelButton: true,
+ cancelButtonColor: "#d33",
+ confirmButtonColor: "#3085d6",
+ confirmButtonText: "Simpan",
+ }).then((result) => {
+ if (result.isConfirmed) {
+ save(data);
+ }
+ });
+ };
+
+ const handlePublish = () => {
+ setIsDraft(false);
+ };
+
+ const handleSave = () => {
+ setIsDraft(true);
+ };
+
+ return (
+
+ );
+}
diff --git a/components/form/communication/collaboration-form.tsx b/components/form/communication/collaboration-form.tsx
index fbb02466..f7555e3e 100644
--- a/components/form/communication/collaboration-form.tsx
+++ b/components/form/communication/collaboration-form.tsx
@@ -168,7 +168,7 @@ export default function FormCollaboration() {
confirmButtonColor: "#3085d6",
confirmButtonText: "OK",
}).then(() => {
- router.push("/en/communication");
+ router.push("/contributor/communication");
});
};
diff --git a/components/form/communication/escalation-detail-form.tsx b/components/form/communication/escalation-detail-form.tsx
new file mode 100644
index 00000000..2e5a7e98
--- /dev/null
+++ b/components/form/communication/escalation-detail-form.tsx
@@ -0,0 +1,285 @@
+"use client";
+"use client";
+import React, { useEffect, useState } from "react";
+import { useForm, Controller } from "react-hook-form";
+import { Input } from "@/components/ui/input";
+import { Button } from "@/components/ui/button";
+import { Label } from "@/components/ui/label";
+import { Card } from "@/components/ui/card";
+import { zodResolver } from "@hookform/resolvers/zod";
+import * as z from "zod";
+import Swal from "sweetalert2";
+import withReactContent from "sweetalert2-react-content";
+import { useParams } from "next/navigation";
+import {
+ Select,
+ SelectContent,
+ SelectItem,
+ SelectTrigger,
+ SelectValue,
+} from "@/components/ui/select";
+import { Avatar, AvatarImage } from "@/components/ui/avatar";
+import {
+ getTicketingDetail,
+ getTicketingInternalDetail,
+ getTicketingInternalDiscussion,
+ saveTicketInternalReply,
+} from "@/service/communication/communication";
+import { Textarea } from "@/components/ui/textarea";
+
+const taskSchema = z.object({
+ title: z.string().min(1, { message: "Judul diperlukan" }),
+ naration: z.string().min(2, {
+ message: "Narasi Penugasan harus lebih dari 2 karakter.",
+ }),
+});
+
+export type escalationDetail = {
+ id: number;
+ title: string;
+ createdAt: string;
+ commentFromUserName: string;
+ message: string;
+ createdBy: {
+ id: number;
+ fullname: string;
+ };
+ sendTo: {
+ id: number;
+ fullname: string;
+ };
+ status: {
+ id: number;
+ name: string;
+ };
+ priority: {
+ id: number;
+ name: string;
+ };
+ description: string;
+ narration: string;
+ is_active: string;
+};
+
+export type replyDetail = {
+ id: number;
+ message: string;
+ createdAt: string;
+ messageFrom: {
+ id: number;
+ fullname: string;
+ };
+ messageTo: {
+ id: number;
+ fullname: string;
+ };
+};
+
+export default function FormDetailEscalation() {
+ const MySwal = withReactContent(Swal);
+ const { id } = useParams() as { id: string };
+
+ const [detail, setDetail] = useState();
+ const [ticketReply, setTicketReply] = useState([]);
+ const [replyVisible, setReplyVisible] = useState(false);
+ const [replyMessage, setReplyMessage] = useState("");
+ const [selectedPriority, setSelectedPriority] = useState("");
+ const [selectedStatus, setSelectedStatus] = useState("");
+
+ const {
+ control,
+ handleSubmit,
+ formState: { errors },
+ } = useForm({
+ resolver: zodResolver(taskSchema),
+ });
+
+ useEffect(() => {
+ async function initState() {
+ if (id) {
+ const response = await getTicketingDetail(id);
+ setDetail(response.data?.data);
+ }
+ }
+ initState();
+ getTicketReply();
+ }, [id]);
+
+ async function getTicketReply() {
+ const res = await getTicketingInternalDiscussion(id);
+ if (res.data !== null) {
+ setTicketReply(res.data?.data);
+ }
+ }
+
+ const handleReply = () => {
+ setReplyVisible((prev) => !prev); // Toggle visibility
+ };
+
+ const handleSendReply = async () => {
+ if (replyMessage.trim() === "") {
+ MySwal.fire({
+ title: "Error",
+ text: "Pesan tidak boleh kosong!",
+ icon: "error",
+ });
+ return;
+ }
+
+ const data = {
+ ticketId: id,
+ message: replyMessage,
+ };
+
+ try {
+ const response = await saveTicketInternalReply(data);
+
+ // Tambahkan balasan baru ke daftar balasan
+ const newReply: replyDetail = {
+ id: response.data.id,
+ message: replyMessage,
+ createdAt: response.data.createdAt,
+ messageFrom: response.data.messageFrom,
+ messageTo: response.data.messageTo,
+ };
+
+ setTicketReply((prevReplies) => [newReply, ...prevReplies]);
+
+ MySwal.fire({
+ title: "Sukses",
+ text: "Pesan berhasil dikirim.",
+ icon: "success",
+ });
+
+ // Reset input dan sembunyikan form balasan
+ setReplyMessage("");
+ setReplyVisible(false);
+ } catch (error) {
+ MySwal.fire({
+ title: "Error",
+ text: "Gagal mengirim balasan.",
+ icon: "error",
+ });
+ console.error("Error sending reply:", error);
+ }
+ };
+
+ return (
+
+
+
+
+ {detail !== undefined && (
+
+
+ Ticket #{detail.id}
+
+
+
+
+
+
+
+
+ {detail?.commentFromUserName}
+ {" "}
+ mengirimkan pesan untuk{" "}
+ {detail?.message}
+
+
{detail?.createdAt}
+
+
+
{detail.message}
+
+ )}
+
+
+ {detail !== undefined && (
+
+
+
+
(
+
+ )}
+ />
+ {/* {errors.title?.message && (
+
+ {errors.title.message}
+
+ )} */}
+
+
+
+
+
+
+
+
(
+
+ )}
+ />
+ {/* {errors.title?.message && (
+
+ {errors.title.message}
+
+ )} */}
+
+
+
+ )}
+
+
+ );
+}
diff --git a/components/form/communication/internal-detail-form.tsx b/components/form/communication/internal-detail-form.tsx
new file mode 100644
index 00000000..9583c542
--- /dev/null
+++ b/components/form/communication/internal-detail-form.tsx
@@ -0,0 +1,292 @@
+"use client";
+"use client";
+import React, { useEffect, useState } from "react";
+import { useForm, Controller } from "react-hook-form";
+import { Input } from "@/components/ui/input";
+import { Button } from "@/components/ui/button";
+import { Label } from "@/components/ui/label";
+import { Card } from "@/components/ui/card";
+import { zodResolver } from "@hookform/resolvers/zod";
+import * as z from "zod";
+import Swal from "sweetalert2";
+import withReactContent from "sweetalert2-react-content";
+import { useParams } from "next/navigation";
+import {
+ Select,
+ SelectContent,
+ SelectItem,
+ SelectTrigger,
+ SelectValue,
+} from "@/components/ui/select";
+import { Avatar, AvatarImage } from "@/components/ui/avatar";
+import {
+ getTicketingInternalDetail,
+ getTicketingInternalDiscussion,
+ saveTicketInternalReply,
+} from "@/service/communication/communication";
+
+const taskSchema = z.object({
+ title: z.string().min(1, { message: "Judul diperlukan" }),
+ naration: z.string().min(2, {
+ message: "Narasi Penugasan harus lebih dari 2 karakter.",
+ }),
+});
+
+export type taskDetail = {
+ id: number;
+ title: string;
+ createdAt: string;
+ createdBy: {
+ id: number;
+ fullname: string;
+ };
+ sendTo: {
+ id: number;
+ fullname: string;
+ };
+ status: {
+ id: number;
+ name: string;
+ };
+ priority: {
+ id: number;
+ name: string;
+ };
+ broadcastType: string;
+ narration: string;
+ is_active: string;
+};
+
+export type replyDetail = {
+ id: number;
+ message: string;
+ createdAt: string;
+ messageFrom: {
+ id: number;
+ fullname: string;
+ };
+ messageTo: {
+ id: number;
+ fullname: string;
+ };
+};
+
+export default function FormDetailInternal() {
+ const MySwal = withReactContent(Swal);
+ const { id } = useParams() as { id: string };
+
+ const [detail, setDetail] = useState();
+ const [ticketReply, setTicketReply] = useState([]);
+ const [replyVisible, setReplyVisible] = useState(false);
+ const [replyMessage, setReplyMessage] = useState("");
+ const [selectedPriority, setSelectedPriority] = useState("");
+ const [selectedStatus, setSelectedStatus] = useState("");
+
+ const {
+ control,
+ handleSubmit,
+ formState: { errors },
+ } = useForm({
+ resolver: zodResolver(taskSchema),
+ });
+
+ useEffect(() => {
+ async function initState() {
+ if (id) {
+ const response = await getTicketingInternalDetail(id);
+ setDetail(response.data?.data);
+ }
+ }
+ initState();
+ getTicketReply();
+ }, [id]);
+
+ async function getTicketReply() {
+ const res = await getTicketingInternalDiscussion(id);
+ if (res.data !== null) {
+ setTicketReply(res.data?.data);
+ }
+ }
+
+ const handleReply = () => {
+ setReplyVisible((prev) => !prev); // Toggle visibility
+ };
+
+ const handleSendReply = async () => {
+ if (replyMessage.trim() === "") {
+ MySwal.fire({
+ title: "Error",
+ text: "Pesan tidak boleh kosong!",
+ icon: "error",
+ });
+ return;
+ }
+
+ const data = {
+ ticketId: id,
+ message: replyMessage,
+ };
+
+ try {
+ const response = await saveTicketInternalReply(data);
+
+ // Tambahkan balasan baru ke daftar balasan
+ const newReply: replyDetail = {
+ id: response.data.id,
+ message: replyMessage,
+ createdAt: response.data.createdAt,
+ messageFrom: response.data.messageFrom,
+ messageTo: response.data.messageTo,
+ };
+
+ setTicketReply((prevReplies) => [newReply, ...prevReplies]);
+
+ MySwal.fire({
+ title: "Sukses",
+ text: "Pesan berhasil dikirim.",
+ icon: "success",
+ });
+
+ // Reset input dan sembunyikan form balasan
+ setReplyMessage("");
+ setReplyVisible(false);
+ } catch (error) {
+ MySwal.fire({
+ title: "Error",
+ text: "Gagal mengirim balasan.",
+ icon: "error",
+ });
+ console.error("Error sending reply:", error);
+ }
+ };
+
+ return (
+
+
+
+
+
+
+
+
+ {replyVisible && (
+
+ )}
+
+
+ {ticketReply?.map((list) => (
+
+
+ Ticket #{list.id}
+
+
+
+
+
+
+
+
+ {list?.messageFrom?.fullname}
+ {" "}
+ mengirimkan pesan untuk{" "}
+
+ {list?.messageTo?.fullname}
+
+
+
{list?.createdAt}
+
+
+
{list.message}
+
+ ))}
+
+ {detail !== undefined && (
+
+
+
+
+
(
+
+ )}
+ />
+ {/* {errors.title?.message && (
+
+ {errors.title.message}
+
+ )} */}
+
+
+
+
+
+
+
+
+
+
+ )}
+
+
+
+ );
+}
diff --git a/components/form/communication/internal-form.tsx b/components/form/communication/internal-form.tsx
index 86ab54a4..b410dcef 100644
--- a/components/form/communication/internal-form.tsx
+++ b/components/form/communication/internal-form.tsx
@@ -168,7 +168,7 @@ export default function FormInternal() {
confirmButtonColor: "#3085d6",
confirmButtonText: "OK",
}).then(() => {
- router.push("/en/communication");
+ router.push("/en/shared/communication");
});
};
diff --git a/components/form/content/image-form.tsx b/components/form/content/image-form.tsx
index 74830c3c..ec996b60 100644
--- a/components/form/content/image-form.tsx
+++ b/components/form/content/image-form.tsx
@@ -168,7 +168,7 @@ export default function FormImage() {
confirmButtonColor: "#3085d6",
confirmButtonText: "OK",
}).then(() => {
- router.push("/en/content/image");
+ router.push("/contributor/content/image");
});
};
diff --git a/components/form/content/video-form.tsx b/components/form/content/video-form.tsx
index 48357d84..23c57810 100644
--- a/components/form/content/video-form.tsx
+++ b/components/form/content/video-form.tsx
@@ -168,7 +168,7 @@ export default function FormVideo() {
confirmButtonColor: "#3085d6",
confirmButtonText: "OK",
}).then(() => {
- router.push("/en/content/audio-visual");
+ router.push("/contributor/content/audio-visual");
});
};
diff --git a/components/form/contest/contest-detail-form.tsx b/components/form/contest/contest-detail-form.tsx
new file mode 100644
index 00000000..bbe69784
--- /dev/null
+++ b/components/form/contest/contest-detail-form.tsx
@@ -0,0 +1,391 @@
+"use client";
+import React, { useEffect, useRef, useState } from "react";
+import { useForm, Controller } from "react-hook-form";
+import { Input } from "@/components/ui/input";
+import { Button } from "@/components/ui/button";
+import { Label } from "@/components/ui/label";
+import { Card } from "@/components/ui/card";
+import { zodResolver } from "@hookform/resolvers/zod";
+import * as z from "zod";
+import Swal from "sweetalert2";
+import withReactContent from "sweetalert2-react-content";
+import { useParams, useRouter } from "next/navigation";
+import {
+ Select,
+ SelectContent,
+ SelectItem,
+ SelectTrigger,
+ SelectValue,
+} from "@/components/ui/select";
+import { Checkbox } from "@/components/ui/checkbox";
+import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group";
+import JoditEditor from "jodit-react";
+import { createTask, getTask } from "@/service/task";
+import { getContestById } from "@/service/contest/contest";
+import page from "@/app/[locale]/page";
+import {
+ Popover,
+ PopoverContent,
+ PopoverTrigger,
+} from "@/components/ui/popover";
+import { cn } from "@/lib/utils";
+import { CalendarIcon } from "lucide-react";
+import { format, parseISO } from "date-fns";
+import { Calendar } from "@/components/ui/calendar";
+import { DateRange } from "react-day-picker";
+
+const contestSchema = z.object({
+ theme: z.string().min(1, { message: "Judul diperlukan" }),
+ hastagCode: z.string().min(1, { message: "Judul diperlukan" }),
+ description: z.string().min(2, {
+ message: "Narasi Penugasan harus lebih dari 2 karakter.",
+ }),
+});
+
+export type taskDetail = {
+ id: number;
+ theme: string;
+ hastagCode: string;
+ assignedToTopLevel: string;
+ assignmentType: {
+ id: number;
+ name: string;
+ };
+ assignmentMainType: {
+ id: number;
+ name: string;
+ };
+
+ targetOutput: string;
+ targetParticipantTopLevel: string;
+ description: string;
+ is_active: string;
+};
+
+export default function FormContestDetail() {
+ const MySwal = withReactContent(Swal);
+ const router = useRouter();
+ const editor = useRef(null);
+ type ContestSchema = z.infer;
+ const { id } = useParams() as { id: string };
+ console.log(id);
+
+ // State for various form fields
+ const [taskOutput, setTaskOutput] = useState({
+ all: false,
+ video: false,
+ audio: false,
+ image: false,
+ text: false,
+ });
+
+ // const [assignmentType, setAssignmentType] = useState("mediahub");
+ // const [assignmentCategory, setAssignmentCategory] = useState("publication");
+ const [mainType, setMainType] = useState("1");
+ const [taskType, setTaskType] = useState("atensi-khusus");
+ const [broadcastType, setBroadcastType] = useState(""); // untuk Tipe Penugasan
+ const [type, setType] = useState("1");
+ const [selectedTarget, setSelectedTarget] = useState("all");
+ const [detail, setDetail] = useState();
+ const [refresh] = useState(false);
+ const [date, setDate] = useState();
+
+ const [platformTypeVisible, setPlatformTypeVisible] = useState(false);
+ const [unitSelection, setUnitSelection] = useState({
+ allUnit: false,
+ mabes: false,
+ polda: false,
+ polres: false,
+ });
+
+ const {
+ control,
+ handleSubmit,
+ formState: { errors },
+ } = useForm({
+ resolver: zodResolver(contestSchema),
+ });
+
+ // const handleRadioChange = (event: React.ChangeEvent) => {
+ // const selectedValue = Number(event.target.value);
+ // setMainType(selectedValue);
+
+ // setPlatformTypeVisible(selectedValue === 2);
+ // };
+
+ useEffect(() => {
+ async function initState() {
+ if (id) {
+ const response = await getContestById(id);
+ const details = response.data?.data;
+
+ setDetail(details);
+ // if (details?.createdAt) {
+ // // Memisahkan string duration menjadi start dan end date
+ // const [startDate, endDate] = details.createdAt.split(" - ");
+ // setDate({
+ // from: parseISO(startDate),
+ // to: parseISO(endDate),
+ // });
+ // }
+ }
+ }
+ initState();
+ }, [id, refresh]);
+
+ useEffect(() => {
+ if (detail?.targetOutput) {
+ const outputSet = new Set(detail.targetOutput.split(",").map(Number)); // Membagi string ke dalam array dan mengonversi ke nomor
+ setTaskOutput({
+ all: outputSet.has(0),
+ video: outputSet.has(2),
+ audio: outputSet.has(4),
+ image: outputSet.has(1),
+ text: outputSet.has(3),
+ });
+ }
+ }, [detail?.targetOutput]);
+
+ useEffect(() => {
+ if (detail?.targetParticipantTopLevel) {
+ const outputSet = new Set(
+ detail.targetParticipantTopLevel.split(",").map(Number)
+ );
+ setUnitSelection({
+ allUnit: outputSet.has(0),
+ mabes: outputSet.has(1),
+ polda: outputSet.has(2),
+ polres: outputSet.has(3),
+ });
+ }
+ }, [detail?.targetParticipantTopLevel]);
+
+ const save = async (data: ContestSchema) => {
+ const fileTypeMapping = {
+ all: "1",
+ video: "2",
+ audio: "3",
+ image: "4",
+ text: "5",
+ };
+
+ const selectedOutputs = Object.keys(taskOutput)
+ .filter((key) => taskOutput[key as keyof typeof taskOutput]) // Ambil hanya yang `true`
+ .map((key) => fileTypeMapping[key as keyof typeof fileTypeMapping]) // Konversi ke nilai string
+ .join(",");
+
+ const requestData = {
+ ...data,
+ // assignmentType,
+ // assignmentCategory,
+ target: selectedTarget,
+ unitSelection,
+ assignedToRole: "3",
+ taskType: taskType,
+ broadcastType: broadcastType,
+ assignmentMainTypeId: mainType,
+ assignmentPurpose: "1",
+ assignmentTypeId: type,
+ fileTypeOutput: selectedOutputs,
+ id: null,
+ description: data.description,
+ platformType: "",
+ theme: data.theme,
+ };
+
+ const response = await createTask(requestData);
+
+ console.log("Form Data Submitted:", requestData);
+ console.log("response", response);
+
+ MySwal.fire({
+ title: "Sukses",
+ text: "Data berhasil disimpan.",
+ icon: "success",
+ confirmButtonColor: "#3085d6",
+ confirmButtonText: "OK",
+ }).then(() => {
+ router.push("/en/contributor/task");
+ });
+ };
+
+ const onSubmit = (data: ContestSchema) => {
+ MySwal.fire({
+ title: "Simpan Data",
+ text: "Apakah Anda yakin ingin menyimpan data ini?",
+ icon: "warning",
+ showCancelButton: true,
+ cancelButtonColor: "#d33",
+ confirmButtonColor: "#3085d6",
+ confirmButtonText: "Simpan",
+ }).then((result) => {
+ if (result.isConfirmed) {
+ save(data);
+ }
+ });
+ };
+
+ return (
+
+
+
Form Contest
+ {detail !== undefined ? (
+
+ ) : (
+ ""
+ )}
+
+
+ );
+}
diff --git a/components/form/planning/mediahub-publish.tsx b/components/form/planning/mediahub-publish.tsx
new file mode 100644
index 00000000..49060fa6
--- /dev/null
+++ b/components/form/planning/mediahub-publish.tsx
@@ -0,0 +1,352 @@
+"use client";
+import React, { useEffect, useRef, useState } from "react";
+import { useForm, Controller } from "react-hook-form";
+import { Input } from "@/components/ui/input";
+import { Button } from "@/components/ui/button";
+import { Label } from "@/components/ui/label";
+import { Card } from "@/components/ui/card";
+import { zodResolver } from "@hookform/resolvers/zod";
+import * as z from "zod";
+import Swal from "sweetalert2";
+import withReactContent from "sweetalert2-react-content";
+import { useParams, useRouter } from "next/navigation";
+import {
+ Select,
+ SelectContent,
+ SelectItem,
+ SelectTrigger,
+ SelectValue,
+} from "@/components/ui/select";
+import { Checkbox } from "@/components/ui/checkbox";
+import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group";
+import JoditEditor from "jodit-react";
+import { createTask } from "@/service/task";
+import { cn } from "@/lib/utils";
+import { format } from "date-fns";
+import { CalendarIcon } from "lucide-react";
+import { id } from "date-fns/locale";
+import { getPlanningById } from "@/service/planning/planning";
+
+const taskSchema = z.object({
+ title: z.string().min(1, { message: "Judul diperlukan" }),
+ naration: z.string().min(2, {
+ message: "Narasi Penugasan harus lebih dari 2 karakter.",
+ }),
+});
+
+export type mediahubDetail = {
+ id: number;
+ title: string;
+ fileTypeOutput: string;
+ assignedToTopLevel: string;
+ assignmentType: {
+ id: number;
+ name: string;
+ };
+ date: string;
+ description: string;
+ is_active: string;
+};
+
+export default function PublishMediahub() {
+ const MySwal = withReactContent(Swal);
+ const router = useRouter();
+ const editor = useRef(null);
+ type TaskSchema = z.infer;
+ const { id } = useParams() as { id: string };
+ console.log(id);
+ const [taskOutput, setTaskOutput] = useState({
+ all: false,
+ video: false,
+ audio: false,
+ image: false,
+ text: false,
+ });
+ const [mainType, setMainType] = useState(1);
+ const [taskType, setTaskType] = useState("atensi-khusus");
+ const [broadcastType, setBroadcastType] = useState("all"); // untuk Tipe Penugasan
+ const [type, setType] = useState("1");
+ const [selectedTarget, setSelectedTarget] = useState("all");
+ const [startDate, setStartDate] = useState(new Date());
+ const [detail, setDetail] = useState();
+ const [refresh] = useState(false);
+
+ const [platformTypeVisible, setPlatformTypeVisible] = useState(false);
+ const [unitSelection, setUnitSelection] = useState({
+ allUnit: false,
+ mabes: false,
+ polda: false,
+ polres: false,
+ });
+
+ const {
+ control,
+ handleSubmit,
+ formState: { errors },
+ } = useForm({
+ resolver: zodResolver(taskSchema),
+ });
+
+ const handleRadioChange = (event: React.ChangeEvent) => {
+ const selectedValue = Number(event.target.value);
+ setMainType(selectedValue);
+
+ setPlatformTypeVisible(selectedValue === 2);
+ };
+
+ useEffect(() => {
+ async function initState() {
+ if (id) {
+ const response = await getPlanningById(id);
+ const details = response.data?.data;
+
+ setDetail(details);
+ if (details?.date) {
+ setStartDate(new Date(details.date)); // Konversi string tanggal ke objek Date
+ }
+ }
+ }
+ initState();
+ }, [id, refresh]);
+
+ useEffect(() => {
+ if (detail?.fileTypeOutput) {
+ const outputSet = new Set(detail.fileTypeOutput.split(",").map(Number)); // Membagi string ke dalam array dan mengonversi ke nomor
+ setTaskOutput({
+ all: outputSet.has(0),
+ video: outputSet.has(2),
+ audio: outputSet.has(4),
+ image: outputSet.has(1),
+ text: outputSet.has(3),
+ });
+ }
+ }, [detail?.fileTypeOutput]);
+
+ useEffect(() => {
+ if (detail?.assignedToTopLevel) {
+ const outputSet = new Set(
+ detail.assignedToTopLevel.split(",").map(Number)
+ ); // Membagi string ke dalam array dan mengonversi ke nomor
+ setUnitSelection({
+ allUnit: outputSet.has(0),
+ mabes: outputSet.has(1),
+ polda: outputSet.has(2),
+ polres: outputSet.has(3),
+ });
+ }
+ }, [detail?.fileTypeOutput]);
+
+ const save = async (data: TaskSchema) => {
+ const fileTypeMapping = {
+ all: "1",
+ video: "2",
+ audio: "3",
+ image: "4",
+ text: "5",
+ };
+
+ const selectedOutputs = Object.keys(taskOutput)
+ .filter((key) => taskOutput[key as keyof typeof taskOutput]) // Ambil hanya yang `true`
+ .map((key) => fileTypeMapping[key as keyof typeof fileTypeMapping]) // Konversi ke nilai string
+ .join(",");
+
+ const requestData = {
+ ...data,
+ // assignmentType,
+ // assignmentCategory,
+ target: selectedTarget,
+ unitSelection,
+ assignedToRole: "3",
+ taskType: taskType,
+ broadcastType: broadcastType,
+ assignmentMainTypeId: mainType,
+ assignmentPurpose: "1",
+ assignmentTypeId: type,
+ fileTypeOutput: selectedOutputs,
+ id: null,
+ narration: data.naration,
+ platformType: "",
+ title: data.title,
+ };
+
+ const response = await createTask(requestData);
+
+ console.log("Form Data Submitted:", requestData);
+ console.log("response", response);
+
+ MySwal.fire({
+ title: "Sukses",
+ text: "Data berhasil disimpan.",
+ icon: "success",
+ confirmButtonColor: "#3085d6",
+ confirmButtonText: "OK",
+ }).then(() => {
+ router.push("/en/contributor/task");
+ });
+ };
+
+ const onSubmit = (data: TaskSchema) => {
+ MySwal.fire({
+ title: "Simpan Data",
+ text: "Apakah Anda yakin ingin menyimpan data ini?",
+ icon: "warning",
+ showCancelButton: true,
+ cancelButtonColor: "#d33",
+ confirmButtonColor: "#3085d6",
+ confirmButtonText: "Simpan",
+ }).then((result) => {
+ if (result.isConfirmed) {
+ save(data);
+ }
+ });
+ };
+
+ return (
+
+
+
Perencanaan Mediahub
+ {detail !== undefined ? (
+
+ ) : (
+ ""
+ )}
+
+
+ );
+}
diff --git a/components/form/planning/medsos-publish.tsx b/components/form/planning/medsos-publish.tsx
new file mode 100644
index 00000000..5124f4a4
--- /dev/null
+++ b/components/form/planning/medsos-publish.tsx
@@ -0,0 +1,352 @@
+"use client";
+import React, { useEffect, useRef, useState } from "react";
+import { useForm, Controller } from "react-hook-form";
+import { Input } from "@/components/ui/input";
+import { Button } from "@/components/ui/button";
+import { Label } from "@/components/ui/label";
+import { Card } from "@/components/ui/card";
+import { zodResolver } from "@hookform/resolvers/zod";
+import * as z from "zod";
+import Swal from "sweetalert2";
+import withReactContent from "sweetalert2-react-content";
+import { useParams, useRouter } from "next/navigation";
+import {
+ Select,
+ SelectContent,
+ SelectItem,
+ SelectTrigger,
+ SelectValue,
+} from "@/components/ui/select";
+import { Checkbox } from "@/components/ui/checkbox";
+import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group";
+import JoditEditor from "jodit-react";
+import { createTask } from "@/service/task";
+import { cn } from "@/lib/utils";
+import { format } from "date-fns";
+import { CalendarIcon } from "lucide-react";
+import { id } from "date-fns/locale";
+import { getPlanningById } from "@/service/planning/planning";
+
+const taskSchema = z.object({
+ title: z.string().min(1, { message: "Judul diperlukan" }),
+ naration: z.string().min(2, {
+ message: "Narasi Penugasan harus lebih dari 2 karakter.",
+ }),
+});
+
+export type medsosDetail = {
+ id: number;
+ title: string;
+ fileTypeOutput: string;
+ assignedToTopLevel: string;
+ assignmentType: {
+ id: number;
+ name: string;
+ };
+ date: string;
+ description: string;
+ is_active: string;
+};
+
+export default function PublishMedsos() {
+ const MySwal = withReactContent(Swal);
+ const router = useRouter();
+ const editor = useRef(null);
+ type TaskSchema = z.infer;
+ const { id } = useParams() as { id: string };
+ console.log(id);
+ const [taskOutput, setTaskOutput] = useState({
+ all: false,
+ video: false,
+ audio: false,
+ image: false,
+ text: false,
+ });
+ const [mainType, setMainType] = useState(1);
+ const [taskType, setTaskType] = useState("atensi-khusus");
+ const [broadcastType, setBroadcastType] = useState("all"); // untuk Tipe Penugasan
+ const [type, setType] = useState("1");
+ const [selectedTarget, setSelectedTarget] = useState("all");
+ const [startDate, setStartDate] = useState(new Date());
+ const [detail, setDetail] = useState();
+ const [refresh] = useState(false);
+
+ const [platformTypeVisible, setPlatformTypeVisible] = useState(false);
+ const [unitSelection, setUnitSelection] = useState({
+ allUnit: false,
+ mabes: false,
+ polda: false,
+ polres: false,
+ });
+
+ const {
+ control,
+ handleSubmit,
+ formState: { errors },
+ } = useForm({
+ resolver: zodResolver(taskSchema),
+ });
+
+ const handleRadioChange = (event: React.ChangeEvent) => {
+ const selectedValue = Number(event.target.value);
+ setMainType(selectedValue);
+
+ setPlatformTypeVisible(selectedValue === 2);
+ };
+
+ useEffect(() => {
+ async function initState() {
+ if (id) {
+ const response = await getPlanningById(id);
+ const details = response.data?.data;
+
+ setDetail(details);
+ if (details?.date) {
+ setStartDate(new Date(details.date)); // Konversi string tanggal ke objek Date
+ }
+ }
+ }
+ initState();
+ }, [id, refresh]);
+
+ useEffect(() => {
+ if (detail?.fileTypeOutput) {
+ const outputSet = new Set(detail.fileTypeOutput.split(",").map(Number)); // Membagi string ke dalam array dan mengonversi ke nomor
+ setTaskOutput({
+ all: outputSet.has(0),
+ video: outputSet.has(2),
+ audio: outputSet.has(4),
+ image: outputSet.has(1),
+ text: outputSet.has(3),
+ });
+ }
+ }, [detail?.fileTypeOutput]);
+
+ useEffect(() => {
+ if (detail?.assignedToTopLevel) {
+ const outputSet = new Set(
+ detail.assignedToTopLevel.split(",").map(Number)
+ ); // Membagi string ke dalam array dan mengonversi ke nomor
+ setUnitSelection({
+ allUnit: outputSet.has(0),
+ mabes: outputSet.has(1),
+ polda: outputSet.has(2),
+ polres: outputSet.has(3),
+ });
+ }
+ }, [detail?.fileTypeOutput]);
+
+ const save = async (data: TaskSchema) => {
+ const fileTypeMapping = {
+ all: "1",
+ video: "2",
+ audio: "3",
+ image: "4",
+ text: "5",
+ };
+
+ const selectedOutputs = Object.keys(taskOutput)
+ .filter((key) => taskOutput[key as keyof typeof taskOutput]) // Ambil hanya yang `true`
+ .map((key) => fileTypeMapping[key as keyof typeof fileTypeMapping]) // Konversi ke nilai string
+ .join(",");
+
+ const requestData = {
+ ...data,
+ // assignmentType,
+ // assignmentCategory,
+ target: selectedTarget,
+ unitSelection,
+ assignedToRole: "3",
+ taskType: taskType,
+ broadcastType: broadcastType,
+ assignmentMainTypeId: mainType,
+ assignmentPurpose: "1",
+ assignmentTypeId: type,
+ fileTypeOutput: selectedOutputs,
+ id: null,
+ narration: data.naration,
+ platformType: "",
+ title: data.title,
+ };
+
+ const response = await createTask(requestData);
+
+ console.log("Form Data Submitted:", requestData);
+ console.log("response", response);
+
+ MySwal.fire({
+ title: "Sukses",
+ text: "Data berhasil disimpan.",
+ icon: "success",
+ confirmButtonColor: "#3085d6",
+ confirmButtonText: "OK",
+ }).then(() => {
+ router.push("/en/contributor/task");
+ });
+ };
+
+ const onSubmit = (data: TaskSchema) => {
+ MySwal.fire({
+ title: "Simpan Data",
+ text: "Apakah Anda yakin ingin menyimpan data ini?",
+ icon: "warning",
+ showCancelButton: true,
+ cancelButtonColor: "#d33",
+ confirmButtonColor: "#3085d6",
+ confirmButtonText: "Simpan",
+ }).then((result) => {
+ if (result.isConfirmed) {
+ save(data);
+ }
+ });
+ };
+
+ return (
+
+
+
Perencanaan Mediahub
+ {detail !== undefined ? (
+
+ ) : (
+ ""
+ )}
+
+
+ );
+}
diff --git a/components/form/schedule/event-detail-form.tsx b/components/form/schedule/event-detail-form.tsx
new file mode 100644
index 00000000..57d9c072
--- /dev/null
+++ b/components/form/schedule/event-detail-form.tsx
@@ -0,0 +1,320 @@
+"use client";
+import React, { useEffect, useRef, useState } from "react";
+import { useForm, Controller } from "react-hook-form";
+import { Input } from "@/components/ui/input";
+import { Button } from "@/components/ui/button";
+import { Label } from "@/components/ui/label";
+import { Card } from "@/components/ui/card";
+import { zodResolver } from "@hookform/resolvers/zod";
+import * as z from "zod";
+import Swal from "sweetalert2";
+import withReactContent from "sweetalert2-react-content";
+import { useParams, useRouter } from "next/navigation";
+import { Switch } from "@/components/ui/switch";
+import {
+ Popover,
+ PopoverContent,
+ PopoverTrigger,
+} from "@/components/ui/popover";
+import { cn } from "@/lib/utils";
+import { CalendarIcon } from "lucide-react";
+import { Calendar } from "@/components/ui/calendar";
+import { addDays, format, parseISO, setDate } from "date-fns";
+import { DateRange } from "react-day-picker";
+import TimePicker from "react-time-picker";
+import "react-time-picker/dist/TimePicker.css";
+import "react-clock/dist/Clock.css";
+import MapHome from "@/components/maps/MapHome";
+import { Textarea } from "@/components/ui/textarea";
+import { error, loading } from "@/lib/swal";
+import Cookies from "js-cookie";
+import { detailSchedule, postSchedule } from "@/service/schedule/schedule";
+
+const taskSchema = z.object({
+ title: z.string().min(1, { message: "Judul diperlukan" }),
+ level: z.string().min(1, { message: "Judul diperlukan" }),
+ name: z.string().min(1, { message: "Judul diperlukan" }),
+ location: z.string().min(1, { message: "Judul diperlukan" }),
+});
+
+interface Detail {
+ id: number;
+ title: string;
+ address: string;
+ speakerTitle: string;
+ speakerName: string;
+ addressLat: number;
+ addressLong: number;
+}
+
+export default function FormEventDetail() {
+ const { id } = useParams() as { id: string };
+ console.log(id);
+ const router = useRouter();
+ const [isLiveStreamingEnabled, setIsLiveStreamingEnabled] = useState(false);
+ type TaskSchema = z.infer;
+ const [startTime, setStartTime] = useState("08:00");
+ const [endTime, setEndTime] = useState("09:00");
+ const [date, setDate] = useState();
+
+ const [detail, setDetail] = useState();
+ const [refresh, setRefresh] = useState(false);
+
+ const {
+ control,
+ handleSubmit,
+ setValue,
+ formState: { errors },
+ } = useForm({
+ resolver: zodResolver(taskSchema),
+ defaultValues: {
+ location: "",
+ },
+ });
+
+ useEffect(() => {
+ async function initState() {
+ if (id) {
+ const response = await detailSchedule(id);
+ const details = response.data?.data;
+
+ setDetail(details);
+ if (details) {
+ setDate({
+ from: parseISO(details.startDate),
+ to: parseISO(details.endDate),
+ });
+ }
+ if (details) {
+ setStartTime(details.startTime);
+ setEndTime(details.endTime);
+ }
+ }
+ }
+ initState();
+ }, [refresh, setValue]);
+
+ const handleStartTime = (e: React.ChangeEvent) => {
+ setStartTime(e.target.value);
+ };
+
+ const handleEndTime = (e: React.ChangeEvent) => {
+ setEndTime(e.target.value);
+ };
+
+ return (
+
+
+
+
Form Event
+ {detail !== undefined ? (
+
+ {/* Input Title */}
+
+
+
(
+
+ )}
+ />
+ {errors.title?.message && (
+ {errors.title.message}
+ )}
+
+
+
+
+
+
Aktifkan fitur live streaming
+
+ setIsLiveStreamingEnabled(checked)
+ }
+ />
+
+
+
+
+ {isLiveStreamingEnabled && (
+
+ )}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {/* Kirim setValue ke MapHome */}
+ setValue("location", location)}
+ />
+
+
+
(
+
+ )}
+ />
+
+ {errors.location?.message}
+
+
+
DI SAMPAIKAN OLEH
+
+
+
+
(
+
+ )}
+ />
+ {errors.level?.message && (
+
+ {errors.level.message}
+
+ )}
+
+
+
+
+
+
(
+
+ )}
+ />
+ {errors.name?.message && (
+
+ {errors.name.message}
+
+ )}
+
+
+
+ ) : (
+ ""
+ )}
+ {/* Submit Button
+
+
+
*/}
+
+
+
+ Jadwal Selanjutnya
+
+
+ );
+}
diff --git a/components/form/schedule/event-form.tsx b/components/form/schedule/event-form.tsx
index 3a1fdcc0..e6dabeb8 100644
--- a/components/form/schedule/event-form.tsx
+++ b/components/form/schedule/event-form.tsx
@@ -37,15 +37,15 @@ import "react-clock/dist/Clock.css";
import { register } from "module";
import MapHome from "@/components/maps/MapHome";
import { Textarea } from "@/components/ui/textarea";
+import { error } from "@/lib/swal";
+import Cookies from "js-cookie";
+import { postSchedule } from "@/service/schedule/schedule";
const taskSchema = z.object({
title: z.string().min(1, { message: "Judul diperlukan" }),
- rankName: z.string().min(1, { message: "Nama Pangkat diperlukan" }),
- fullName: z.string().min(1, { message: "Nama Lengkap diperlukan" }),
- naration: z.string().min(2, {
- message: "Narasi Penugasan harus lebih dari 2 karakter.",
- }),
- location: z.string().min(1, { message: "Nama Lengkap diperlukan" }),
+ level: z.string().min(1, { message: "Judul diperlukan" }),
+ name: z.string().min(1, { message: "Judul diperlukan" }),
+ location: z.string().min(1, { message: "Judul diperlukan" }),
});
export default function FormEvent() {
@@ -69,13 +69,6 @@ export default function FormEvent() {
setEndTime(e.target.value);
};
// State for various form fields
- const [output, setOutput] = useState({
- all: false,
- video: false,
- audio: false,
- image: false,
- text: false,
- });
const [assignmentType, setAssignmentType] = useState("mediahub");
const [assignmentCategory, setAssignmentCategory] = useState("publication");
@@ -102,16 +95,33 @@ export default function FormEvent() {
const save = async (data: TaskSchema) => {
const requestData = {
- ...data,
- output,
- assignmentType,
- assignmentCategory,
- target: selectedTarget,
- unitSelection,
+ title: data.title,
+ address: data.location,
+ speakerTitle: data.level,
+ speakerName: data.name,
+ startTime, // Start time from state
+ endTime, // End time from state
+ addressLat: "0.0", // Replace with actual latitude
+ addressLong: "0.0", // Replace with actual longitude
+ startDate: date?.from ? format(date.from, "yyyy-MM-dd") : null,
+ endDate: date?.to ? format(date.to, "yyyy-MM-dd") : null,
+ isYoutube: isLiveStreamingEnabled,
+ scheduleTypeId: 2,
};
console.log("Form Data Submitted:", requestData);
+ const response = await postSchedule(requestData);
+ if (response.error) {
+ error(response.message);
+ return false;
+ }
+
+ Cookies.set("scheduleId", response.data.data.id, {
+ expires: 1,
+ });
+
+ // Optional: Use Swal for success feedback
MySwal.fire({
title: "Sukses",
text: "Data berhasil disimpan.",
@@ -119,7 +129,7 @@ export default function FormEvent() {
confirmButtonColor: "#3085d6",
confirmButtonText: "OK",
}).then(() => {
- router.push("/en/task");
+ router.push("/contributor/schedule/event");
});
};
@@ -143,7 +153,7 @@ export default function FormEvent() {
-
Form Konferensi Pers
+
Form Event
diff --git a/components/form/schedule/event-update-form.tsx b/components/form/schedule/event-update-form.tsx
new file mode 100644
index 00000000..cf0ea640
--- /dev/null
+++ b/components/form/schedule/event-update-form.tsx
@@ -0,0 +1,400 @@
+"use client";
+import React, { useEffect, useRef, useState } from "react";
+import { useForm, Controller } from "react-hook-form";
+import { Input } from "@/components/ui/input";
+import { Button } from "@/components/ui/button";
+import { Label } from "@/components/ui/label";
+import { Card } from "@/components/ui/card";
+import { zodResolver } from "@hookform/resolvers/zod";
+import * as z from "zod";
+import Swal from "sweetalert2";
+import withReactContent from "sweetalert2-react-content";
+import { useParams, useRouter } from "next/navigation";
+import { Switch } from "@/components/ui/switch";
+import {
+ Popover,
+ PopoverContent,
+ PopoverTrigger,
+} from "@/components/ui/popover";
+import { cn } from "@/lib/utils";
+import { CalendarIcon } from "lucide-react";
+import { Calendar } from "@/components/ui/calendar";
+import { addDays, format, parseISO, setDate } from "date-fns";
+import { DateRange } from "react-day-picker";
+import TimePicker from "react-time-picker";
+import "react-time-picker/dist/TimePicker.css";
+import "react-clock/dist/Clock.css";
+import MapHome from "@/components/maps/MapHome";
+import { Textarea } from "@/components/ui/textarea";
+import { error, loading } from "@/lib/swal";
+import Cookies from "js-cookie";
+import { detailSchedule, postSchedule } from "@/service/schedule/schedule";
+
+const taskSchema = z.object({
+ title: z.string().min(1, { message: "Judul diperlukan" }),
+ level: z.string().min(1, { message: "Judul diperlukan" }),
+ name: z.string().min(1, { message: "Judul diperlukan" }),
+ location: z.string().min(1, { message: "Judul diperlukan" }),
+});
+
+interface Detail {
+ id: number;
+ title: string;
+ address: string;
+ speakerTitle: string;
+ speakerName: string;
+ addressLat: number;
+ addressLong: number;
+}
+
+export default function FormEventUpdate() {
+ const { id } = useParams() as { id: string };
+ console.log(id);
+ const router = useRouter();
+ const MySwal = withReactContent(Swal);
+ const [isLiveStreamingEnabled, setIsLiveStreamingEnabled] = useState(false);
+ type TaskSchema = z.infer;
+ const [startTime, setStartTime] = useState("08:00");
+ const [endTime, setEndTime] = useState("09:00");
+ const [date, setDate] = useState();
+
+ const [detail, setDetail] = useState();
+ const [refresh, setRefresh] = useState(false);
+
+ const {
+ control,
+ handleSubmit,
+ setValue,
+ formState: { errors },
+ } = useForm({
+ resolver: zodResolver(taskSchema),
+ defaultValues: {
+ location: "",
+ },
+ });
+
+ useEffect(() => {
+ async function initState() {
+ if (id) {
+ const response = await detailSchedule(id);
+ const details = response.data?.data;
+
+ setDetail(details);
+ if (details) {
+ setDate({
+ from: parseISO(details.startDate),
+ to: parseISO(details.endDate),
+ });
+ }
+ if (details) {
+ setStartTime(details.startTime);
+ setEndTime(details.endTime);
+ }
+ }
+ }
+ initState();
+ }, [refresh, setValue]);
+
+ const handleStartTime = (e: React.ChangeEvent) => {
+ setStartTime(e.target.value);
+ };
+
+ const handleEndTime = (e: React.ChangeEvent) => {
+ setEndTime(e.target.value);
+ };
+
+ const save = async (data: TaskSchema) => {
+ const requestData: {
+ id?: number;
+ title: string;
+ address: string;
+ speakerTitle: string;
+ speakerName: string;
+ startTime: string;
+ endTime: string;
+ addressLat: string;
+ addressLong: string;
+ startDate: string | null;
+ endDate: string | null;
+ isYoutube: boolean;
+ scheduleTypeId: number;
+ } = {
+ title: data.title,
+ address: data.location,
+ speakerTitle: data.level,
+ speakerName: data.name,
+ startTime, // Start time from state
+ endTime, // End time from state
+ addressLat: "0.0", // Replace with actual latitude
+ addressLong: "0.0", // Replace with actual longitude
+ startDate: date?.from ? format(date.from, "yyyy-MM-dd") : null,
+ endDate: date?.to ? format(date.to, "yyyy-MM-dd") : null,
+ isYoutube: isLiveStreamingEnabled,
+ scheduleTypeId: 2,
+ };
+
+ // Add id property if it exists
+ if (id) {
+ requestData.id = parseInt(id, 10); // Ensure id is a number
+ }
+
+ console.log("Form Data Submitted:", requestData);
+
+ const response = await postSchedule(requestData);
+
+ if (response.error) {
+ error(response.message);
+ return false;
+ }
+
+ Cookies.set("scheduleId", response.data.data.id, {
+ expires: 1,
+ });
+
+ MySwal.fire({
+ title: "Sukses",
+ text: "Data berhasil disimpan.",
+ icon: "success",
+ confirmButtonColor: "#3085d6",
+ confirmButtonText: "OK",
+ }).then(() => {
+ router.push("/en/contributor/schedule/event");
+ });
+ };
+
+ const onSubmit = (data: TaskSchema) => {
+ MySwal.fire({
+ title: "Simpan Data",
+ text: "Apakah Anda yakin ingin menyimpan data ini?",
+ icon: "warning",
+ showCancelButton: true,
+ cancelButtonColor: "#d33",
+ confirmButtonColor: "#3085d6",
+ confirmButtonText: "Simpan",
+ }).then((result) => {
+ if (result.isConfirmed) {
+ save(data);
+ }
+ });
+ };
+
+ return (
+
+
+