feat: add media rewrite to email
This commit is contained in:
parent
3c14fd2358
commit
f90c9f73e1
|
|
@ -29,6 +29,7 @@ import { sendMediaUploadToEmail } from "@/service/media-tracking/media-tracking"
|
|||
import ImageBlurry from "@/components/ui/image-blurry";
|
||||
import Image from "next/image";
|
||||
import { useTranslations } from "next-intl";
|
||||
import { sendMediaRewriteToEmail } from "@/service/content/content";
|
||||
|
||||
const page = () => {
|
||||
const [, setProfile] = useState();
|
||||
|
|
@ -175,18 +176,16 @@ const page = () => {
|
|||
}
|
||||
};
|
||||
|
||||
async function shareToEmail() {
|
||||
async function shareToEmail(uploadId: any) {
|
||||
if (Number(userRoleId) < 1 || userRoleId == undefined) {
|
||||
router.push("/auth/login");
|
||||
} else {
|
||||
const data = {
|
||||
mediaUploadId: id?.split("-")?.[0],
|
||||
id: uploadId,
|
||||
email: emailShareList || [emailShareInput],
|
||||
message: emailMessageInput,
|
||||
url: window.location.href,
|
||||
};
|
||||
loading();
|
||||
const res = await sendMediaUploadToEmail(data);
|
||||
const res = await sendMediaRewriteToEmail(data.id, data.email);
|
||||
if (res?.error) {
|
||||
error(res.message);
|
||||
return false;
|
||||
|
|
@ -196,6 +195,7 @@ const page = () => {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
const handleEmailList = (e: any) => {
|
||||
const arrayEmail: any = [];
|
||||
for (let i = 0; i < emailShareList?.length; i += 1) {
|
||||
|
|
@ -328,7 +328,7 @@ const page = () => {
|
|||
</div>
|
||||
<Button
|
||||
className="bg-blue-500 text-white p-2 w-fit rounded-lg"
|
||||
onClick={() => shareToEmail()}
|
||||
onClick={() => shareToEmail(image.id)}
|
||||
>
|
||||
{t("send", { defaultValue: "Send" })}
|
||||
</Button>
|
||||
|
|
|
|||
|
|
@ -255,6 +255,12 @@ export async function saveContentRewrite(data: any) {
|
|||
const url = "media/rewrite";
|
||||
return httpPostInterceptor(url, data);
|
||||
}
|
||||
|
||||
export async function sendMediaRewriteToEmail(id: any, email: any) {
|
||||
const url = `media/rewrite/share-to-email?id=${id}&email=${email}`;
|
||||
return httpPostInterceptor(url, null);
|
||||
}
|
||||
|
||||
export async function saveUserReports(data: any) {
|
||||
const url = "public/users/reports";
|
||||
return httpPostInterceptor(url, data);
|
||||
|
|
|
|||
Loading…
Reference in New Issue