diff --git a/app/[locale]/(protected)/contributor/agenda-setting/event-modal.tsx b/app/[locale]/(protected)/contributor/agenda-setting/event-modal.tsx index 513c743f..00e002c8 100644 --- a/app/[locale]/(protected)/contributor/agenda-setting/event-modal.tsx +++ b/app/[locale]/(protected)/contributor/agenda-setting/event-modal.tsx @@ -1,10 +1,5 @@ // "use client"; -import React, { - useState, - useEffect, - useRef, - Fragment, -} from "react"; +import React, { useState, useEffect, useRef, Fragment } from "react"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; @@ -49,6 +44,7 @@ import { getUserLevelForAssignments } from "@/service/task"; import { AudioRecorder } from "react-audio-voice-recorder"; import FileUploader from "@/components/form/shared/file-uploader"; import { Upload } from "tus-js-client"; +import { getCsrfToken } from "@/service/auth"; const schema = z.object({ title: z.string().min(3, { message: "Required" }), @@ -75,9 +71,7 @@ const EventModal = ({ const [startDate, setStartDate] = useState(new Date()); const [endDate, setEndDate] = useState(new Date()); const [isPending, startTransition] = React.useTransition(); - const [agendaType, setAgendaType] = React.useState( - categories[0].value - ); + const [agendaType, setAgendaType] = React.useState(categories[0].value); const [listDest, setListDest] = useState([]); const [deleteModalOpen, setDeleteModalOpen] = useState(false); const [eventIdToDelete, setEventIdToDelete] = useState(null); @@ -97,6 +91,12 @@ const EventModal = ({ const [isVideoUploadFinish, setIsVideoUploadFinish] = useState(false); const [isTextUploadFinish, setIsTextUploadFinish] = useState(false); const [isAudioUploadFinish, setIsAudioUploadFinish] = useState(false); + let progressInfo: any = []; + let counterUpdateProgress = 0; + const [progressList, setProgressList] = useState([]); + let uploadPersen = 0; + const [isStartUpload, setIsStartUpload] = useState(false); + const [counterProgress, setCounterProgress] = useState(0); const { register, @@ -118,11 +118,17 @@ const EventModal = ({ const levelList = response?.data?.data.list; let listFiltered = []; if (agendaType == "polda") { - listFiltered = levelList.filter((level: any) => level.name != 'SATKER POLRI'); + listFiltered = levelList.filter( + (level: any) => level.name != "SATKER POLRI" + ); } else if (agendaType == "polres") { - listFiltered = levelList.filter((level: any) => level.name != 'SATKER POLRI'); + listFiltered = levelList.filter( + (level: any) => level.name != "SATKER POLRI" + ); } else if (agendaType == "satker") { - listFiltered = levelList.filter((level: any) => level.name == 'SATKER POLRI'); + listFiltered = levelList.filter( + (level: any) => level.name == "SATKER POLRI" + ); } setListDest(listFiltered); const initialExpandedState = listFiltered.reduce( @@ -181,52 +187,28 @@ const EventModal = ({ setIsImageUploadFinish(true); } imageFiles?.map(async (item: any, index: number) => { - await uploadResumableFile( - index, - String(id), - item, - "1", - "0" - ); + await uploadResumableFile(index, String(id), item, "1", "0"); }); if (videoFiles?.length == 0) { setIsVideoUploadFinish(true); } videoFiles?.map(async (item: any, index: number) => { - await uploadResumableFile( - index, - String(id), - item, - "2", - "0" - ); + await uploadResumableFile(index, String(id), item, "2", "0"); }); if (textFiles?.length == 0) { setIsTextUploadFinish(true); } textFiles?.map(async (item: any, index: number) => { - await uploadResumableFile( - index, - String(id), - item, - "3", - "0" - ); + await uploadResumableFile(index, String(id), item, "3", "0"); }); if (audioFiles?.length == 0) { setIsAudioUploadFinish(true); } audioFiles?.map(async (item: any, index: number) => { - await uploadResumableFile( - index, - String(id), - item, - "4", - "0" - ); + await uploadResumableFile(index, String(id), item, "4", "0"); }); // Optional: Use Swal for success feedback @@ -325,19 +307,24 @@ const EventModal = ({ }; async function uploadResumableFile( - idx: number, - id: string, - file: any, - fileTypeId: string, - duration: string + idx: number, + id: string, + file: any, + fileTypeId: string, + duration: string ) { console.log(idx, id, file, fileTypeId, duration); - // const placements = getPlacement(file.placements); - // console.log("Placementttt: : ", placements); + const resCsrf = await getCsrfToken(); + const csrfToken = resCsrf?.data?.token; + console.log("CSRF TOKEN : ", csrfToken); + const headers = { + "X-XSRF-TOKEN": csrfToken, + }; const upload = new Upload(file, { endpoint: `${process.env.NEXT_PUBLIC_API}/agenda-settings/file/upload`, + headers: headers, retryDelays: [0, 3000, 6000, 12_000, 24_000], chunkSize: 20_000, metadata: { @@ -345,8 +332,12 @@ const EventModal = ({ filename: file.name, filetype: file.type, fileTypeId: fileTypeId, - duration: "", - isWatermark: "true", // hardcode + duration, + isWatermark: "false", // hardcode + }, + onBeforeRequest: function (req) { + var xhr = req.getUnderlyingObject(); + xhr.withCredentials = true; }, onError: async (e: any) => { console.log("Error upload :", e); @@ -358,27 +349,18 @@ const EventModal = ({ bytesTotal: any ) => { const uploadPersen = Math.floor((bytesAccepted / bytesTotal) * 100); - // progressInfo[idx].percentage = uploadPersen; - // counterUpdateProgress++; - // console.log(counterUpdateProgress); - // setProgressList(progressInfo); - // setCounterProgress(counterUpdateProgress); + progressInfo[idx].percentage = uploadPersen; + counterUpdateProgress++; + console.log(counterUpdateProgress); + setProgressList(progressInfo); + setCounterProgress(counterUpdateProgress); }, onSuccess: async () => { - // uploadPersen = 100; - // progressInfo[idx].percentage = 100; - // counterUpdateProgress++; - // setCounterProgress(counterUpdateProgress); + uploadPersen = 100; + progressInfo[idx].percentage = 100; + counterUpdateProgress++; + setCounterProgress(counterUpdateProgress); successTodo(); - if (fileTypeId == '1'){ - setIsImageUploadFinish(true); - } else if (fileTypeId == '2'){ - setIsVideoUploadFinish(true); - } if (fileTypeId == '3'){ - setIsTextUploadFinish(true); - } if (fileTypeId == '4'){ - setIsAudioUploadFinish(true); - } }, }); @@ -387,14 +369,24 @@ const EventModal = ({ useEffect(() => { successTodo(); - }, [isImageUploadFinish, isVideoUploadFinish, isAudioUploadFinish, isTextUploadFinish]) + }, [ + isImageUploadFinish, + isVideoUploadFinish, + isAudioUploadFinish, + isTextUploadFinish, + ]); function successTodo() { - if (isImageUploadFinish && isVideoUploadFinish && isAudioUploadFinish && isTextUploadFinish) { + if ( + isImageUploadFinish && + isVideoUploadFinish && + isAudioUploadFinish && + isTextUploadFinish + ) { successSubmit("/in/contributor/agenda-setting"); } } - + const successSubmit = (redirect: string) => { MySwal.fire({ title: "Sukses", @@ -422,7 +414,9 @@ const EventModal = ({ > - {event?.length > 1 ? "Edit Agenda Setting" : "Create Agenda Setting"}{" "} + {event?.length > 1 + ? "Edit Agenda Setting" + : "Create Agenda Setting"}{" "} {event?.title} @@ -551,7 +545,9 @@ const EventModal = ({ )} /> - {(agendaType === "polda" || agendaType === "polres" || agendaType === "satker" )&& ( + {(agendaType === "polda" || + agendaType === "polres" || + agendaType === "satker") && (
@@ -588,50 +584,56 @@ const EventModal = ({ )} - {(agendaType == "polres" || agendaType == "satker") && expandedPolda[polda.id] && ( -
- - {polda?.subDestination?.map((polres: any) => ( -
+ )}
))} @@ -665,7 +667,7 @@ const EventModal = ({
-
-
- - - {event?.length > 1 ? "Updating..." : "Adding..."} + {event?.length > 1 ? "Updating..." : "Adding..."} - ) : event?.length > 1 ? ( + ) : event?.length > 1 ? ( "Update Agenda Setting" ) : ( "Simpan Agenda Setting" diff --git a/app/[locale]/(protected)/contributor/content/spit/table-spit/columns.tsx b/app/[locale]/(protected)/contributor/content/spit/table-spit/columns.tsx index ca5cf595..aa706fb3 100644 --- a/app/[locale]/(protected)/contributor/content/spit/table-spit/columns.tsx +++ b/app/[locale]/(protected)/contributor/content/spit/table-spit/columns.tsx @@ -112,12 +112,17 @@ const columns: ColumnDef[] = [ header: "Actions", enableHiding: false, cell: ({ row }) => { + const isDisabled = row.original.isPublish; // Check the isPublish value + return ( - + + )} +
+ ), }, + { accessorKey: "uniqueCode", header: "Code", diff --git a/app/[locale]/(protected)/contributor/task/forward/[id]/page.tsx b/app/[locale]/(protected)/contributor/task/forward/[id]/page.tsx new file mode 100644 index 00000000..2cb4a08c --- /dev/null +++ b/app/[locale]/(protected)/contributor/task/forward/[id]/page.tsx @@ -0,0 +1,18 @@ +import { Card, CardContent } from "@/components/ui/card"; +import SiteBreadcrumb from "@/components/site-breadcrumb"; +import FormTask from "@/components/form/task/task-form"; +import FormTaskDetail from "@/components/form/task/task-detail-form"; +import FormTaskForward from "@/components/form/task/task-forward-form"; + +const TaskForwardPage = async () => { + return ( +
+ +
+ +
+
+ ); +}; + +export default TaskForwardPage; diff --git a/app/[locale]/(protected)/shared/curated-content/giat-routine/image/detail/[id]/page.tsx b/app/[locale]/(protected)/shared/curated-content/giat-routine/image/detail/[id]/page.tsx index 9f776610..90858da6 100644 --- a/app/[locale]/(protected)/shared/curated-content/giat-routine/image/detail/[id]/page.tsx +++ b/app/[locale]/(protected)/shared/curated-content/giat-routine/image/detail/[id]/page.tsx @@ -21,8 +21,19 @@ import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group"; import Cookies from "js-cookie"; import { postBlog } from "@/service/blog/blog"; import { Textarea } from "@/components/ui/textarea"; -import { DotSquare, InboxIcon, PaperclipIcon, SmileIcon } from "lucide-react"; -import { detailMedia } from "@/service/curated-content/curated-content"; +import { + DotSquare, + InboxIcon, + PaperclipIcon, + SmileIcon, + TrashIcon, +} from "lucide-react"; +import { + deleteMediaCurationMessage, + detailMedia, + getMediaCurationMessage, + saveMediaCurationMessage, +} from "@/service/curated-content/curated-content"; import { Swiper, SwiperSlide } from "swiper/react"; import "swiper/css"; import "swiper/css/free-mode"; @@ -34,6 +45,14 @@ import "swiper/css/navigation"; import { FreeMode, Navigation, Pagination, Thumbs } from "swiper/modules"; import { Avatar, AvatarImage } from "@/components/ui/avatar"; import { Badge } from "@/components/ui/badge"; +import { listData } from "@/service/landing/landing"; +import { + createAssignmentResponse, + deleteAssignmentResponse, + getAssignmentResponseList, +} from "@/service/task"; +import { getCookiesDecrypt } from "@/lib/utils"; +import { close, loading } from "@/lib/swal"; const detailSchema = z.object({ title: z.string().min(1, { message: "Judul diperlukan" }), @@ -50,6 +69,24 @@ type Category = { categoryName: string; }; +const formatDate = (dateString: string): string => { + const date = new Date(dateString); + + // Pastikan validitas tanggal + if (isNaN(date.getTime())) { + throw new Error("Invalid date format"); + } + + // Format tanggal + const day = date.getDate().toString().padStart(2, "0"); + const month = (date.getMonth() + 1).toString().padStart(2, "0"); + const year = date.getFullYear(); + // const hours = date.getHours().toString().padStart(2, "0"); + + // Gabungkan hasil format + return `${day}-${month}-${year} `; +}; + export type curationDetail = { id: number; title: string; @@ -108,22 +145,21 @@ export default function DetailImage() { console.log(id); const editor = useRef(null); type DetailSchema = z.infer; - + const userLevelNumber = getCookiesDecrypt("ulne"); + const userId = getCookiesDecrypt("uie"); const [selectedFiles, setSelectedFiles] = useState([]); const taskId = Cookies.get("taskId"); const scheduleId = Cookies.get("scheduleId"); const scheduleType = Cookies.get("scheduleType"); const [selectedTarget, setSelectedTarget] = useState(""); - // const [detail, setDetail] = useState({ - // title: null, - // tags: null, - // files: [], - // fileType: null, - // }); const [detail, setDetail] = useState(); const [refresh] = useState(false); const [detailThumb, setDetailThumb] = useState([]); const [thumbsSwiper, setThumbsSwiper] = useState(null); + const [showInput, setShowInput] = useState(false); + const [selectedFileId, setSelectedFileId] = useState(null); + const [listData, setListData] = useState([]); + const [message, setMessage] = useState(""); const { control, @@ -142,31 +178,93 @@ export default function DetailImage() { setReplyingTo(commentId); }; - const addReply = (commentId: number) => { - if (replyText.trim()) { - const newCommentData = commentsData.map((comment: any) => { - if (comment.id === commentId) { - return { - ...comment, - replies: [ - ...comment.replies, - { - text: replyText, - username: "You", - date: new Date().toLocaleString(), - }, - ], - }; - } - return comment; - }); + const handleInputChange = (e: React.ChangeEvent) => { + setMessage(e.target.value); + }; - setCommentsData(newCommentData); - setReplyText(""); + useEffect(() => { + async function initState() { + // loading(); + const response = await getMediaCurationMessage(selectedFileId); + console.log("data", response?.data?.data); + console.log("userLvl", userLevelNumber); + setListData(response?.data?.data); + close(); + } + + initState(); + }, [selectedFileId]); + + // const postData = () => { + // sendSuggestionParent(); + // }; + + const postData = async () => { + if (message?.length > 1 && selectedFileId) { + try { + const data = { + mediaUploadFileId: selectedFileId, + message, + parentId: null, + }; + + const response = await saveMediaCurationMessage(data); + console.log("Komentar terkirim:", response); + + const responseGet = await getMediaCurationMessage(selectedFileId); + setListData(responseGet?.data?.data); + + setMessage(""); + } catch (error) { + console.error("Error posting comment:", error); + } + } else { + console.log("Pesan atau file ID tidak valid."); + } + }; + + const sendReplyData = async (parentId: number) => { + const inputElement = document.querySelector( + `#input-comment-${parentId}` + ) as HTMLTextAreaElement; + + if (inputElement?.value?.length > 1 && selectedFileId) { + loading(); + const data = { + mediaUploadFileId: selectedFileId, + message: inputElement.value, + parentId, + }; + + console.log("Sending reply:", data); + const response = await saveMediaCurationMessage(data); + console.log(response); + + const responseGet = await getMediaCurationMessage(selectedFileId); + console.log("Updated comments:", responseGet?.data?.data); + setListData(responseGet?.data?.data); + + inputElement.value = ""; + close(); setReplyingTo(null); } }; + async function deleteDataSuggestion(dataId: any) { + loading(); + const response = await deleteMediaCurationMessage(dataId); + console.log(response); + const responseGet = await getMediaCurationMessage(selectedFileId); + console.log(responseGet?.data?.data); + setListData(responseGet?.data?.data); + close(); + } + + const deleteData = (dataId: any) => { + deleteDataSuggestion(dataId); + console.log(dataId); + }; + useEffect(() => { async function initState() { if (id) { @@ -174,16 +272,29 @@ export default function DetailImage() { const details = response?.data?.data; setDetail(details); + setSelectedFileId(details?.files[0]?.id); const filesData = details.files || []; - const fileUrls = filesData.map((file: { thumbnailFileUrl: string }) => - file.thumbnailFileUrl ? file.thumbnailFileUrl : "default-image.jpg" - ); + const fileUrls = filesData.map((file: any) => ({ + id: file.id, + thumbnailFileUrl: file.thumbnailFileUrl || "default-image.jpg", + })); setDetailThumb(fileUrls); } } initState(); }, [id, refresh]); + const handleFileClick = async (fileId: any) => { + setSelectedFileId(fileId); + try { + const response = await getMediaCurationMessage(fileId); + console.log("Data komentar:", response?.data?.data); + setListData(response?.data?.data); + } catch (error) { + console.error("Error fetching comments:", error); + } + }; + return (
{detail !== undefined ? ( @@ -336,11 +447,14 @@ export default function DetailImage() { className="w-full" > {detailThumb?.map((data: any) => ( - + handleFileClick(data.id)} + > {` ))} @@ -357,11 +471,14 @@ export default function DetailImage() { // className="mySwiper2" > {detailThumb?.map((data: any) => ( - + handleFileClick(data.id)} + > {` ))} @@ -432,112 +549,186 @@ export default function DetailImage() {
-
- -
- - - - - -
-
- - - -
-
-
- {commentsData.map((comment) => ( -
- - - -
- - {comment.username} - - - {comment.date} - -

{comment.text}

-
handleReply(comment.id)} - > - - Balas +
+ - -
- )}
diff --git a/app/[locale]/(protected)/shared/curated-content/giat-routine/image/image.tsx b/app/[locale]/(protected)/shared/curated-content/giat-routine/image/image.tsx index 937b95bf..96600dc7 100644 --- a/app/[locale]/(protected)/shared/curated-content/giat-routine/image/image.tsx +++ b/app/[locale]/(protected)/shared/curated-content/giat-routine/image/image.tsx @@ -8,7 +8,8 @@ import { CarouselNext, CarouselPrevious, } from "@/components/ui/carousel"; -import { getListContent } from "@/service/landing/landing"; +import { listCuratedContent } from "@/service/curated-content/curated-content"; + import { formatDateToIndonesian, generateLocalizedPath, @@ -35,10 +36,12 @@ const ImageSliderPage = () => { const [imageData, setImageData] = useState(); const [displayImage, setDisplayImage] = useState([]); const [page, setPage] = useState(1); + const [limit, setLimit] = React.useState(10); + const [search, setSearch] = React.useState(""); useEffect(() => { fetchData(); - }, [page]); + }, [page, limit, search]); useEffect(() => { if (imageData?.length > 0) { @@ -49,12 +52,7 @@ const ImageSliderPage = () => { }, [imageData]); const fetchData = async () => { - const response = await getListContent({ - page: page - 1, - size: 6, - sortBy: "createdAt", - contentTypeId: "1", - }); + const response = await listCuratedContent(search, limit, page - 1, 1, "1"); console.log(response); const data = response?.data?.data; diff --git a/app/[locale]/(protected)/shared/curated-content/giat-routine/video/audio-visual.tsx b/app/[locale]/(protected)/shared/curated-content/giat-routine/video/audio-visual.tsx index 523f860e..07070ec0 100644 --- a/app/[locale]/(protected)/shared/curated-content/giat-routine/video/audio-visual.tsx +++ b/app/[locale]/(protected)/shared/curated-content/giat-routine/video/audio-visual.tsx @@ -1,6 +1,7 @@ "use client"; import { Link } from "@/components/navigation"; import { Card, CardContent } from "@/components/ui/card"; +import { listCuratedContent } from "@/service/curated-content/curated-content"; import { getListContent } from "@/service/landing/landing"; import { formatDateToIndonesian } from "@/utils/globals"; import { Icon } from "@iconify/react/dist/iconify.js"; @@ -11,10 +12,12 @@ const VideoSliderPage = () => { const [allVideoData, setAllVideoData] = useState([]); const [displayVideos, setDisplayVideos] = useState([]); const [page, setPage] = useState(1); + const [limit, setLimit] = React.useState(10); + const [search, setSearch] = React.useState(""); useEffect(() => { - initFetch(); - }, []); + fetchData(); + }, [page, limit, search]); useEffect(() => { if (allVideoData?.length > 0) { @@ -24,14 +27,13 @@ const VideoSliderPage = () => { } }, [allVideoData]); - const initFetch = async () => { - const response = await getListContent({ - page: page - 1, - size: 12, - sortBy: "createdAt", - contentTypeId: "2", - }); - setAllVideoData(response?.data?.data?.content || []); + const fetchData = async () => { + const response = await listCuratedContent(search, limit, page - 1, 1, "2"); + console.log(response); + + const data = response?.data?.data; + const contentData = data?.content; + setAllVideoData(contentData); }; const shuffleAndSetVideos = () => { diff --git a/app/[locale]/(public)/audio/detail/[slug]/page.tsx b/app/[locale]/(public)/audio/detail/[slug]/page.tsx index 277f956a..78e4b112 100644 --- a/app/[locale]/(public)/audio/detail/[slug]/page.tsx +++ b/app/[locale]/(public)/audio/detail/[slug]/page.tsx @@ -1,6 +1,6 @@ "use client"; -import { useParams, usePathname } from "next/navigation"; +import { useParams, usePathname, useSearchParams } from "next/navigation"; import React, { useEffect, useState } from "react"; import { Icon } from "@iconify/react/dist/iconify.js"; import NewContent from "@/components/landing-page/new-content"; @@ -10,7 +10,11 @@ import { BarWave } from "react-cssfx-loading"; import { useToast } from "@/components/ui/use-toast"; import { checkWishlistStatus, deleteWishlist, getDetail, saveWishlist } from "@/service/landing/landing"; import { getCookiesDecrypt } from "@/lib/utils"; -import { close, error, loading } from "@/config/swal"; +import { close, error, loading, successCallback } from "@/config/swal"; +import { sendMediaUploadToEmail } from "@/service/media-tracking/media-tracking"; +import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover"; +import { Input } from "@/components/ui/input"; +import { Button } from "@/components/ui/button"; const DetailAudio = () => { const [selectedSize, setSelectedSize] = useState("L"); @@ -29,8 +33,17 @@ const DetailAudio = () => { const [main, setMain] = useState(); const [resolutionSelected, setResolutionSelected] = useState("720"); const [imageSizeSelected, setImageSizeSelected] = useState("l"); - const userId = getCookiesDecrypt("uie"); + const [emailShareList, setEmailShareList] = useState(); + const [emailShareInput, setEmailShareInput] = useState(); + const [emailMessageInput, setEmailMessageInput] = useState(); + const searchParams = useSearchParams(); + const id = searchParams?.get("id"); + const [width, setWidth] = useState(); + const [content, setContent] = useState([]); + const userRoleId = getCookiesDecrypt("urie"); + + let typeString = "video"; useEffect(() => { initFetch(); @@ -41,6 +54,8 @@ const DetailAudio = () => { const response = await getDetail(String(slug)); console.log("detailAudio", response); setIsFromSPIT(response?.data?.data?.isFromSPIT); + setWidth(window.innerWidth); + setContent(response?.data.data); setMain({ id: response?.data?.data?.files[0]?.id, type: response?.data?.data?.fileType.name, @@ -216,6 +231,59 @@ const DetailAudio = () => { { label: "XS", value: "800 x 450 px" }, ]; + const handleShare = (type: any, url: any) => { + if (Number(userRoleId) < 1 || userRoleId == undefined) { + router.push("/auth/login"); + } else { + sendActivityLog(2); + sendActivityLog(4); + if (type == "wa" && width <= 768) { + window.open(`whatsapp://send?${url}`, "_blank"); + } else if (type == "wa" && width > 768) { + window.open(`https://web.whatsapp.com/send?${url}`, "_blank", "noreferrer"); + } else { + window.open(url); + } + } + }; + + async function shareToEmail() { + if (Number(userRoleId) < 1 || userRoleId == undefined) { + router.push("/auth/login"); + } else { + const data = { + mediaUploadId: id?.split("-")?.[0], + email: emailShareList || [emailShareInput], + message: emailMessageInput, + url: window.location.href, + }; + loading(); + const res = await sendMediaUploadToEmail(data); + if (res?.error) { + error(res.message); + return false; + } + close(); + successCallback("Konten Telah Dikirim"); + } + } + + const handleEmailList = (e: any) => { + const arrayEmail: any = []; + for (let i = 0; i < emailShareList?.length; i += 1) { + arrayEmail.push(emailShareList[i]); + } + if (e.which == 13) { + if (e.target.value) { + arrayEmail.push(e.target.value); + setEmailShareList(arrayEmail); + setEmailShareInput(""); + } + e.preventDefault(); + } + return false; + }; + return ( <>
@@ -310,6 +378,39 @@ const DetailAudio = () => { Download + + {/* Tombol Bagikan */} +
diff --git a/app/[locale]/(public)/content-management/download/page.tsx b/app/[locale]/(public)/content-management/download/page.tsx index e86b44b2..f1ffbf31 100644 --- a/app/[locale]/(public)/content-management/download/page.tsx +++ b/app/[locale]/(public)/content-management/download/page.tsx @@ -12,7 +12,11 @@ import SidebarManagement from "@/components/landing-page/sidebar-management"; import withReactContent from "sweetalert2-react-content"; import { getCookiesDecrypt } from "@/lib/utils"; import Swal from "sweetalert2"; -import { useToast } from "@/components/ui/use-toast"; +import { Icon } from "@iconify/react/dist/iconify.js"; +import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover"; +import { Input } from "@/components/ui/input"; +import { Button } from "@/components/ui/button"; +import { sendMediaUploadToEmail } from "@/service/media-tracking/media-tracking"; const Galery = (props: any) => { const [profile, setProfile] = useState(); @@ -20,7 +24,6 @@ const Galery = (props: any) => { const router = useRouter(); const MySwal = withReactContent(Swal); const searchParams = useSearchParams(); - // const { id } = router.query; const page: any = searchParams?.get("page"); const title = searchParams?.get("title"); const category = searchParams?.get("category"); @@ -28,7 +31,6 @@ const Galery = (props: any) => { const { isInstitute, instituteId } = props; const userId = getCookiesDecrypt("uie"); const userRoleId = getCookiesDecrypt("urie"); - const [totalContent, setTotalContent] = useState(); const [categoryFilter] = useState([]); const [formatFilter] = useState([]); @@ -42,6 +44,10 @@ const Galery = (props: any) => { const [refresh, setRefresh] = useState(false); const [, setCopySuccess] = useState(""); const [, setWishlistId] = useState(); + const [emailShareList, setEmailShareList] = useState(); + const [emailShareInput, setEmailShareInput] = useState(); + const [emailMessageInput, setEmailMessageInput] = useState(); + const id = searchParams?.get("id"); useEffect(() => { getDataVideo(); @@ -219,8 +225,44 @@ const Galery = (props: any) => { // toast.success("Link Berhasil Di Copy"); }; - const [hasMounted, setHasMounted] = useState(false); + async function shareToEmail() { + if (Number(userRoleId) < 1 || userRoleId == undefined) { + router.push("/auth/login"); + } else { + const data = { + mediaUploadId: id?.split("-")?.[0], + email: emailShareList || [emailShareInput], + message: emailMessageInput, + url: window.location.href, + }; + loading(); + const res = await sendMediaUploadToEmail(data); + if (res?.error) { + error(res.message); + return false; + } + close(); + successCallback("Konten Telah Dikirim"); + } + } + const handleEmailList = (e: any) => { + const arrayEmail: any = []; + for (let i = 0; i < emailShareList?.length; i += 1) { + arrayEmail.push(emailShareList[i]); + } + if (e.which == 13) { + if (e.target.value) { + arrayEmail.push(e.target.value); + setEmailShareList(arrayEmail); + setEmailShareInput(""); + } + e.preventDefault(); + } + return false; + }; + + const [hasMounted, setHasMounted] = useState(false); // Hooks useEffect(() => { setHasMounted(true); @@ -236,10 +278,10 @@ const Galery = (props: any) => {
-

Galeri Saya

+

Galeri Saya

-
-
+
+
{
-
+
{selectedTab == "video" ? ( contentVideo?.length > 0 ? (
{contentVideo?.map((video: any) => ( - - - - -
{video?.mediaUpload?.title}
- + + +
+ + +
{video?.mediaUpload?.title}
+ + + + + + + + +
+ + + + + +
+

Share Ke Email

+
+

Email Tujuan :

+ setEmailShareInput(event.target.value)} onKeyPress={handleEmailList} type="email" placeholder="Tekan Enter untuk input Email" /> +
+ +
+
+
+
+ handleDelete(video?.id)} className="flex items-center gap-1 hover:text-red-800 w-full rounded-lg"> + +

Hapus

+
+
+
+
))} @@ -296,11 +375,7 @@ const Galery = (props: any) => { contentAudio?.length > 0 ? (
{contentAudio?.map((audio: any) => ( - +
{ />
-
-
{audio?.mediaUpload?.title}
+
+ +
{audio?.mediaUpload?.title}
+
@@ -327,7 +404,42 @@ const Galery = (props: any) => {
- + + + + + + + +
+ + + + + +
+

Share Ke Email

+
+

Email Tujuan :

+ setEmailShareInput(event.target.value)} onKeyPress={handleEmailList} type="email" placeholder="Tekan Enter untuk input Email" /> +
+ +
+
+
+
+ handleDelete(audio?.id)} className="flex items-center gap-1 hover:text-red-800 w-full rounded-lg"> + +

Hapus

+
+
+
+
))}
) : ( @@ -339,12 +451,47 @@ const Galery = (props: any) => { contentImage?.length > 0 ? (
{contentImage?.map((image: any) => ( - - + +
{image?.mediaUpload?.title}
+ + + + + + + +
+ + + + + +
+

Share Ke Email

+
+

Email Tujuan :

+ setEmailShareInput(event.target.value)} onKeyPress={handleEmailList} type="email" placeholder="Tekan Enter untuk input Email" /> +
+ +
+
+
+
+ handleDelete(image?.id)} className="flex items-center gap-1 hover:text-red-800 w-full rounded-lg"> + +

Hapus

+
+
+
))} @@ -357,7 +504,7 @@ const Galery = (props: any) => { ) : contentDocument.length > 0 ? (
{contentDocument?.map((document: any) => ( - +
{
-
{document?.mediaUpload?.title}
+ + {document?.mediaUpload?.title} +
@@ -376,7 +525,42 @@ const Galery = (props: any) => { Download Dokumen
- + + + + + + + +
+ + + + + +
+

Share Ke Email

+
+

Email Tujuan :

+ setEmailShareInput(event.target.value)} onKeyPress={handleEmailList} type="email" placeholder="Tekan Enter untuk input Email" /> +
+ +
+
+
+
+ handleDelete(document?.id)} className="flex items-center gap-1 hover:text-red-800 w-full rounded-lg"> + +

Hapus

+
+
+
+
))}
) : ( diff --git a/app/[locale]/(public)/content-management/galery/page.tsx b/app/[locale]/(public)/content-management/galery/page.tsx index 797500b8..6bdaf09a 100644 --- a/app/[locale]/(public)/content-management/galery/page.tsx +++ b/app/[locale]/(public)/content-management/galery/page.tsx @@ -13,9 +13,12 @@ import withReactContent from "sweetalert2-react-content"; import { getCookiesDecrypt } from "@/lib/utils"; import Swal from "sweetalert2"; import { useToast } from "@/components/ui/use-toast"; -import { Icon } from "@iconify/react/dist/iconify.js"; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from "@/components/ui/dropdown-menu"; +import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover"; +import { Icon } from "@iconify/react/dist/iconify.js"; +import { Input } from "@/components/ui/input"; import { Button } from "@/components/ui/button"; +import { sendMediaUploadToEmail } from "@/service/media-tracking/media-tracking"; const Galery = (props: any) => { const [profile, setProfile] = useState(); @@ -23,7 +26,6 @@ const Galery = (props: any) => { const router = useRouter(); const MySwal = withReactContent(Swal); const searchParams = useSearchParams(); - // const { id } = router.query; const page: any = searchParams?.get("page"); const title = searchParams?.get("title"); const category = searchParams?.get("category"); @@ -45,6 +47,10 @@ const Galery = (props: any) => { const [refresh, setRefresh] = useState(false); const [, setCopySuccess] = useState(""); const [, setWishlistId] = useState(); + const [emailShareList, setEmailShareList] = useState(); + const [emailShareInput, setEmailShareInput] = useState(); + const [emailMessageInput, setEmailMessageInput] = useState(); + const id = searchParams?.get("id"); useEffect(() => { getDataVideo(); @@ -225,8 +231,44 @@ const Galery = (props: any) => { }); }; - const [hasMounted, setHasMounted] = useState(false); + async function shareToEmail() { + if (Number(userRoleId) < 1 || userRoleId == undefined) { + router.push("/auth/login"); + } else { + const data = { + mediaUploadId: id?.split("-")?.[0], + email: emailShareList || [emailShareInput], + message: emailMessageInput, + url: window.location.href, + }; + loading(); + const res = await sendMediaUploadToEmail(data); + if (res?.error) { + error(res.message); + return false; + } + close(); + successCallback("Konten Telah Dikirim"); + } + } + const handleEmailList = (e: any) => { + const arrayEmail: any = []; + for (let i = 0; i < emailShareList?.length; i += 1) { + arrayEmail.push(emailShareList[i]); + } + if (e.which == 13) { + if (e.target.value) { + arrayEmail.push(e.target.value); + setEmailShareList(arrayEmail); + setEmailShareInput(""); + } + e.preventDefault(); + } + return false; + }; + + const [hasMounted, setHasMounted] = useState(false); // Hooks useEffect(() => { setHasMounted(true); @@ -244,8 +286,8 @@ const Galery = (props: any) => {

Galeri {profile?.institute?.name}

-
-
+
+
{
-
+
{selectedTab == "video" ? ( contentVideo?.length > 0 ? (
@@ -289,37 +331,42 @@ const Galery = (props: any) => { -
{video?.mediaUpload?.title}
- - - + + + - - - - - - - - -

Content Rewrite

- -
- -
- -
-
-
-
+ + +
+ + + + + +
+

Share Ke Email

+
+

Email Tujuan :

+ setEmailShareInput(event.target.value)} onKeyPress={handleEmailList} type="email" placeholder="Tekan Enter untuk input Email" /> +
+ +
+
+
+
+ handleDelete(video?.id)} className="flex items-center gap-2 hover:text-red-800 w-full rounded-lg"> + +

Hapus

+
+
+
@@ -361,35 +408,41 @@ const Galery = (props: any) => {
- - - + + + - - - - - - - - -

Content Rewrite

- -
- -
- -
-
-
-
+ + +
+ + + + + +
+

Share Ke Email

+
+

Email Tujuan :

+ setEmailShareInput(event.target.value)} onKeyPress={handleEmailList} type="email" placeholder="Tekan Enter untuk input Email" /> +
+ +
+
+
+
+ handleDelete(audio?.id)} className="flex items-center gap-1 hover:text-red-800 w-full rounded-lg"> + +

Hapus

+
+
+
))}
@@ -402,41 +455,47 @@ const Galery = (props: any) => { contentImage?.length > 0 ? (
{contentImage?.map((image: any) => ( - + -
{image?.mediaUpload?.title}
+
{image?.mediaUpload?.title}
- - - + + + - - - - - - - - -

Content Rewrite

- -
- -
- -
-
-
-
+ + +
+ + + + + +
+

Share Ke Email

+
+

Email Tujuan :

+ setEmailShareInput(event.target.value)} onKeyPress={handleEmailList} type="email" placeholder="Tekan Enter untuk input Email" /> +
+ +
+
+
+
+ handleDelete(image?.id)} className="flex items-center gap-1 hover:text-red-800 w-full rounded-lg"> + +

Hapus

+
+
+
))} @@ -470,35 +529,41 @@ const Galery = (props: any) => { Download Dokumen
- - - + + + - - - - - - - - -

Content Rewrite

- -
- -
- -
-
-
-
+ + +
+ + + + + +
+

Share Ke Email

+
+

Email Tujuan :

+ setEmailShareInput(event.target.value)} onKeyPress={handleEmailList} type="email" placeholder="Tekan Enter untuk input Email" /> +
+ +
+
+
+
+ handleDelete(document?.id)} className="flex items-center gap-1 hover:text-red-800 w-full rounded-lg"> + +

Hapus

+
+
+
))}
diff --git a/app/[locale]/(public)/content-management/rewrite/create/[id]/page.tsx b/app/[locale]/(public)/content-management/rewrite/create/[id]/page.tsx index 9cba820d..4dca7923 100644 --- a/app/[locale]/(public)/content-management/rewrite/create/[id]/page.tsx +++ b/app/[locale]/(public)/content-management/rewrite/create/[id]/page.tsx @@ -35,7 +35,7 @@ const imageSchema = z.object({ // tags: z.string().min(1, { message: "Judul diperlukan" }), }); -const page = (props: { states?: string }) => { +const page = (props: any) => { const { states } = props; const MySwal = withReactContent(Swal); const router = useRouter(); @@ -255,7 +255,7 @@ const page = (props: { states?: string }) => { const maxRetries = 20; try { - const waitForStatusUpdate = async () => { + const waitForStatusUpdate: any = async () => { while (retryCount < maxRetries) { const res = await getDetailArticle(id); const articleData = res?.data?.data; @@ -276,7 +276,7 @@ const page = (props: { states?: string }) => { const articleImagesData = articleData?.imagesUrl?.split(","); setValue("description", cleanArticleBody || ""); setArticleBody(cleanArticleBody || ""); - setDetailData(articleData); + setDetailArticle(articleData); setSelectedArticleId(id); setArticleImages(articleImagesData || []); } catch (error) { @@ -404,7 +404,11 @@ const page = (props: { states?: string }) => { {articleIds.map((id: any, index: any) => (

handleArticleIdClick(id)} > {id} @@ -429,7 +433,7 @@ const page = (props: { states?: string }) => { ) } /> - {articleBody === null || articleBody === "" ?

Deskripsi tidak boleh kosong*
: ""} + {articleBody === null || articleBody === "" ?

Deskripsi tidak boleh kosong*

: ""}
-
diff --git a/app/[locale]/(public)/content-management/rewrite/detail/[id]/page.tsx b/app/[locale]/(public)/content-management/rewrite/detail/[id]/page.tsx index 74a90820..678343d5 100644 --- a/app/[locale]/(public)/content-management/rewrite/detail/[id]/page.tsx +++ b/app/[locale]/(public)/content-management/rewrite/detail/[id]/page.tsx @@ -4,7 +4,7 @@ import { close, error, loading } from "@/config/swal"; import { useRouter } from "@/i18n/routing"; import { getCookiesDecrypt } from "@/lib/utils"; import { getContentRewrite, getInfoProfile } from "@/service/landing/landing"; -import { useSearchParams } from "next/navigation"; +import { useParams, useSearchParams } from "next/navigation"; import React, { useEffect, useState } from "react"; import Swal from "sweetalert2"; import withReactContent from "sweetalert2-react-content"; @@ -15,15 +15,17 @@ import { generateDataArticle } from "@/service/content/ai"; import HeaderManagement from "@/components/landing-page/header-management"; import SidebarManagement from "@/components/landing-page/sidebar-management"; import { saveContentRewrite } from "@/service/content/content"; +import CustomEditor from "@/components/editor/custom-editor"; +import { Input } from "@/components/ui/input"; -const page = (props: any) => { - const { states } = props; +const page = () => { const [profile, setProfile] = useState(); const MySwal = withReactContent(Swal); const searchParams = useSearchParams(); const router = useRouter(); const [, setLoadingState] = useState(false); - const id: any = searchParams?.get("title"); + const getParams = useParams(); + const id: any = getParams?.id; const [content, setContent] = useState([]); const [isFromSPIT, setIsFromSPIT] = useState(false); const [listSuggestion, setListSuggestion] = useState(); @@ -199,96 +201,95 @@ const page = (props: any) => {
Detail Content Rewrite
- {/* {content && ( */} - <> -
-
-

Judul

-
- setSelectedTitle(e.target.value)} - /> -
-
-
-
-

Main Keyword

+ {content && ( + <> +
+
+

Judul

-
- -
-
-
-
- -
- - - // setSelectedMainKeyword(e.target.value) - // } - placeholder="Masukan Additional Keyword disini!" - defaultValue={content?.additionalKeyword} + className={`w-full mb-3 ${errors.title ? "is-invalid" : ""}`} + {...register("title", { + value: content?.title, + })} + id="title" + defaultValue={content?.title} + // onChange={(e) => setSelectedTitle(e.target.value)} />
-
+
+
+
+

Main Keyword

+
+
+ +
+
+
+
+ +
+ + // setSelectedMainKeyword(e.target.value) + // } + placeholder="Masukan Additional Keyword disini!" + defaultValue={content?.additionalKeyword} + /> +
+
-
-
+
+
+
+ +
+ + // setSelectedMainKeyword(e.target.value) + // } + placeholder="Masukan Meta Title disini!" + defaultValue={content?.metaTitle} + /> +
+
+
+ +
+ + // setSelectedMainKeyword(e.target.value) + // } + placeholder="Masukan Meta Description disini!" + defaultValue={content?.metaDescription} + /> +
+
+ +
- + + {}} initialData={articleBody || ""} />
- - // setSelectedMainKeyword(e.target.value) - // } - placeholder="Masukan Meta Title disini!" - defaultValue={content?.metaTitle} - />
-
-
- -
- - // setSelectedMainKeyword(e.target.value) - // } - placeholder="Masukan Meta Description disini!" - defaultValue={content?.metaDescription} - /> -
-
- -
-
- -
- {articleBody === null || articleBody === "" ?
Deskripsi tidak boleh kosong
: ""} -
- - {/* )} */} + + )}
diff --git a/app/[locale]/(public)/content-management/rewrite/page.tsx b/app/[locale]/(public)/content-management/rewrite/page.tsx index ec35c993..f9d1cf4a 100644 --- a/app/[locale]/(public)/content-management/rewrite/page.tsx +++ b/app/[locale]/(public)/content-management/rewrite/page.tsx @@ -11,8 +11,13 @@ import Swal from "sweetalert2"; import withReactContent from "sweetalert2-react-content"; import { Card, CardContent } from "@/components/ui/card"; import { Link } from "@/i18n/routing"; +import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover"; +import { Icon } from "@iconify/react/dist/iconify.js"; +import { Input } from "@/components/ui/input"; +import { Button } from "@/components/ui/button"; +import { sendMediaUploadToEmail } from "@/service/media-tracking/media-tracking"; -const page = (props: any) => { +const page = () => { const [, setProfile] = useState(); const router = useRouter(); const searchParams = useSearchParams(); @@ -21,23 +26,21 @@ const page = (props: any) => { const title = searchParams?.get("title"); const category = searchParams?.get("category"); const pages = page ? page - 1 : 0; - - const { isInstitute, instituteId } = props; const userId = getCookiesDecrypt("uie"); const userRoleId = getCookiesDecrypt("urie"); - const [, setGetTotalPage] = useState(); const [totalContent, setTotalContent] = useState(); const [contentImage, setContentImage] = useState([]); - const [categoryFilter] = useState([]); const [formatFilter] = useState([]); const [sortBy] = useState(); - const [refresh, setRefresh] = useState(false); const [, setCopySuccess] = useState(""); - const [, setWishlistId] = useState(); + const [emailShareList, setEmailShareList] = useState(); + const [emailShareInput, setEmailShareInput] = useState(); + const [emailMessageInput, setEmailMessageInput] = useState(); + const id = searchParams?.get("id"); useEffect(() => { async function initState() { @@ -153,6 +156,43 @@ const page = (props: any) => { } }; + async function shareToEmail() { + if (Number(userRoleId) < 1 || userRoleId == undefined) { + router.push("/auth/login"); + } else { + const data = { + mediaUploadId: id?.split("-")?.[0], + email: emailShareList || [emailShareInput], + message: emailMessageInput, + url: window.location.href, + }; + loading(); + const res = await sendMediaUploadToEmail(data); + if (res?.error) { + error(res.message); + return false; + } + close(); + successCallback("Konten Telah Dikirim"); + } + } + + const handleEmailList = (e: any) => { + const arrayEmail: any = []; + for (let i = 0; i < emailShareList?.length; i += 1) { + arrayEmail.push(emailShareList[i]); + } + if (e.which == 13) { + if (e.target.value) { + arrayEmail.push(e.target.value); + setEmailShareList(arrayEmail); + setEmailShareInput(""); + } + e.preventDefault(); + } + return false; + }; + return ( <> @@ -162,16 +202,53 @@ const page = (props: any) => {

Galeri Content Rewrite

-
+
{contentImage?.length > 0 ? (
{contentImage?.map((image: any) => ( - + - - +
+ + +
{image?.title}
- + + + + + + + +
+ + + + + +
+

Share Ke Email

+
+

Email Tujuan :

+ setEmailShareInput(event.target.value)} onKeyPress={handleEmailList} type="email" placeholder="Tekan Enter untuk input Email" /> +
+ +
+
+
+
+ handleDelete(image?.id)} className="flex items-center gap-1 hover:text-red-800 w-full rounded-lg"> + +

Hapus

+
+
+
+
))} diff --git a/app/[locale]/(public)/document/detail/[slug]/page.tsx b/app/[locale]/(public)/document/detail/[slug]/page.tsx index d247839b..6548f80a 100644 --- a/app/[locale]/(public)/document/detail/[slug]/page.tsx +++ b/app/[locale]/(public)/document/detail/[slug]/page.tsx @@ -1,15 +1,19 @@ "use client"; -import { useParams, usePathname } from "next/navigation"; +import { useParams, usePathname, useSearchParams } from "next/navigation"; import React, { useEffect, useState } from "react"; import { Icon } from "@iconify/react/dist/iconify.js"; import NewContent from "@/components/landing-page/new-content"; import { Textarea } from "@/components/ui/textarea"; import { getCookiesDecrypt } from "@/lib/utils"; import { checkWishlistStatus, deleteWishlist, getDetail, saveWishlist } from "@/service/landing/landing"; -import { close, error, loading } from "@/config/swal"; +import { close, error, loading, successCallback } from "@/config/swal"; import { useToast } from "@/components/ui/use-toast"; import { Link, useRouter } from "@/i18n/routing"; +import { sendMediaUploadToEmail } from "@/service/media-tracking/media-tracking"; +import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover"; +import { Input } from "@/components/ui/input"; +import { Button } from "@/components/ui/button"; const DetailDocument = () => { const [selectedSize, setSelectedSize] = useState("L"); @@ -29,8 +33,17 @@ const DetailDocument = () => { const [main, setMain] = useState(); const [resolutionSelected, setResolutionSelected] = useState("720"); const [imageSizeSelected, setImageSizeSelected] = useState("l"); - const userId = getCookiesDecrypt("uie"); + const [emailShareList, setEmailShareList] = useState(); + const [emailShareInput, setEmailShareInput] = useState(); + const [emailMessageInput, setEmailMessageInput] = useState(); + const searchParams = useSearchParams(); + const id = searchParams?.get("id"); + const [width, setWidth] = useState(); + const [content, setContent] = useState([]); + const userRoleId = getCookiesDecrypt("urie"); + + let typeString = "video"; useEffect(() => { initFetch(); @@ -41,6 +54,8 @@ const DetailDocument = () => { const response = await getDetail(String(slug)); console.log("detailDocument", response); setIsFromSPIT(response?.data?.data?.isFromSPIT); + setWidth(window.innerWidth); + setContent(response?.data.data); setMain({ id: response?.data?.data?.files[0]?.id, type: response?.data?.data?.fileType.name, @@ -216,6 +231,59 @@ const DetailDocument = () => { xhr.send(); }; + const handleShare = (type: any, url: any) => { + if (Number(userRoleId) < 1 || userRoleId == undefined) { + router.push("/auth/login"); + } else { + sendActivityLog(2); + sendActivityLog(4); + if (type == "wa" && width <= 768) { + window.open(`whatsapp://send?${url}`, "_blank"); + } else if (type == "wa" && width > 768) { + window.open(`https://web.whatsapp.com/send?${url}`, "_blank", "noreferrer"); + } else { + window.open(url); + } + } + }; + + async function shareToEmail() { + if (Number(userRoleId) < 1 || userRoleId == undefined) { + router.push("/auth/login"); + } else { + const data = { + mediaUploadId: id?.split("-")?.[0], + email: emailShareList || [emailShareInput], + message: emailMessageInput, + url: window.location.href, + }; + loading(); + const res = await sendMediaUploadToEmail(data); + if (res?.error) { + error(res.message); + return false; + } + close(); + successCallback("Konten Telah Dikirim"); + } + } + + const handleEmailList = (e: any) => { + const arrayEmail: any = []; + for (let i = 0; i < emailShareList?.length; i += 1) { + arrayEmail.push(emailShareList[i]); + } + if (e.which == 13) { + if (e.target.value) { + arrayEmail.push(e.target.value); + setEmailShareList(arrayEmail); + setEmailShareInput(""); + } + e.preventDefault(); + } + return false; + }; + return ( <>
@@ -307,6 +375,39 @@ const DetailDocument = () => { Download + + {/* Tombol Bagikan */} +
diff --git a/app/[locale]/(public)/image/detail/[slug]/page.tsx b/app/[locale]/(public)/image/detail/[slug]/page.tsx index 9c84bf5e..10b24956 100644 --- a/app/[locale]/(public)/image/detail/[slug]/page.tsx +++ b/app/[locale]/(public)/image/detail/[slug]/page.tsx @@ -1,15 +1,19 @@ "use client"; import { Textarea } from "@/components/ui/textarea"; -import { useParams, usePathname } from "next/navigation"; +import { useParams, usePathname, useSearchParams } from "next/navigation"; import React, { useEffect, useState } from "react"; import { Icon } from "@iconify/react/dist/iconify.js"; import NewContent from "@/components/landing-page/new-content"; import { useToast } from "@/components/ui/use-toast"; import { getCookiesDecrypt } from "@/lib/utils"; -import { close, error, loading } from "@/config/swal"; +import { close, error, loading, successCallback } from "@/config/swal"; import { checkWishlistStatus, deleteWishlist, getDetail, saveWishlist } from "@/service/landing/landing"; import { Link, useRouter } from "@/i18n/routing"; +import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover"; +import { Input } from "@/components/ui/input"; +import { Button } from "@/components/ui/button"; +import { sendMediaUploadToEmail } from "@/service/media-tracking/media-tracking"; const DetailInfo = () => { const [selectedSize, setSelectedSize] = useState("L"); @@ -29,8 +33,17 @@ const DetailInfo = () => { const [main, setMain] = useState(); const [resolutionSelected, setResolutionSelected] = useState("720"); const [imageSizeSelected, setImageSizeSelected] = useState("l"); - const userId = getCookiesDecrypt("uie"); + const [content, setContent] = useState([]); + const [emailShareList, setEmailShareList] = useState(); + const [emailShareInput, setEmailShareInput] = useState(); + const [emailMessageInput, setEmailMessageInput] = useState(); + const searchParams = useSearchParams(); + const id = searchParams?.get("id"); + const [width, setWidth] = useState(); + const userRoleId = getCookiesDecrypt("urie"); + + let typeString = "video"; useEffect(() => { initFetch(); @@ -41,6 +54,8 @@ const DetailInfo = () => { const response = await getDetail(String(slug)); console.log("detailImage", response); setIsFromSPIT(response?.data?.data?.isFromSPIT); + setWidth(window.innerWidth); + setContent(response?.data.data); setMain({ id: response?.data?.data?.files[0]?.id, type: response?.data?.data?.fileType.name, @@ -219,6 +234,59 @@ const DetailInfo = () => { xhr.send(); }; + const handleShare = (type: any, url: any) => { + if (Number(userRoleId) < 1 || userRoleId == undefined) { + router.push("/auth/login"); + } else { + sendActivityLog(2); + sendActivityLog(4); + if (type == "wa" && width <= 768) { + window.open(`whatsapp://send?${url}`, "_blank"); + } else if (type == "wa" && width > 768) { + window.open(`https://web.whatsapp.com/send?${url}`, "_blank", "noreferrer"); + } else { + window.open(url); + } + } + }; + + async function shareToEmail() { + if (Number(userRoleId) < 1 || userRoleId == undefined) { + router.push("/auth/login"); + } else { + const data = { + mediaUploadId: id?.split("-")?.[0], + email: emailShareList || [emailShareInput], + message: emailMessageInput, + url: window.location.href, + }; + loading(); + const res = await sendMediaUploadToEmail(data); + if (res?.error) { + error(res.message); + return false; + } + close(); + successCallback("Konten Telah Dikirim"); + } + } + + const handleEmailList = (e: any) => { + const arrayEmail: any = []; + for (let i = 0; i < emailShareList?.length; i += 1) { + arrayEmail.push(emailShareList[i]); + } + if (e.which == 13) { + if (e.target.value) { + arrayEmail.push(e.target.value); + setEmailShareList(arrayEmail); + setEmailShareInput(""); + } + e.preventDefault(); + } + return false; + }; + return ( <>
@@ -296,7 +364,7 @@ const DetailInfo = () => { {sizes.map((size: any) => (
- setSelectedSize(size.label)} className="text-red-600 focus:ring-red-600" /> + setImageSizeSelected(e.target.value)} className="text-red-600 focus:ring-red-600" />
{size.label}
@@ -321,6 +389,39 @@ const DetailInfo = () => { Download + + {/* Tombol Bagikan */} +
diff --git a/app/[locale]/(public)/image/filter/page.tsx b/app/[locale]/(public)/image/filter/page.tsx index b874433d..a7e9b1e7 100644 --- a/app/[locale]/(public)/image/filter/page.tsx +++ b/app/[locale]/(public)/image/filter/page.tsx @@ -486,7 +486,7 @@ const FilterPage = () => { - +
{formatDateToIndonesian(new Date(image?.createdAt))} {image?.timezone ? image?.timezone : "WIB"}| {image?.clickCount}{" "} diff --git a/app/[locale]/(public)/inbox/layout.tsx b/app/[locale]/(public)/inbox/layout.tsx new file mode 100644 index 00000000..fab820cf --- /dev/null +++ b/app/[locale]/(public)/inbox/layout.tsx @@ -0,0 +1,22 @@ +import LayoutProvider from "@/providers/layout.provider"; +import LayoutContentProvider from "@/providers/content.provider"; +import DashCodeSidebar from "@/components/partials/sidebar"; +import DashCodeFooter from "@/components/partials/footer"; +import ThemeCustomize from "@/components/partials/customizer"; +import DashCodeHeader from "@/components/partials/header"; + +import { redirect } from "@/components/navigation"; +import Footer from "@/components/landing-page/footer"; +import Navbar from "@/components/landing-page/navbar"; + +const layout = async ({ children }: { children: React.ReactNode }) => { + return ( + <> + + {children} +
+ + ); +}; + +export default layout; diff --git a/app/[locale]/(public)/inbox/page.tsx b/app/[locale]/(public)/inbox/page.tsx new file mode 100644 index 00000000..f7626ff3 --- /dev/null +++ b/app/[locale]/(public)/inbox/page.tsx @@ -0,0 +1,153 @@ +"use client"; + +import { Link, usePathname } from "@/i18n/routing"; +import { getUserNotifications } from "@/service/landing/landing"; +import { getTimestamp } from "@/utils/globals"; +import { Icon } from "@iconify/react/dist/iconify.js"; +import { useSearchParams } from "next/navigation"; +import { useRouter } from "next/navigation"; +import React, { useEffect, useState } from "react"; + +const InboxSection = () => { + const router = useRouter(); + const pathname = usePathname(); + const isUpdate = pathname.includes("update"); + const searchParams = useSearchParams(); + + const page: any = searchParams?.get("page"); + + const pages = page ? page - 1 : 0; + + const [notifications, setNotifications] = useState([]); + const [getTotalData, setGetTotalData] = useState(); + const [, setGetTotalPage] = useState(); + + useEffect(() => { + async function getNotif() { + const response = await getUserNotifications(pages, 2); + setNotifications(response?.data?.data?.content); + setGetTotalData(response?.data?.data?.totalElements); + setGetTotalPage(response?.data?.data?.totalPage); + } + + async function getNotifUpdate() { + const response = await getUserNotifications(pages, 3); + setNotifications(response?.data?.data?.content); + setGetTotalData(response?.data?.data?.totalElements); + setGetTotalPage(response?.data?.data?.totalPage); + } + + if (isUpdate) { + getNotifUpdate(); + } else { + getNotif(); + } + }, [pages]); + + return ( + + ); +}; + +export default InboxSection; diff --git a/app/[locale]/(public)/inbox/update/page.tsx b/app/[locale]/(public)/inbox/update/page.tsx new file mode 100644 index 00000000..4f31e10a --- /dev/null +++ b/app/[locale]/(public)/inbox/update/page.tsx @@ -0,0 +1,150 @@ +"use client"; + +import { Link, usePathname } from "@/i18n/routing"; +import { getUserNotifications } from "@/service/landing/landing"; +import { getTimestamp } from "@/utils/globals"; +import { Icon } from "@iconify/react/dist/iconify.js"; +import { useSearchParams } from "next/navigation"; +import { useRouter } from "next/navigation"; +import React, { useEffect, useState } from "react"; + +const UpdateSection = () => { + const pathname = usePathname(); + const isUpdate = pathname.includes("update"); + const searchParams = useSearchParams(); + const page: any = searchParams?.get("page"); + const pages = page ? page - 1 : 0; + + const [notifications, setNotifications] = useState([]); + const [getTotalData, setGetTotalData] = useState(); + const [, setGetTotalPage] = useState(); + + useEffect(() => { + async function getNotif() { + const response = await getUserNotifications(pages, 2); + setNotifications(response?.data?.data?.content); + setGetTotalData(response?.data?.data?.totalElements); + setGetTotalPage(response?.data?.data?.totalPage); + } + + async function getNotifUpdate() { + const response = await getUserNotifications(pages, 3); + setNotifications(response?.data?.data?.content); + setGetTotalData(response?.data?.data?.totalElements); + setGetTotalPage(response?.data?.data?.totalPage); + } + + if (isUpdate) { + getNotifUpdate(); + } else { + getNotif(); + } + }, [pages]); + + return ( + + ); +}; + +export default UpdateSection; diff --git a/app/[locale]/(public)/video/detail/[slug]/page.tsx b/app/[locale]/(public)/video/detail/[slug]/page.tsx index 5b9f747a..747b61ea 100644 --- a/app/[locale]/(public)/video/detail/[slug]/page.tsx +++ b/app/[locale]/(public)/video/detail/[slug]/page.tsx @@ -1,6 +1,6 @@ "use client"; -import { useParams, usePathname } from "next/navigation"; +import { useParams, usePathname, useSearchParams } from "next/navigation"; import React, { useEffect, useState } from "react"; import { Icon } from "@iconify/react/dist/iconify.js"; import { checkWishlistStatus, deleteWishlist, getDetail, saveWishlist } from "@/service/landing/landing"; @@ -9,8 +9,13 @@ import NewContent from "@/components/landing-page/new-content"; import { Link, useRouter } from "@/i18n/routing"; import { Textarea } from "@/components/ui/textarea"; import { getCookiesDecrypt } from "@/lib/utils"; -import { close, error, loading } from "@/config/swal"; +import { close, error, loading, successCallback } from "@/config/swal"; import { useToast } from "@/components/ui/use-toast"; +import { sendMediaUploadToEmail } from "@/service/media-tracking/media-tracking"; +import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover"; +import { Input } from "@/components/ui/input"; +import { Button } from "@/components/ui/button"; + const DetailVideo = () => { const [selectedSize, setSelectedSize] = useState("L"); @@ -28,8 +33,17 @@ const DetailVideo = () => { const [isFromSPIT, setIsFromSPIT] = useState(false); const [main, setMain] = useState(); const [resolutionSelected, setResolutionSelected] = useState("720"); - const userId = getCookiesDecrypt("uie"); + const [emailShareList, setEmailShareList] = useState(); + const [emailShareInput, setEmailShareInput] = useState(); + const [emailMessageInput, setEmailMessageInput] = useState(); + const searchParams = useSearchParams(); + const id = searchParams?.get("id"); + const [width, setWidth] = useState(); + const [content, setContent] = useState([]); + const userRoleId = getCookiesDecrypt("urie"); + + let typeString = "video"; useEffect(() => { initFetch(); @@ -40,6 +54,8 @@ const DetailVideo = () => { const response = await getDetail(String(slug)); console.log("detailVideo", response); setIsFromSPIT(response?.data?.data?.isFromSPIT); + setWidth(window.innerWidth); + setContent(response?.data.data); setMain({ id: response?.data?.data?.files[0]?.id, type: response?.data?.data?.fileType.name, @@ -216,6 +232,59 @@ const DetailVideo = () => { xhr.send(); }; + const handleShare = (type: any, url: any) => { + if (Number(userRoleId) < 1 || userRoleId == undefined) { + router.push("/auth/login"); + } else { + sendActivityLog(2); + sendActivityLog(4); + if (type == "wa" && width <= 768) { + window.open(`whatsapp://send?${url}`, "_blank"); + } else if (type == "wa" && width > 768) { + window.open(`https://web.whatsapp.com/send?${url}`, "_blank", "noreferrer"); + } else { + window.open(url); + } + } + }; + + async function shareToEmail() { + if (Number(userRoleId) < 1 || userRoleId == undefined) { + router.push("/auth/login"); + } else { + const data = { + mediaUploadId: id?.split("-")?.[0], + email: emailShareList || [emailShareInput], + message: emailMessageInput, + url: window.location.href, + }; + loading(); + const res = await sendMediaUploadToEmail(data); + if (res?.error) { + error(res.message); + return false; + } + close(); + successCallback("Konten Telah Dikirim"); + } + } + + const handleEmailList = (e: any) => { + const arrayEmail: any = []; + for (let i = 0; i < emailShareList?.length; i += 1) { + arrayEmail.push(emailShareList[i]); + } + if (e.which == 13) { + if (e.target.value) { + arrayEmail.push(e.target.value); + setEmailShareList(arrayEmail); + setEmailShareInput(""); + } + e.preventDefault(); + } + return false; + }; + return ( <>
@@ -318,6 +387,39 @@ const DetailVideo = () => { Download + + {/* Tombol Bagikan */} +
diff --git a/app/[locale]/auth/page.tsx b/app/[locale]/auth/page.tsx index 2c642a15..b627a490 100644 --- a/app/[locale]/auth/page.tsx +++ b/app/[locale]/auth/page.tsx @@ -19,8 +19,7 @@ const Login = ({ params: { locale } }: { params: { locale: string } }) => {
diff --git a/app/[locale]/auth/registration/page.tsx b/app/[locale]/auth/registration/page.tsx new file mode 100644 index 00000000..be0dbe16 --- /dev/null +++ b/app/[locale]/auth/registration/page.tsx @@ -0,0 +1,1012 @@ +"use client"; + +import { Button } from "@/components/ui/button"; +import { Checkbox } from "@/components/ui/checkbox"; +import { Input } from "@/components/ui/input"; +import { Label } from "@/components/ui/label"; +import Image from "next/image"; + +import { close, error, loading, registerConfirm } from "@/config/swal"; +import { Link, useRouter } from "@/i18n/routing"; +import { getDataByNIK, getDataByNRP, getDataJournalist, getDataPersonil, listCity, listDistricts, listInstitusi, listProvince, postRegistration, saveInstitutes } from "@/service/auth"; +import { requestOTP, verifyOTP } from "@/service/landing/landing"; +import { yupResolver } from "@hookform/resolvers/yup"; +import { useParams, useSearchParams } from "next/navigation"; +import { useEffect, useState } from "react"; +import { useForm, SubmitHandler } from "react-hook-form"; +import Swal from "sweetalert2"; +import withReactContent from "sweetalert2-react-content"; +import * as Yup from "yup"; +import { InputOTP, InputOTPGroup, InputOTPSeparator, InputOTPSlot } from "@/components/ui/input-otp"; +import { Textarea } from "@/components/ui/textarea"; +import { Icon } from "@/components/ui/icon"; +import dynamic from "next/dynamic"; +import ReactPasswordChecklist from "react-password-checklist"; + +type Inputs = { + example: string; + exampleRequired: string; +}; + +const PasswordChecklist = dynamic(() => import("react-password-checklist"), { + ssr: false, +}); + +const page = () => { + const params = useParams(); + const [stepOneActive] = useState(true); + const [stepTwoActive, setStepTwoActive] = useState(false); + const [stepThreeActive, setStepThreeActive] = useState(false); + const [typePass, setTypePass] = useState("password"); + const [typePassConf, setTypePassConf] = useState("password"); + const searchParams = useSearchParams(); + const [formProfile, setFormProfile] = useState(false); + const [journalistCertificate, setJournalistCertificate] = useState(); + const [personilNRP, setPersonilNRP] = useState(); + const [journalistData, setJournalistData] = useState(); + const [personilData, setPersonilData] = useState(); + const [userIdentity] = useState(); + const [userIdentityValidate, setUserIdentityValidate] = useState(""); + const [email, setEmail] = useState(); + const [emailValidate, setEmailValidate] = useState(""); + const [otpValidate, setOtpValidate] = useState(""); + const [password, setPassword] = useState(""); + const [passwordConf, setPasswordConf] = useState(""); + const [city, setCity] = useState([]); + const [isValidPassword, setIsValidPassword] = useState(false); + const MySwal = withReactContent(Swal); + const [isCustomActive, setIsCustomActive] = useState(false); + const [institusi, setInstitusi] = useState(); + const [customInstituteName, setCustomInstituteName] = useState(""); + const [institusiAddress, setInstitusiAddress] = useState(); + const [institution, setInstitution] = useState([]); + const [province, setProvince] = useState([]); + const router = useRouter(); + const category = searchParams?.get("category"); + const [districts, setDistricts] = useState([]); + const [, setAssociation] = useState(); + const [warningPassConf] = useState(); + + const [otp1, setOtp1] = useState(); + const [otp2, setOtp2] = useState(); + const [otp3, setOtp3] = useState(); + const [otp4, setOtp4] = useState(); + const [otp5, setOtp5] = useState(); + const [otp6, setOtp6] = useState(); + + const nMinuteSeconds = 60; + const nSecondInMiliseconds = 1000; + const [, setRefreshTimer] = useState(false); + + const validationSchema = Yup.object().shape({ + firstName: Yup.string().required("Nama Lengkap tidak boleh kosong"), + username: Yup.string().required("Username tidak boleh kosong"), + phoneNumber: Yup.string().required("Nomor Telepon tidak boleh kosong"), + address: Yup.string().required("Alamat tidak boleh kosong"), + email: Yup.string().required("Email tidak boleh kosong"), + provinsi: Yup.string().required("Provinsi tidak boleh kosong"), + kota: Yup.string().required("Kota tidak boleh kosong"), + kecamatan: Yup.string().required("Kecamatan tidak boleh kosong"), + password: Yup.string().required("Kata Sandi tidak boleh kosong"), + passwordConf: Yup.string().required("Konfirmasi Kata Sandi tidak boleh kosong"), + }); + + const formOptions = { + resolver: yupResolver(validationSchema), + }; + + const { register, handleSubmit, formState, setValue } = useForm(formOptions); + + const convertMinutesToMiliseconds = (minute: any) => minute * nMinuteSeconds * nSecondInMiliseconds; + + const convertMilisecondsToHour = (miliseconds: any) => new Date(miliseconds).toISOString().slice(17, -5); + + let [timerCount, setTimerCount] = useState(convertMinutesToMiliseconds(1)); + let interval: any; + + const showPass = () => { + setTypePass("text"); + }; + + const hidePass = () => { + setTypePass("password"); + }; + + const showPassConf = () => { + setTypePassConf("text"); + }; + + const hidePassConf = () => { + setTypePassConf("password"); + }; + + const setValUsername = (e: any) => { + const uname = e.replaceAll(/[^\w.-]/g, ""); + setValue("username", uname.toLowerCase()); + }; + + const setValPassword = (e: any) => { + setValue("password", e); + setPassword(e); + }; + + const setValPasswordConf = (e: any) => { + setPasswordConf(e); + }; + + const { errors }: any = formState; + + async function save(data: any) { + // loading(); + let institutionId = 1; + + if (Number(category) == 6) { + const dataInstitution = + isCustomActive == true + ? { + name: customInstituteName, + address: institusiAddress, + categoryRoleId: Number(category), + } + : { + id: institusi, + address: institusiAddress, + }; + + console.log(dataInstitution); + + const resInstitution = await saveInstitutes(dataInstitution); + + institutionId = resInstitution?.data?.data?.id; + if (resInstitution?.error) { + error(resInstitution?.message); + return false; + } + } + + // const sanitizedFirstName = sanitizeHtml(data.firstName); + + // if (sanitizedFirstName == "") { + // error("Invalid Name"); + // } else { + // const datas = { + // firstName: sanitizedFirstName, + // lastName: "", + // username: data.username, + // phoneNumber: data.phoneNumber, + // email, + // address: data.address, + // memberIdentity: userIdentity, + // provinceId: Number(data.provinsi), + // cityId: Number(data.kota), + // districtId: Number(data.kecamatan), + // password: data.password, + // instituteId: Number(institutionId), + // roleId: Number(category), + // }; + + // const response = await postRegistration(datas); + // console.log(response); + // if (response?.error) { + // error(response?.message); + // return false; + // } + + // registerConfirm(); + // return false; + // } + } + + const handleSendOTP = async () => { + console.log(userIdentity, email); + if (Number(category) == 6) { + // const journalist = await handleJournalistCertificate(); + console.log(email, journalistCertificate); + if (email != "" && journalistCertificate != undefined) { + const data = { + memberIdentity: journalistCertificate, + email, + category: 6, + }; + + loading(); + const response = await requestOTP(data); + + if (response?.error) { + error(response.message); + return false; + } + + close(); + handleJournalistCertificate(); + setStepTwoActive(true); + } else { + console.log("identity empty"); + setUserIdentityValidate("Nomor identitas tidak boleh kosong"); + } + } else if (Number(category) == 7) { + console.log(email, personilNRP); + if (email != "" && personilNRP != undefined) { + const data = { + memberIdentity: personilNRP, + email, + category: 7, + }; + + loading(); + const response = await requestOTP(data); + + if (response?.error) { + error(response?.message); + return false; + } + + close(); + handleDataNRP(); + setStepTwoActive(true); + } else { + console.log("identity empty"); + setUserIdentityValidate("Nomor identitas tidak boleh kosong"); + } + } else { + console.log("UMUM"); + if (email != "") { + const data = { + memberIdentity: null, + email, + category, + }; + + loading(); + const response = await requestOTP(data); + + if (response?.error) { + error(response?.message); + return false; + } + + close(); + setStepTwoActive(true); + } + } + }; + + const handleJournalistCertificate = async () => { + const response = await getDataJournalist(journalistCertificate); + const data = response?.data?.data; + console.log(data); + if (data) { + setJournalistData(data[0]); + } + + console.log("Data jurnalis:", data); + return data; + }; + + const handleTypeOTP = (event: any) => { + const { form } = event.target; + const index = [...form].indexOf(event.target); + form.elements[index + 1].focus(); + event.preventDefault(); + }; + + const handleResendOTP = async () => { + const timer = convertMilisecondsToHour(timerCount); + + if (timer == "00") { + handleSendOTP(); + restartTimer(); + } + }; + + function restartTimer() { + setTimerCount(60_000); + setRefreshTimer(true); + startInterval(); + } + + function startInterval() { + interval = setInterval(() => { + if (timerCount == 1000 && interval) { + clearInterval(interval); + console.log("Reset"); + } + + timerCount = timerCount == 0 ? 60_000 : timerCount; + setTimerCount((timerCount -= nSecondInMiliseconds)); + }, nSecondInMiliseconds); + } + + const handleDataNRP = async () => { + const response = await getDataPersonil(personilNRP); + const data = response?.data?.data; + setPersonilData(data); + console.log("Data personil:", data); + return data; + }; + + const handleInstituteOption = (e: any) => { + if (e.target.value == "0") { + setIsCustomActive(true); + } else { + setIsCustomActive(false); + setInstitusi(e.target.value); + } + }; + + // const { + // register, + // handleSubmit, + // watch, + // formState: { errors }, + // } = useForm(); + // const onSubmit: SubmitHandler = (data) => console.log(data); + // console.log(watch("example")); + + function setDataToForm() { + if (Number(category) == 6 && journalistData) { + setValue("firstName", journalistData.journalistName); + setValue("memberIdentity", journalistData.certNumber); + const selectedProvince = province.find((o: any) => o.provName == journalistData.province?.toUpperCase()); + + if (selectedProvince !== undefined) { + setValue("provinsi", selectedProvince.id); + } + } else if (Number(category) == 7 && personilData) { + setValue("firstName", personilData.lastName); + setValue("memberIdentity", personilData.nrp); + } + } + + const checkEmail = (e: any) => { + const regEmail = /^(([^\s"(),.:;<>@[\\\]]+(\.[^\s"(),.:;<>@[\\\]]+)*)|(".+"))@((\[(?:\d{1,3}\.){3}\d{1,3}])|(([\dA-Za-z\-]+\.)+[A-Za-z]{2,}))$/; + + if (regEmail.test(e)) { + setEmailValidate(""); + setEmail(e); + } else { + setEmailValidate("Email tidak valid"); + setEmail(""); + } + }; + + async function onSubmit(data: any) { + console.log("Submit"); + + if (isValidPassword) { + MySwal.fire({ + title: "Buat akun", + text: "", + icon: "warning", + showCancelButton: true, + cancelButtonColor: "#d33", + confirmButtonColor: "#3085d6", + confirmButtonText: "Buat", + }).then((result) => { + if (result.isConfirmed) { + save(data); + } + }); + } else { + error("Kata Sandi harus sama"); + } + } + + const handleIdentity = async (e: any) => { + const id = e; + console.log(id); + await new Promise((resolve) => setTimeout(resolve, 2000)); // 2 sec + if (Number(category) == 5) { + const reqId = + "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJsb2dlZF9pbiI6ImxvZ2luX3RydWUiLCJpZF91c2VyX2FjY291bnQiOiJJRDExMyIsInVzZXJuYW1lIjoiaXdhbjc0M0BnbWFpbC5jb20iLCJub21lcktUUCI6bnVsbCwicm9sZSI6IjEiLCJyZWRpcmVjdF9sb2dpbl92YWxpZCI6IjM0IiwiY29udHJvbGxlciI6InN5c3RlbXMiLCJuYW1hX2xlbmdrYXAiOiJJd2FuIEphZWxhbmksIFMuS29tIiwiaWRXYXJnYSI6IjIwMTgxMjA2MTMwNTQ1Iiwia29kZV9yYWhhc2lhIjoiWGJqMHRRR2djWXdVMnYiLCJpZF9zZXNzaW9uIjoiMnRwMTZUV2VpTEhQN1o0RGpyYkt2TlVBelhHIiwicGVyc29uYWxfYXRhdV9sZW1iYWdhIjoiTEVNQkFHQSIsImV4cGlyZV9zZXNzaW9uIjoiMjAyMi0wMS0yNyAxNTowMzozNiJ9.Nzq3QqAlKaeKAdDujI9fGuj_mJcIIyWe8lvBI_Ui06o"; + const response = await getDataByNIK(reqId, id); + const data = response?.data?.data_return[0]; + + console.log(data); + if (data !== undefined) { + setValue("firstName", data.nama_lengkap); + setValue("address", data.alamat); + const selectedProvince = province.find((o: any) => o.provName == data.prov?.toUpperCase()); + + if (selectedProvince !== undefined) { + setValue("provinsi", selectedProvince.id); + } + + const selectedCity: any = city.find((o: any) => o.cityName == data.kab_kota?.toUpperCase()); + + if (selectedCity !== undefined) { + setValue("kota", selectedCity?.id); + } + + const selectedDistrict: any = districts.find((o: any) => o.disName == data.kec?.toUpperCase()); + + if (selectedDistrict !== undefined) { + setValue("kecamatan", selectedDistrict?.id); + } + } + } else if (Number(category) == 7) { + const reqId = + "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJsb2dlZF9pbiI6ImxvZ2luX3RydWUiLCJpZF91c2VyX2FjY291bnQiOiJJRDExMyIsInVzZXJuYW1lIjoiaXdhbjc0M0BnbWFpbC5jb20iLCJub21lcktUUCI6bnVsbCwicm9sZSI6IjEiLCJyZWRpcmVjdF9sb2dpbl92YWxpZCI6IjM0IiwiY29udHJvbGxlciI6InN5c3RlbXMiLCJuYW1hX2xlbmdrYXAiOiJJd2FuIEphZWxhbmksIFMuS29tIiwiaWRXYXJnYSI6IjIwMTgxMjA2MTMwNTQ1Iiwia29kZV9yYWhhc2lhIjoiWGJqMHRRR2djWXdVMnYiLCJpZF9zZXNzaW9uIjoiMnRwMTZUV2VpTEhQN1o0RGpyYkt2TlVBelhHIiwicGVyc29uYWxfYXRhdV9sZW1iYWdhIjoiTEVNQkFHQSIsImV4cGlyZV9zZXNzaW9uIjoiMjAyMi0wMS0yNyAxNTowMzozNiJ9.Nzq3QqAlKaeKAdDujI9fGuj_mJcIIyWe8lvBI_Ui06o"; + const response = await getDataByNRP(reqId, id); + const data = response?.data?.data_return[0]; + + console.log("Data :", data); + if (data !== undefined) { + setValue("firstName", data.nama); + setValue("address", data.lokasi); + } + } + }; + + const getCity = async (e: any) => { + const res = await listCity(e); + setCity(res?.data.data); + }; + + const getDistricts = async (e: any) => { + const res = await listDistricts(e); + setDistricts(res?.data.data); + }; + + const handleVerifyOTP = async () => { + const otp = `${otp1}${otp2}${otp3}${otp4}${otp5}${otp6}`; + + if (email != "" && otp.length == 6) { + console.log("verify otp"); + loading(); + // const response = { + // message: "success", + // }; + + const response = await verifyOTP(email, otp); + if (response?.error) { + error(response?.message); + return false; + } + close(); + // console.log(response); + if (response?.message == "success") { + console.log("success"); + setStepThreeActive(true); + setFormProfile(true); + setOtpValidate(""); + setValue("email", email); + setValue("memberIdentity", userIdentity); + handleIdentity(userIdentity); + setDataToForm(); + } else { + setOtpValidate("Kode OTP Tidak Valid"); + } + } + }; + + useEffect(() => { + async function initState() { + if (category != undefined) { + const resInstiution = await listInstitusi(category); + const res = await listProvince(); + setInstitution(resInstiution?.data.data); + setProvince(res?.data.data); + } + } + + initState(); + }, [category]); + + useEffect(() => { + function initState() { + for (const element of institution) { + const { id } = element; + + if (id == institusi) { + setInstitusiAddress(element.address); + } + } + } + + initState(); + }, [institusi]); + + useEffect(() => { + async function initState() { + if (category != undefined) { + const resInstiution = await listInstitusi(category); + const res = await listProvince(); + setInstitution(resInstiution?.data.data); + setProvince(res?.data.data); + } + } + + initState(); + }, [category]); + + return ( +
+
+
+ + + +
+
+ +
+
+ +
+
+
+
    +
  • +
    + + 1 + +
    +
  • +
    +
  • +
    + + 2 + +
    +
  • +
    +
  • +
    + + 3 + +
    +
  • +
+
+ +
+
+

{stepThreeActive ? "Silahkan lengkapi data pengguna" : "Silahkan registrasi terlebih dahulu"}

+

+ Sudah memiliki akun?{" "} + + Masuk + +

+
+
+

+ Masukkan Kode OTP +

+

Silahkan cek inbox atau kotak spam pada email Anda.

+
+
+ +
+
+ + +
{errors.association?.message}
+
+ + {Number(category) == 7 ? ( +
+ + setPersonilNRP(event.target.value)} /> +

{userIdentityValidate}

+
+ ) : ( + "" + )} + {Number(category) == 6 ? ( +
+ + setJournalistCertificate(event.target.value)} /> +
+ ) : ( + "" + )} +
+ + checkEmail(event.target.value)} /> +

{emailValidate}

+
+
+ +
+
+ + + setOtp1(e.target.value)} onKeyUp={handleTypeOTP} /> + setOtp2(e.target.value)} onKeyUp={handleTypeOTP} /> + + + + setOtp3(e.target.value)} onKeyUp={handleTypeOTP} /> + setOtp4(e.target.value)} onKeyUp={handleTypeOTP} /> + + + + setOtp5(e.target.value)} onKeyUp={handleTypeOTP} /> + setOtp6(e.target.value)} onKeyUp={handleTypeOTP} /> + + +
+

+ {otpValidate} +

+ +
+ +
+
+ {Number(category) == 6 || Number(category) == 7 ? ( +
+ + handleIdentity(e.target.value)} + disabled + /> +
{errors.memberIdentity?.message}
+
+ ) : ( + "" + )} +
+ + +
{errors.firstName?.message}
+
+
+ + { + setValUsername(e.target.value.trim()); + }} + onPaste={(e: any) => { + setValUsername(e.target.value.trim()); + }} + onCopy={(e: any) => { + setValUsername(e.target.value.trim()); + }} + /> +
{errors.username?.message}
+
+
+ + +
{errors.email?.message}
+
+
+
+ + +
{errors.phoneNumber?.message}
+
+
+ +