From f05ade4d3c49f88d5a90edbd8904807aea385bd6 Mon Sep 17 00:00:00 2001 From: Rama Priyanto Date: Tue, 24 Dec 2024 10:27:08 +0700 Subject: [PATCH] feat:upload to dise --- components/form/form-article.tsx | 30 +++++++++++++++++++++++++++++- service/generate-article.ts | 9 +++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/components/form/form-article.tsx b/components/form/form-article.tsx index 044dee5..0867c0c 100644 --- a/components/form/form-article.tsx +++ b/components/form/form-article.tsx @@ -1,5 +1,5 @@ "use client"; -import { error } from "@/config/swal"; +import { close, error, loading } from "@/config/swal"; import { createArticle, getArticleByCategory } from "@/service/article"; import { zodResolver } from "@hookform/resolvers/zod"; import { @@ -21,6 +21,7 @@ import withReactContent from "sweetalert2-react-content"; import * as z from "zod"; import ReactSelect from "react-select"; import makeAnimated from "react-select/animated"; +import { saveManualContext } from "@/service/generate-article"; const articleSchema = z.object({ title: z.string().min(1, { message: "Required" }), @@ -210,10 +211,37 @@ export default function FormArticle() { confirmButtonText: "Simpan", }).then((result) => { if (result.isConfirmed) { + // diseUpload(data); save(data); } }); } + + const diseUpload = async (data: any) => { + const request = { + title: data.title, + articleBody: content, + metaDescription: data.title, + metaTitle: data.title, + mainKeyword: data.title, + additionalKeywords: data.title, + createdBy: "123432", + style: "Informational", + projectId: 2, + clientId: "humasClientIdtest", + lang: "id", + }; + + loading(); + const res = await saveManualContext(request); + if (res.error) { + res.message; + return false; + } + close(); + save(data); + }; + return (
diff --git a/service/generate-article.ts b/service/generate-article.ts index 41e21c6..7973690 100644 --- a/service/generate-article.ts +++ b/service/generate-article.ts @@ -215,3 +215,12 @@ export async function regenerateArticle(id: number | string) { }; return await httpGet(`ai-writer/re-create-article/${id}`, headers); } + +export async function saveManualContext(data: any) { + const headers = { + "content-type": "application/json", + Authorization: + "Basic bmdETFBQaW9ycGx6bncyalRxVmUzWUZDejV4cUtmVUo6UHJEaERXUmNvdkJSNlc1Sg==", + }; + return await httpPost("ai-writer/create-article", headers, data); +}