From 47d24e8a29a857ff01a212cc6006a698b7eaadfe Mon Sep 17 00:00:00 2001 From: Anang Yusman Date: Thu, 12 Dec 2024 20:04:27 +0700 Subject: [PATCH] feat:create schedule,create agenda setting, curated-content,communication --- .../agenda-setting/calender-view.tsx | 6 +- .../agenda-setting/event-modal.tsx | 95 +++-- .../(protected)/agenda-setting/page.tsx | 4 +- .../contest/components/columns.tsx | 130 +++++++ .../contest/components/contest-table.tsx | 208 +++++++++++ app/[locale]/(protected)/contest/page.tsx | 28 +- .../contest/table-contest/contest-table.tsx | 347 ------------------ .../(protected)/contest/table-contest/data.ts | 74 ---- .../giat-penugasan/audio-visual.tsx | 78 ++++ .../curated-content/giat-penugasan/audio.tsx | 89 +++++ .../curated-content/giat-penugasan/image.tsx | 79 ++++ .../curated-content/giat-penugasan/teks.tsx | 103 ++++++ .../giat-routine/audio-visual.tsx | 78 ++++ .../curated-content/giat-routine/audio.tsx | 89 +++++ .../curated-content/giat-routine/image.tsx | 79 ++++ .../curated-content/giat-routine/teks.tsx | 103 ++++++ .../(protected)/curated-content/page.tsx | 86 +++-- .../press-conference/components/columns.tsx | 21 +- .../press-conference/detail/[id]/page.tsx | 23 ++ components/form/schedule/event-form.tsx | 64 ++-- .../form/schedule/pers-release-form.tsx | 64 ++-- .../schedule/press-conference-detail-form.tsx | 341 +++++++++++++++++ .../form/schedule/press-conference-form.tsx | 62 ++-- components/ui/carousel.tsx | 148 ++++---- service/agenda-setting/agenda-setting.ts | 16 + service/contest/contest.ts | 8 +- service/schedule/schedule.ts | 11 + 27 files changed, 1789 insertions(+), 645 deletions(-) create mode 100644 app/[locale]/(protected)/contest/components/columns.tsx create mode 100644 app/[locale]/(protected)/contest/components/contest-table.tsx delete mode 100644 app/[locale]/(protected)/contest/table-contest/contest-table.tsx delete mode 100644 app/[locale]/(protected)/contest/table-contest/data.ts create mode 100644 app/[locale]/(protected)/curated-content/giat-penugasan/audio-visual.tsx create mode 100644 app/[locale]/(protected)/curated-content/giat-penugasan/audio.tsx create mode 100644 app/[locale]/(protected)/curated-content/giat-penugasan/image.tsx create mode 100644 app/[locale]/(protected)/curated-content/giat-penugasan/teks.tsx create mode 100644 app/[locale]/(protected)/curated-content/giat-routine/audio-visual.tsx create mode 100644 app/[locale]/(protected)/curated-content/giat-routine/audio.tsx create mode 100644 app/[locale]/(protected)/curated-content/giat-routine/image.tsx create mode 100644 app/[locale]/(protected)/curated-content/giat-routine/teks.tsx create mode 100644 app/[locale]/(protected)/schedule/press-conference/detail/[id]/page.tsx create mode 100644 components/form/schedule/press-conference-detail-form.tsx create mode 100644 service/agenda-setting/agenda-setting.ts diff --git a/app/[locale]/(protected)/agenda-setting/calender-view.tsx b/app/[locale]/(protected)/agenda-setting/calender-view.tsx index 6eba2619..2f078cd3 100644 --- a/app/[locale]/(protected)/agenda-setting/calender-view.tsx +++ b/app/[locale]/(protected)/agenda-setting/calender-view.tsx @@ -110,11 +110,11 @@ const CalendarView = ({ events, categories }: CalendarViewProps) => { const handleClassName = (arg: EventContentArg) => { if (arg.event.extendedProps.calendar === "national") { - return "destructive"; - } else if (arg.event.extendedProps.calendar === "polda") { return "primary"; - } else if (arg.event.extendedProps.calendar === "polres") { + } else if (arg.event.extendedProps.calendar === "polda") { return "success"; + } else if (arg.event.extendedProps.calendar === "polres") { + return "destructive"; } else if (arg.event.extendedProps.calendar === "international") { return "info"; } else { diff --git a/app/[locale]/(protected)/agenda-setting/event-modal.tsx b/app/[locale]/(protected)/agenda-setting/event-modal.tsx index 87ebc61f..c84fdc07 100644 --- a/app/[locale]/(protected)/agenda-setting/event-modal.tsx +++ b/app/[locale]/(protected)/agenda-setting/event-modal.tsx @@ -1,4 +1,4 @@ -"use client"; +// "use client"; import React, { useState, useEffect } from "react"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; @@ -30,9 +30,18 @@ import { DialogHeader, DialogTitle, } from "@/components/ui/dialog"; +import { Textarea } from "@/components/ui/textarea"; +import { error, loading } from "@/lib/swal"; +import Cookies from "js-cookie"; +import Swal from "sweetalert2"; +import withReactContent from "sweetalert2-react-content"; +import { useRouter } from "next/navigation"; +import { postSchedule } from "@/service/schedule/schedule"; +import { saveAgendaSettings } from "@/service/agenda-setting/agenda-setting"; const schema = z.object({ title: z.string().min(3, { message: "Required" }), + description: z.string().min(3, { message: "Required" }), }); const EventModal = ({ @@ -57,6 +66,8 @@ const EventModal = ({ // delete modal state const [deleteModalOpen, setDeleteModalOpen] = useState(false); const [eventIdToDelete, setEventIdToDelete] = useState(null); + const MySwal = withReactContent(Swal); + const router = useRouter(); const { register, @@ -70,20 +81,45 @@ const EventModal = ({ mode: "all", }); - const onSubmit = (data: any) => { - startTransition(() => { - if (!event) { - data.start = startDate; - data.end = endDate; - data.allDay = false; - data.extendedProps = { - calendar: calendarProps, - }; - } - if (event) { - } + const save = async (data: any) => { + // loading(); + + const reqData = { + title: data.title, + description: data.description || "", + agendaType: calendarProps, + startDate: format(startDate, "yyyy-MM-dd"), + endDate: format(endDate, "yyyy-MM-dd"), + }; + + console.log("Submitted Data:", reqData); + + const response = await saveAgendaSettings(reqData); + if (response.error) { + error(response.message); + return false; + } + + Cookies.set("AgendaSetting", response.data.data.id, { + expires: 1, + }); + + // Optional: Use Swal for success feedback + MySwal.fire({ + title: "Sukses", + text: "Data berhasil disimpan.", + icon: "success", + confirmButtonColor: "#3085d6", + confirmButtonText: "OK", + }).then(() => { + router.push("/en/agenda-setting"); }); }; + + const onSubmit = (data: any) => { + save(data); + }; + useEffect(() => { if (selectedDate) { setStartDate(selectedDate.date); @@ -93,13 +129,10 @@ const EventModal = ({ setStartDate(event?.event?.start); setEndDate(event?.event?.end); const eventCalendar = event?.event?.extendedProps?.calendar; - if (eventCalendar) { - setCalendarProps(eventCalendar); - } else { - setCalendarProps(categories[0].value); - } + setCalendarProps(eventCalendar || categories[0].value); } setValue("title", event?.event?.title || ""); + setValue("description", event?.event?.description || ""); }, [event, selectedDate, open, categories, setValue]); const onDeleteEventAction = async () => { @@ -125,14 +158,15 @@ const EventModal = ({ - {event ? "Edit Event" : "Create Event"} {event?.title} + {event ? "Edit Agenda Setting" : "Create Agenda Setting"}{" "} + {event?.title}
- +
- +
+
+ +