diff --git a/app/[locale]/(public)/content-management/download/page.tsx b/app/[locale]/(public)/content-management/download/page.tsx index 7b02f3ca..80483d72 100644 --- a/app/[locale]/(public)/content-management/download/page.tsx +++ b/app/[locale]/(public)/content-management/download/page.tsx @@ -12,8 +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 { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from "@/components/ui/dropdown-menu"; 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(); @@ -21,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"); @@ -29,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([]); @@ -43,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(); @@ -220,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); @@ -278,35 +319,49 @@ const Galery = (props: any) => { contentVideo?.length > 0 ? (
{contentVideo?.map((video: any) => ( - - - - -
{video?.mediaUpload?.title}
- - - + + +
+ + +
{video?.mediaUpload?.title}
+ + + +
- - - -
- -
-
- - handleDelete(video?.id)} className="flex items-center gap-1 hover:bg-slate-600 w-full rounded-lg"> - -

Hapus

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

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

+
+
+ +
))} @@ -320,7 +375,7 @@ const Galery = (props: any) => { contentAudio?.length > 0 ? (
{contentAudio?.map((audio: any) => ( -
+
{ />
-
- - {audio?.mediaUpload?.title} +
+ +
{audio?.mediaUpload?.title}
@@ -349,29 +404,41 @@ const Galery = (props: any) => {
- - - + + + - - - -
- -
-
- - handleDelete(audio?.id)} className="flex items-center gap-1 hover:bg-slate-600 w-full rounded-lg"> - -

Hapus

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

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

+
+
+
))}
@@ -384,36 +451,48 @@ 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:bg-slate-600 w-full rounded-lg"> + handleDelete(image?.id)} className="flex items-center gap-1 hover:text-red-800 w-full rounded-lg">

Hapus

-
- - +
+
+ ))}
@@ -446,29 +525,41 @@ const Galery = (props: any) => { Download Dokumen
- - - + + + - - - -
- -
-
- - handleDelete(document?.id)} className="flex items-center gap-1 hover:bg-slate-600 w-full rounded-lg"> - -

Hapus

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

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/page.tsx b/app/[locale]/(public)/content-management/rewrite/page.tsx index ec35c993..132c93ed 100644 --- a/app/[locale]/(public)/content-management/rewrite/page.tsx +++ b/app/[locale]/(public)/content-management/rewrite/page.tsx @@ -11,6 +11,11 @@ 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 [, setProfile] = useState(); @@ -21,23 +26,22 @@ 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 +157,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 ( <> @@ -166,12 +207,49 @@ const page = (props: any) => { {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)/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/service/media-tracking/media-tracking.ts b/service/media-tracking/media-tracking.ts index a1469fc4..42a37d30 100644 --- a/service/media-tracking/media-tracking.ts +++ b/service/media-tracking/media-tracking.ts @@ -1,6 +1,11 @@ -import { httpGetInterceptor } from "../http-config/http-interceptor-service"; +import { httpGetInterceptor, httpPostInterceptor } from "../http-config/http-interceptor-service"; export async function getMediaTrackingMonitoring(page: number, size: number) { const url = `cekmedsos/monitoring/pagination?page=${page}&size=${size}`; return httpGetInterceptor(url); } + +export async function sendMediaUploadToEmail(data: any) { + const url = "media/public/share-to-email"; + return httpPostInterceptor(url, data); +}