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)/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)/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/components/landing-page/navbar.tsx b/components/landing-page/navbar.tsx index 4b426162..20e7bffc 100644 --- a/components/landing-page/navbar.tsx +++ b/components/landing-page/navbar.tsx @@ -37,6 +37,7 @@ type Detail = { const Navbar = () => { const [menuOpen, setMenuOpen] = useState(false); + const [inboxOpen, setInboxOpen] = useState(false); const router = useRouter(); const params = useParams(); const locale = params?.locale; @@ -118,7 +119,7 @@ const Navbar = () => { const response = await getInfoProfile(); if (!response?.error) { const details = response?.data?.data; - + setInboxOpen(details); setDetail(details); console.log("data", details); } @@ -211,9 +212,9 @@ const Navbar = () => { {t("content")} - - router.push(prefixPath + "/image/filter")} className="flex place-items-start gap-1.5 p-2 w-40"> -

+ + router.push(prefixPath + "/image/filter")} className="flex place-items-start gap-1.5 p-2 w-36"> +

{t("image")}

@@ -221,32 +222,28 @@ const Navbar = () => { router.push(prefixPath + "/video/filter")} className="flex items-start gap-1.5 p-2 "> {pathname?.split("/")[1] == "in" ? ( <> -

+

{t("video")}

) : ( <> -

+

{t("video")}

)} - {/*

- - {t("video")} -

*/}
router.push(prefixPath + "/document/filter")} className="flex place-items-start gap-1.5 p-2"> -

+

{t("text")}

router.push(prefixPath + "/audio/filter")} className="flex place-items-start gap-1.5 p-2 "> -

+

{t("audio")}{" "}

@@ -327,97 +324,6 @@ const Navbar = () => { - {/* Inbox */} - - - test()}> - {" "} - - - - - - - - setIsMessageActive(true)} - > - Pesan Masuk - - - - setIsMessageActive(false)} - > - Update( - {notificationsUpdate?.length}) - - - - - - - {/* - - */} - - {/*
{fullName ? ( <> @@ -464,112 +370,248 @@ const Navbar = () => {
*/} {roleId === "5" || roleId === "6" || roleId === "7" || roleId === "8" ? ( - - - {detail !== undefined ? ( -
- {"Image"} - - ) : ( - "" - )} - - - - {[ - { - name: "Profile & Settings", - icon: "heroicons:user", - href: "/profile", - }, - { - name: "Kelola Konten", - icon: "stash:save-ribbon-duotone", - href: "/content-management/galery", - }, - ].map((item, index) => ( - - - - {item.name} - - - ))} - - - -
- - - -
-
-
- + ) : ( + "" + )} + + + + {[ + { + name: "Profile & Settings", + icon: "heroicons:user", + href: "/profile", + }, + { + name: "Kelola Konten", + icon: "stash:save-ribbon-duotone", + href: "/content-management/galery", + }, + ].map((item, index) => ( + + + + {item.name} + + + ))} + + + +
+ + + +
+
+
+ + ) : roleId === "2" || roleId === "3" || roleId === "4" || roleId === "9" || roleId === "10" || roleId === "11" || roleId === "12" || roleId === "13" ? ( - // Dropdown menu for roleId === 3 - - - {detail !== undefined ? ( -
- {"Image"} -
-
{detail?.fullname}
-

({detail?.fullname})

+ <> + {/* Inbox */} + + + test()}> + {" "} + + + + + + + + setIsMessageActive(true)} + > + Pesan Masuk + + + + setIsMessageActive(false)} + > + Update( + {notificationsUpdate?.length}) + + + + + + + + // Dropdown menu for roleId === 3 + + + {detail !== undefined ? ( +
+ {"Image"} +
+
{detail?.fullname}
+

({detail?.fullname})

+
+ + +
- - - -
- ) : ( - "" - )} - - - - {[ - { - name: "Profile & Settings", - icon: "heroicons:user", - href: "/profile", - }, - { - name: "Dashboard", - icon: "material-symbols:dashboard", - href: "/dashboard", - }, - ].map((item, index) => ( - - - - {item.name} - - - ))} - - - -
- - - -
-
-
- + ) : ( + "" + )} + + + + {[ + { + name: "Profile & Settings", + icon: "heroicons:user", + href: "/profile", + }, + { + name: "Dashboard", + icon: "material-symbols:dashboard", + href: "/dashboard", + }, + ].map((item, index) => ( + + + + {item.name} + + + ))} + + + +
+ + + +
+
+
+ + ) : ( // Masuk and Daftar buttons for roleId === null