feat: fixing all service axios
This commit is contained in:
parent
c8c3ed2ee6
commit
d7b11b2516
|
|
@ -138,7 +138,7 @@ const CalendarView = ({ categories }: CalendarViewProps) => {
|
|||
|
||||
if (response.data && Array.isArray(response.data)) {
|
||||
// Transform API data to match CalendarEvent type
|
||||
const eventsFromAPI: CalendarEvent[] = response.data.map((item) => ({
|
||||
const eventsFromAPI: CalendarEvent[] = response?.data?.map((item) => ({
|
||||
id: item.id.toString(),
|
||||
title: item.title,
|
||||
start: new Date(item.startDate),
|
||||
|
|
|
|||
|
|
@ -96,8 +96,8 @@ const EventModal = ({
|
|||
setIsLoading(true);
|
||||
try {
|
||||
const response = await getUserLevelForAssignments();
|
||||
setListDest(response.data.data.list);
|
||||
const initialExpandedState = response.data.data.list.reduce(
|
||||
setListDest(response?.data?.data.list);
|
||||
const initialExpandedState = response?.data?.data.list.reduce(
|
||||
(acc: any, polda: any) => {
|
||||
acc[polda.id] = false;
|
||||
return acc;
|
||||
|
|
@ -145,12 +145,12 @@ const EventModal = ({
|
|||
console.log("Submitted Data:", reqData);
|
||||
|
||||
const response = await saveAgendaSettings(reqData);
|
||||
if (response.error) {
|
||||
error(response.message);
|
||||
if (response?.error) {
|
||||
error(response?.message);
|
||||
return false;
|
||||
}
|
||||
|
||||
Cookies.set("AgendaSetting", response.data.data.id, {
|
||||
Cookies.set("AgendaSetting", response?.data?.data.id, {
|
||||
expires: 1,
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -248,8 +248,8 @@ export default function DetailDaily() {
|
|||
console.log("req =>", reqData);
|
||||
const response = await savePlanning(reqData);
|
||||
|
||||
if (response.error) {
|
||||
error(response.message);
|
||||
if (response?.error) {
|
||||
error(response?.message);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -327,7 +327,7 @@ export default function DetailDaily() {
|
|||
useEffect(() => {
|
||||
async function initState() {
|
||||
const response = await getUserLevelForAssignments();
|
||||
setListDest(response.data.data.list);
|
||||
setListDest(response?.data?.data.list);
|
||||
}
|
||||
|
||||
initState();
|
||||
|
|
|
|||
|
|
@ -262,8 +262,8 @@ export default function EditDaily() {
|
|||
|
||||
const response = await savePlanning(reqData);
|
||||
|
||||
if (response.error) {
|
||||
error(response.message);
|
||||
if (response?.error) {
|
||||
error(response?.message);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -341,7 +341,7 @@ export default function EditDaily() {
|
|||
useEffect(() => {
|
||||
async function initState() {
|
||||
const response = await getUserLevelForAssignments();
|
||||
setListDest(response.data.data.list);
|
||||
setListDest(response?.data?.data.list);
|
||||
}
|
||||
|
||||
initState();
|
||||
|
|
|
|||
|
|
@ -210,8 +210,8 @@ export default function CreateDaily() {
|
|||
console.log("req =>", reqData);
|
||||
const response = await savePlanning(reqData);
|
||||
|
||||
if (response.error) {
|
||||
error(response.message);
|
||||
if (response?.error) {
|
||||
error(response?.message);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -289,7 +289,7 @@ export default function CreateDaily() {
|
|||
useEffect(() => {
|
||||
async function initState() {
|
||||
const response = await getUserLevelForAssignments();
|
||||
setListDest(response.data.data.list);
|
||||
setListDest(response?.data?.data.list);
|
||||
}
|
||||
|
||||
initState();
|
||||
|
|
|
|||
|
|
@ -122,8 +122,8 @@ export default function DetailMonthly() {
|
|||
console.log("req", reqData, data.month);
|
||||
const response = await savePlanning(reqData);
|
||||
close();
|
||||
if (response.error) {
|
||||
error(response.message);
|
||||
if (response?.error) {
|
||||
error(response?.message);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -123,8 +123,8 @@ export default function EditMonthly() {
|
|||
console.log("req", reqData, data.month);
|
||||
const response = await savePlanning(reqData);
|
||||
close();
|
||||
if (response.error) {
|
||||
error(response.message);
|
||||
if (response?.error) {
|
||||
error(response?.message);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -91,8 +91,8 @@ export default function CreateMonthly() {
|
|||
console.log("req", reqData, data.month);
|
||||
const response = await savePlanning(reqData);
|
||||
close();
|
||||
if (response.error) {
|
||||
error(response.message);
|
||||
if (response?.error) {
|
||||
error(response?.message);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -113,8 +113,8 @@ export default function DetailMonthly() {
|
|||
console.log("req", reqData);
|
||||
const response = await savePlanning(reqData);
|
||||
close();
|
||||
if (response.error) {
|
||||
error(response.message);
|
||||
if (response?.error) {
|
||||
error(response?.message);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -113,8 +113,8 @@ export default function EditMonthly() {
|
|||
console.log("req", reqData);
|
||||
const response = await savePlanning(reqData);
|
||||
close();
|
||||
if (response.error) {
|
||||
error(response.message);
|
||||
if (response?.error) {
|
||||
error(response?.message);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -112,8 +112,8 @@ export default function CreateMonthly() {
|
|||
console.log("req", reqData);
|
||||
const response = await savePlanning(reqData);
|
||||
close();
|
||||
if (response.error) {
|
||||
error(response.message);
|
||||
if (response?.error) {
|
||||
error(response?.message);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -229,8 +229,8 @@ export default function CreateMonthly() {
|
|||
console.log("req =>", reqData);
|
||||
const response = await savePlanning(reqData);
|
||||
|
||||
if (response.error) {
|
||||
error(response.message);
|
||||
if (response?.error) {
|
||||
error(response?.message);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -258,7 +258,7 @@ export default function CreateMonthly() {
|
|||
useEffect(() => {
|
||||
async function initState() {
|
||||
const response = await getUserLevelForAssignments();
|
||||
setListDest(response.data.data.list);
|
||||
setListDest(response?.data?.data.list);
|
||||
}
|
||||
|
||||
initState();
|
||||
|
|
|
|||
|
|
@ -122,8 +122,8 @@ export default function DetailMonthly() {
|
|||
console.log("req", reqData, data.month);
|
||||
const response = await savePlanning(reqData);
|
||||
close();
|
||||
if (response.error) {
|
||||
error(response.message);
|
||||
if (response?.error) {
|
||||
error(response?.message);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -123,8 +123,8 @@ export default function EditMonthly() {
|
|||
console.log("req", reqData, data.month);
|
||||
const response = await savePlanning(reqData);
|
||||
close();
|
||||
if (response.error) {
|
||||
error(response.message);
|
||||
if (response?.error) {
|
||||
error(response?.message);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -91,8 +91,8 @@ export default function CreateMonthly() {
|
|||
console.log("req", reqData, data.month);
|
||||
const response = await savePlanning(reqData);
|
||||
close();
|
||||
if (response.error) {
|
||||
error(response.message);
|
||||
if (response?.error) {
|
||||
error(response?.message);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -113,8 +113,8 @@ export default function DetailMonthly() {
|
|||
console.log("req", reqData);
|
||||
const response = await savePlanning(reqData);
|
||||
close();
|
||||
if (response.error) {
|
||||
error(response.message);
|
||||
if (response?.error) {
|
||||
error(response?.message);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -113,8 +113,8 @@ export default function EditMonthly() {
|
|||
console.log("req", reqData);
|
||||
const response = await savePlanning(reqData);
|
||||
close();
|
||||
if (response.error) {
|
||||
error(response.message);
|
||||
if (response?.error) {
|
||||
error(response?.message);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -111,8 +111,8 @@ export default function CreateMonthly() {
|
|||
console.log("req", reqData);
|
||||
const response = await savePlanning(reqData);
|
||||
close();
|
||||
if (response.error) {
|
||||
error(response.message);
|
||||
if (response?.error) {
|
||||
error(response?.message);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -86,8 +86,8 @@ const FeedbackForm: React.FC = () => {
|
|||
console.log("Save Feedback :", userFeedbacks);
|
||||
const response = await postUserFeedback();
|
||||
close();
|
||||
if (response.error) {
|
||||
error(response.message);
|
||||
if (response?.error) {
|
||||
error(response?.message);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ import JoditEditor from "jodit-react";
|
|||
import { register } from "module";
|
||||
import { Switch } from "@/components/ui/switch";
|
||||
import Cookies from "js-cookie";
|
||||
import { createTask } from "@/config/api";
|
||||
import {
|
||||
createMedia,
|
||||
getTagsBySubCategoryId,
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ import JoditEditor from "jodit-react";
|
|||
import { register } from "module";
|
||||
import { Switch } from "@/components/ui/switch";
|
||||
import Cookies from "js-cookie";
|
||||
import { createTask } from "@/config/api";
|
||||
import {
|
||||
createMedia,
|
||||
getTagsBySubCategoryId,
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ import JoditEditor from "jodit-react";
|
|||
import { register } from "module";
|
||||
import { Switch } from "@/components/ui/switch";
|
||||
import Cookies from "js-cookie";
|
||||
import { createTask } from "@/config/api";
|
||||
import {
|
||||
createMedia,
|
||||
getTagsBySubCategoryId,
|
||||
|
|
@ -172,20 +171,20 @@ export default function FormBlog() {
|
|||
console.log("Form Data Submitted:", requestData);
|
||||
console.log("response", response);
|
||||
|
||||
if (response.error) {
|
||||
MySwal.fire("Error", response.message, "error");
|
||||
if (response?.error) {
|
||||
MySwal.fire("Error", response?.message, "error");
|
||||
return;
|
||||
}
|
||||
|
||||
const blogId = response.data.data.id;
|
||||
const blogId = response?.data.data.id;
|
||||
if (blogId && thumbnail) {
|
||||
const formMedia = new FormData();
|
||||
formMedia.append("file", thumbnail);
|
||||
|
||||
const responseThumbnail = await uploadThumbnailBlog(blogId, formMedia);
|
||||
|
||||
if (responseThumbnail.error) {
|
||||
MySwal.fire("Error", responseThumbnail.message, "error");
|
||||
if (responseThumbnail?.error) {
|
||||
MySwal.fire("Error", responseThumbnail?.message, "error");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -136,11 +136,11 @@ export default function FormDetailEscalation() {
|
|||
|
||||
// Tambahkan balasan baru ke daftar balasan
|
||||
const newReply: replyDetail = {
|
||||
id: response.data.id,
|
||||
id: response?.data?.id,
|
||||
message: replyMessage,
|
||||
createdAt: response.data.createdAt,
|
||||
messageFrom: response.data.messageFrom,
|
||||
messageTo: response.data.messageTo,
|
||||
createdAt: response?.data?.createdAt,
|
||||
messageFrom: response?.data?.messageFrom,
|
||||
messageTo: response?.data?.messageTo,
|
||||
};
|
||||
|
||||
setTicketReply((prevReplies) => [newReply, ...prevReplies]);
|
||||
|
|
|
|||
|
|
@ -132,11 +132,11 @@ export default function FormDetailInternal() {
|
|||
|
||||
// Tambahkan balasan baru ke daftar balasan
|
||||
const newReply: replyDetail = {
|
||||
id: response.data.id,
|
||||
id: response?.data?.id,
|
||||
message: replyMessage,
|
||||
createdAt: response.data.createdAt,
|
||||
messageFrom: response.data.messageFrom,
|
||||
messageTo: response.data.messageTo,
|
||||
createdAt: response?.data?.createdAt,
|
||||
messageFrom: response?.data?.messageFrom,
|
||||
messageTo: response?.data?.messageTo,
|
||||
};
|
||||
|
||||
setTicketReply((prevReplies) => [newReply, ...prevReplies]);
|
||||
|
|
|
|||
|
|
@ -135,11 +135,11 @@ export default function FormEditInternal() {
|
|||
|
||||
// Tambahkan balasan baru ke daftar balasan
|
||||
const newReply: replyDetail = {
|
||||
id: response.data.id,
|
||||
id: response?.data?.id,
|
||||
message: replyMessage,
|
||||
createdAt: response.data.createdAt,
|
||||
messageFrom: response.data.messageFrom,
|
||||
messageTo: response.data.messageTo,
|
||||
createdAt: response?.data?.createdAt,
|
||||
messageFrom: response?.data?.messageFrom,
|
||||
messageTo: response?.data?.messageTo,
|
||||
};
|
||||
|
||||
setTicketReply((prevReplies) => [newReply, ...prevReplies]);
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ import JoditEditor from "jodit-react";
|
|||
import { register } from "module";
|
||||
import { Switch } from "@/components/ui/switch";
|
||||
import Cookies from "js-cookie";
|
||||
import { createTask } from "@/config/api";
|
||||
import {
|
||||
createMedia,
|
||||
getTagsBySubCategoryId,
|
||||
|
|
@ -342,20 +341,20 @@ export default function FormImageAI() {
|
|||
const response = await createMedia(requestData);
|
||||
console.log("Form Data Submitted:", requestData);
|
||||
|
||||
if (response.error) {
|
||||
MySwal.fire("Error", response.message, "error");
|
||||
if (response?.error) {
|
||||
MySwal.fire("Error", response?.message, "error");
|
||||
return;
|
||||
}
|
||||
|
||||
const imageId = response.data.data.id;
|
||||
const imageId = response?.data?.data.id;
|
||||
if (imageId && thumbnail) {
|
||||
const formMedia = new FormData();
|
||||
formMedia.append("file", thumbnail);
|
||||
|
||||
const responseThumbnail = await uploadThumbnail(imageId, formMedia);
|
||||
|
||||
if (responseThumbnail.error) {
|
||||
MySwal.fire("Error", responseThumbnail.message, "error");
|
||||
if (responseThumbnail?.error) {
|
||||
MySwal.fire("Error", responseThumbnail?.message, "error");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ import JoditEditor from "jodit-react";
|
|||
import { register } from "module";
|
||||
import { Switch } from "@/components/ui/switch";
|
||||
import Cookies from "js-cookie";
|
||||
import { createTask } from "@/config/api";
|
||||
import {
|
||||
createMedia,
|
||||
getTagsBySubCategoryId,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
"use client";
|
||||
import React, { ChangeEvent, useEffect, useRef, useState } from "react";
|
||||
import React, { ChangeEvent, useEffect, useRef, Fragment, useState } from "react";
|
||||
import { useForm, Controller } from "react-hook-form";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Button } from "@/components/ui/button";
|
||||
|
|
@ -23,7 +23,6 @@ import JoditEditor from "jodit-react";
|
|||
import { register } from "module";
|
||||
import { Switch } from "@/components/ui/switch";
|
||||
import Cookies from "js-cookie";
|
||||
import { createTask } from "@/config/api";
|
||||
import {
|
||||
createMedia,
|
||||
getTagsBySubCategoryId,
|
||||
|
|
@ -48,6 +47,14 @@ const imageSchema = z.object({
|
|||
creatorName: z.string().min(1, { message: "Creator diperlukan" }),
|
||||
// tags: z.string().min(1, { message: "Judul diperlukan" }),
|
||||
});
|
||||
import { useDropzone } from "react-dropzone";
|
||||
import { Icon } from "@iconify/react";
|
||||
import { CloudUpload } from "lucide-react";
|
||||
import Image from "next/image";
|
||||
|
||||
interface FileWithPreview extends File {
|
||||
preview: string;
|
||||
}
|
||||
|
||||
type Category = {
|
||||
id: string;
|
||||
|
|
@ -102,6 +109,14 @@ export default function FormImage() {
|
|||
|
||||
let fileTypeId = "1";
|
||||
|
||||
const [files, setFiles] = useState<FileWithPreview[]>([]);
|
||||
|
||||
const { getRootProps, getInputProps } = useDropzone({
|
||||
onDrop: (acceptedFiles) => {
|
||||
setFiles(acceptedFiles.map((file) => Object.assign(file)));
|
||||
},
|
||||
});
|
||||
|
||||
const {
|
||||
control,
|
||||
handleSubmit,
|
||||
|
|
@ -342,20 +357,20 @@ export default function FormImage() {
|
|||
const response = await createMedia(requestData);
|
||||
console.log("Form Data Submitted:", requestData);
|
||||
|
||||
if (response.error) {
|
||||
MySwal.fire("Error", response.message, "error");
|
||||
if (response?.error) {
|
||||
MySwal.fire("Error", response?.message, "error");
|
||||
return;
|
||||
}
|
||||
|
||||
const imageId = response.data.data.id;
|
||||
const imageId = response?.data?.data.id;
|
||||
if (imageId && thumbnail) {
|
||||
const formMedia = new FormData();
|
||||
formMedia.append("file", thumbnail);
|
||||
|
||||
const responseThumbnail = await uploadThumbnail(imageId, formMedia);
|
||||
|
||||
if (responseThumbnail.error) {
|
||||
MySwal.fire("Error", responseThumbnail.message, "error");
|
||||
if (responseThumbnail?.error) {
|
||||
MySwal.fire("Error", responseThumbnail?.message, "error");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -400,6 +415,65 @@ export default function FormImage() {
|
|||
}
|
||||
};
|
||||
|
||||
const renderFilePreview = (file: FileWithPreview) => {
|
||||
if (file.type.startsWith("image")) {
|
||||
return (
|
||||
<Image
|
||||
width={48}
|
||||
height={48}
|
||||
alt={file.name}
|
||||
src={URL.createObjectURL(file)}
|
||||
className=" rounded border p-0.5"
|
||||
/>
|
||||
);
|
||||
} else {
|
||||
return <Icon icon="tabler:file-description" />;
|
||||
}
|
||||
};
|
||||
|
||||
const handleRemoveFile = (file: FileWithPreview) => {
|
||||
const uploadedFiles = files;
|
||||
const filtered = uploadedFiles.filter((i) => i.name !== file.name);
|
||||
setFiles([...filtered]);
|
||||
};
|
||||
|
||||
const fileList = files.map((file) => (
|
||||
<div
|
||||
key={file.name}
|
||||
className=" flex justify-between border px-3.5 py-3 my-6 rounded-md"
|
||||
>
|
||||
<div className="flex gap-3 items-center">
|
||||
<div className="file-preview">{renderFilePreview(file)}</div>
|
||||
<div>
|
||||
<div className=" text-sm text-card-foreground">{file.name}</div>
|
||||
<div className=" text-xs font-light text-muted-foreground">
|
||||
{Math.round(file.size / 100) / 10 > 1000 ? (
|
||||
<>{(Math.round(file.size / 100) / 10000).toFixed(1)}</>
|
||||
) : (
|
||||
<>{(Math.round(file.size / 100) / 10).toFixed(1)}</>
|
||||
)}
|
||||
{" kb"}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Button
|
||||
size="icon"
|
||||
color="destructive"
|
||||
variant="outline"
|
||||
className=" border-none rounded-full"
|
||||
onClick={() => handleRemoveFile(file)}
|
||||
>
|
||||
<Icon icon="tabler:x" className=" h-5 w-5" />
|
||||
</Button>
|
||||
</div>
|
||||
));
|
||||
|
||||
const handleRemoveAllFiles = () => {
|
||||
setFiles([]);
|
||||
};
|
||||
|
||||
|
||||
return (
|
||||
<form onSubmit={handleSubmit(onSubmit)}>
|
||||
<div className="flex lg:flex-row gap-10">
|
||||
|
|
@ -695,29 +769,44 @@ export default function FormImage() {
|
|||
)}
|
||||
</div>
|
||||
<div className="py-3">
|
||||
<Label>Attachment</Label>
|
||||
|
||||
<Input
|
||||
<Label>Pilih File</Label>
|
||||
{/* <Input
|
||||
id="fileInput"
|
||||
type="file"
|
||||
onChange={handleImageChange}
|
||||
/>
|
||||
|
||||
<div className="flex flex-row items-center gap-3 py-3">
|
||||
<Label>Gunakan Watermark</Label>
|
||||
<div className="flex items-center gap-3">
|
||||
<Switch defaultChecked color="primary" id="c2" />
|
||||
/> */}
|
||||
<Fragment>
|
||||
<div {...getRootProps({ className: "dropzone" })}>
|
||||
<input {...getInputProps()} />
|
||||
<div className=" w-full text-center border-dashed border border-default-200 dark:border-default-300 rounded-md py-[52px] flex items-center flex-col">
|
||||
<CloudUpload className="text-default-300 w-10 h-10" />
|
||||
<h4 className=" text-2xl font-medium mb-1 mt-3 text-card-foreground/80">
|
||||
{/* Drop files here or click to upload. */}
|
||||
Tarik file disini atau klik untuk upload.
|
||||
</h4>
|
||||
<div className=" text-xs text-muted-foreground">
|
||||
( Upload file dengan format .jpg, .jpeg, atau .png. Ukuran maksimal 100mb.)
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{preview && (
|
||||
<div className="mt-3 px-3">
|
||||
<img
|
||||
src={preview}
|
||||
alt="Thumbnail Preview"
|
||||
className="w-32 h-auto rounded"
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
{files.length ? (
|
||||
<Fragment>
|
||||
<div>{fileList}</div>
|
||||
<div className=" flex justify-between gap-2">
|
||||
<div className="flex flex-row items-center gap-3 py-3">
|
||||
<Label>Gunakan Watermark</Label>
|
||||
<div className="flex items-center gap-3">
|
||||
<Switch defaultChecked color="primary" id="c2" />
|
||||
</div>
|
||||
</div>
|
||||
<Button color="destructive" onClick={handleRemoveAllFiles}>
|
||||
Remove All
|
||||
</Button>
|
||||
</div>
|
||||
</Fragment>
|
||||
) : null}
|
||||
</Fragment>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ import JoditEditor from "jodit-react";
|
|||
import { register } from "module";
|
||||
import { Switch } from "@/components/ui/switch";
|
||||
import Cookies from "js-cookie";
|
||||
import { createTask } from "@/config/api";
|
||||
import {
|
||||
createMedia,
|
||||
getTagsBySubCategoryId,
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ import JoditEditor from "jodit-react";
|
|||
import { register } from "module";
|
||||
import { Switch } from "@/components/ui/switch";
|
||||
import Cookies from "js-cookie";
|
||||
import { createTask } from "@/config/api";
|
||||
import {
|
||||
convertSPIT,
|
||||
createMedia,
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ import JoditEditor from "jodit-react";
|
|||
import { register } from "module";
|
||||
import { Switch } from "@/components/ui/switch";
|
||||
import Cookies from "js-cookie";
|
||||
import { createTask } from "@/config/api";
|
||||
import {
|
||||
createMedia,
|
||||
getTagsBySubCategoryId,
|
||||
|
|
|
|||
|
|
@ -115,8 +115,8 @@ export default function PublishMediahub() {
|
|||
setIsLoading(true);
|
||||
try {
|
||||
const response = await getUserLevelForAssignments();
|
||||
setListDest(response.data.data.list);
|
||||
const initialExpandedState = response.data.data.list.reduce(
|
||||
setListDest(response?.data?.data.list);
|
||||
const initialExpandedState = response?.data?.data.list.reduce(
|
||||
(acc: any, polda: any) => {
|
||||
acc[polda.id] = false;
|
||||
return acc;
|
||||
|
|
|
|||
|
|
@ -110,8 +110,8 @@ export default function PublishMedsos() {
|
|||
setIsLoading(true);
|
||||
try {
|
||||
const response = await getUserLevelForAssignments();
|
||||
setListDest(response.data.data.list);
|
||||
const initialExpandedState = response.data.data.list.reduce(
|
||||
setListDest(response?.data?.data.list);
|
||||
const initialExpandedState = response?.data?.data.list.reduce(
|
||||
(acc: any, polda: any) => {
|
||||
acc[polda.id] = false;
|
||||
return acc;
|
||||
|
|
|
|||
|
|
@ -112,12 +112,12 @@ export default function FormEvent() {
|
|||
console.log("Form Data Submitted:", requestData);
|
||||
|
||||
const response = await postSchedule(requestData);
|
||||
if (response.error) {
|
||||
error(response.message);
|
||||
if (response?.error) {
|
||||
error(response?.message);
|
||||
return false;
|
||||
}
|
||||
|
||||
Cookies.set("scheduleId", response.data.data.id, {
|
||||
Cookies.set("scheduleId", response?.data?.data.id, {
|
||||
expires: 1,
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -142,12 +142,12 @@ export default function FormEventUpdate() {
|
|||
|
||||
const response = await postSchedule(requestData);
|
||||
|
||||
if (response.error) {
|
||||
error(response.message);
|
||||
if (response?.error) {
|
||||
error(response?.message);
|
||||
return false;
|
||||
}
|
||||
|
||||
Cookies.set("scheduleId", response.data.data.id, {
|
||||
Cookies.set("scheduleId", response?.data?.data.id, {
|
||||
expires: 1,
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -149,12 +149,12 @@ export default function FormUpdatePressRelease() {
|
|||
|
||||
const response = await postSchedule(requestData);
|
||||
|
||||
if (response.error) {
|
||||
error(response.message);
|
||||
if (response?.error) {
|
||||
error(response?.message);
|
||||
return false;
|
||||
}
|
||||
|
||||
Cookies.set("scheduleId", response.data.data.id, {
|
||||
Cookies.set("scheduleId", response?.data?.data.id, {
|
||||
expires: 1,
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -112,12 +112,12 @@ export default function FormPressRelease() {
|
|||
console.log("Form Data Submitted:", requestData);
|
||||
|
||||
const response = await postSchedule(requestData);
|
||||
if (response.error) {
|
||||
error(response.message);
|
||||
if (response?.error) {
|
||||
error(response?.message);
|
||||
return false;
|
||||
}
|
||||
|
||||
Cookies.set("scheduleId", response.data.data.id, {
|
||||
Cookies.set("scheduleId", response?.data?.data.id, {
|
||||
expires: 1,
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -102,12 +102,12 @@ export default function FormPressConference() {
|
|||
console.log("Form Data Submitted:", requestData);
|
||||
|
||||
const response = await postSchedule(requestData);
|
||||
if (response.error) {
|
||||
error(response.message);
|
||||
if (response?.error) {
|
||||
error(response?.message);
|
||||
return false;
|
||||
}
|
||||
|
||||
Cookies.set("scheduleId", response.data.data.id, {
|
||||
Cookies.set("scheduleId", response?.data?.data.id, {
|
||||
expires: 1,
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -149,12 +149,12 @@ export default function FormUpdatePressConference() {
|
|||
|
||||
const response = await postSchedule(requestData);
|
||||
|
||||
if (response.error) {
|
||||
error(response.message);
|
||||
if (response?.error) {
|
||||
error(response?.message);
|
||||
return false;
|
||||
}
|
||||
|
||||
Cookies.set("scheduleId", response.data.data.id, {
|
||||
Cookies.set("scheduleId", response?.data?.data.id, {
|
||||
expires: 1,
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -122,8 +122,8 @@ export default function FormTaskDetail() {
|
|||
setIsLoading(true);
|
||||
try {
|
||||
const response = await getUserLevelForAssignments();
|
||||
setListDest(response.data.data.list);
|
||||
const initialExpandedState = response.data.data.list.reduce(
|
||||
setListDest(response?.data?.data.list);
|
||||
const initialExpandedState = response?.data?.data.list.reduce(
|
||||
(acc: any, polda: any) => {
|
||||
acc[polda.id] = false;
|
||||
return acc;
|
||||
|
|
|
|||
|
|
@ -122,8 +122,8 @@ export default function FormTaskEdit() {
|
|||
setIsLoading(true);
|
||||
try {
|
||||
const response = await getUserLevelForAssignments();
|
||||
setListDest(response.data.data.list);
|
||||
const initialExpandedState = response.data.data.list.reduce(
|
||||
setListDest(response?.data?.data.list);
|
||||
const initialExpandedState = response?.data?.data.list.reduce(
|
||||
(acc: any, polda: any) => {
|
||||
acc[polda.id] = false;
|
||||
return acc;
|
||||
|
|
|
|||
|
|
@ -126,8 +126,8 @@ export default function FormTask() {
|
|||
setIsLoading(true);
|
||||
try {
|
||||
const response = await getUserLevelForAssignments();
|
||||
setListDest(response.data.data.list);
|
||||
const initialExpandedState = response.data.data.list.reduce(
|
||||
setListDest(response?.data?.data.list);
|
||||
const initialExpandedState = response?.data?.data.list.reduce(
|
||||
(acc: any, polda: any) => {
|
||||
acc[polda.id] = false;
|
||||
return acc;
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import { zodResolver } from "@hookform/resolvers/zod";
|
|||
import { z } from "zod";
|
||||
import { cn, setCookiesEncrypt } from "@/lib/utils";
|
||||
import { Loader2 } from "lucide-react";
|
||||
import { getProfile, setLogin } from "@/service/auth";
|
||||
import { getProfile, login } from "@/service/auth";
|
||||
import { toast } from "sonner";
|
||||
import { Link, useRouter } from "@/components/navigation";
|
||||
import { warning } from "@/lib/swal";
|
||||
|
|
@ -49,13 +49,13 @@ const LoginForm = () => {
|
|||
// Fungsi submit form
|
||||
const onSubmit: SubmitHandler<LoginFormValues> = async (data) => {
|
||||
try {
|
||||
const response = await setLogin({
|
||||
const response = await login({
|
||||
...data,
|
||||
grant_type: "password",
|
||||
client_id: "mediahub-app",
|
||||
});
|
||||
|
||||
if (response.error) {
|
||||
if (response?.error) {
|
||||
toast.error("Username / Password Tidak Sesuai");
|
||||
} else {
|
||||
const { access_token } = response.data;
|
||||
|
|
@ -86,53 +86,53 @@ const LoginForm = () => {
|
|||
});
|
||||
warning("Akun Anda tidak dapat digunakan untuk masuk ke MediaHub Polri", "/auth/login");
|
||||
} else {
|
||||
Cookies.set("home_path", profile.data?.data?.homePath, {
|
||||
Cookies.set("home_path", profile?.data?.data?.homePath, {
|
||||
expires: 1,
|
||||
});
|
||||
Cookies.set("profile_picture", profile.data?.data?.profilePictureUrl, {
|
||||
Cookies.set("profile_picture", profile?.data?.data?.profilePictureUrl, {
|
||||
expires: 1,
|
||||
});
|
||||
Cookies.set("state", profile.data?.data?.userLevel?.name, {
|
||||
Cookies.set("state", profile?.data?.data?.userLevel?.name, {
|
||||
expires: 1,
|
||||
});
|
||||
setCookiesEncrypt("uie", profile.data.data?.id, {
|
||||
setCookiesEncrypt("uie", profile?.data?.data?.id, {
|
||||
expires: 1,
|
||||
});
|
||||
setCookiesEncrypt("urie", profile.data.data?.roleId, {
|
||||
setCookiesEncrypt("urie", profile?.data?.data?.roleId, {
|
||||
expires: 1,
|
||||
});
|
||||
setCookiesEncrypt("urne", profile.data.data?.role?.name, {
|
||||
setCookiesEncrypt("urne", profile?.data?.data?.role?.name, {
|
||||
expires: 1,
|
||||
});
|
||||
setCookiesEncrypt("ulie", profile.data.data?.userLevel?.id, {
|
||||
setCookiesEncrypt("ulie", profile?.data?.data?.userLevel?.id, {
|
||||
expires: 1,
|
||||
});
|
||||
setCookiesEncrypt("uplie", profile.data.data?.userLevel?.parentLevelId, {
|
||||
setCookiesEncrypt("uplie", profile?.data?.data?.userLevel?.parentLevelId, {
|
||||
expires: 1,
|
||||
});
|
||||
setCookiesEncrypt("ulne", profile.data.data?.userLevel?.levelNumber, {
|
||||
setCookiesEncrypt("ulne", profile?.data?.data?.userLevel?.levelNumber, {
|
||||
expires: 1,
|
||||
});
|
||||
setCookiesEncrypt("ufne", profile.data.data?.fullname, {
|
||||
setCookiesEncrypt("ufne", profile?.data?.data?.fullname, {
|
||||
expires: 1,
|
||||
});
|
||||
setCookiesEncrypt("ulnae", profile.data.data?.userLevel?.name, {
|
||||
setCookiesEncrypt("ulnae", profile?.data?.data?.userLevel?.name, {
|
||||
expires: 1,
|
||||
});
|
||||
setCookiesEncrypt("uinse", profile.data.data?.instituteId, {
|
||||
setCookiesEncrypt("uinse", profile?.data?.data?.instituteId, {
|
||||
expires: 1,
|
||||
});
|
||||
|
||||
if (
|
||||
Number(profile.data.data?.roleId) == 2 ||
|
||||
Number(profile.data.data?.roleId) == 3 ||
|
||||
Number(profile.data.data?.roleId) == 4 ||
|
||||
Number(profile.data.data?.roleId) == 9 ||
|
||||
Number(profile.data.data?.roleId) == 10 ||
|
||||
Number(profile.data.data?.roleId) == 11 ||
|
||||
Number(profile.data.data?.roleId) == 12
|
||||
Number(profile?.data?.data?.roleId) == 2 ||
|
||||
Number(profile?.data?.data?.roleId) == 3 ||
|
||||
Number(profile?.data?.data?.roleId) == 4 ||
|
||||
Number(profile?.data?.data?.roleId) == 9 ||
|
||||
Number(profile?.data?.data?.roleId) == 10 ||
|
||||
Number(profile?.data?.data?.roleId) == 11 ||
|
||||
Number(profile?.data?.data?.roleId) == 12
|
||||
) {
|
||||
if (profile.data.data?.userLevel?.id == 761 || profile.data.data?.userLevel?.parentLevelId == 761) {
|
||||
if (profile?.data?.data?.userLevel?.id == 761 || profile?.data?.data?.userLevel?.parentLevelId == 761) {
|
||||
window.location.href = "/in/welcome";
|
||||
// router.push('/admin/dashboard');
|
||||
Cookies.set("status", "login", {
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ import qs from "qs";
|
|||
|
||||
import axiosInstance from "./axiosInstance";
|
||||
import axiosInstanceJson from "./axiosInstanceJson";
|
||||
import axiosInterceptor from "./axiosInterceptor";
|
||||
import { data } from "@/app/[locale]/(protected)/charts/rechart/charts-rechart-bar/data";
|
||||
import { url } from "inspector";
|
||||
|
||||
|
|
|
|||
|
|
@ -1,59 +0,0 @@
|
|||
"use client";
|
||||
import axios from "axios";
|
||||
import Cookies from "js-cookie";
|
||||
import qs from "qs";
|
||||
|
||||
const baseURL = "https://netidhub.com/api/";
|
||||
const tokenAuth = Cookies.get("access_token")
|
||||
? Cookies.get("access_token")
|
||||
: null;
|
||||
const expired = Cookies.get("time_refresh")
|
||||
? Cookies.get("time_refresh")
|
||||
: null;
|
||||
|
||||
const axiosInterceptor = axios.create({
|
||||
baseURL,
|
||||
headers: {
|
||||
Authorization: `Bearer ${tokenAuth}`,
|
||||
},
|
||||
});
|
||||
|
||||
axiosInterceptor.interceptors.request.use(async (req) => {
|
||||
const time = new Date();
|
||||
const expiredValue = Cookies.get("time_refresh"); // Assuming 'time_refresh' contains `expired`
|
||||
|
||||
if (expiredValue) {
|
||||
const expired = new Date(expiredValue); // Ensure valid Date object
|
||||
if (time.getTime() >= expired.getTime()) {
|
||||
const url = `${baseURL}/signin`;
|
||||
const data = {
|
||||
grant_type: "refresh_token",
|
||||
client_id: "mediahub-app",
|
||||
refresh_token: Cookies.get("refresh_token") || "", // Fallback to empty string if undefined
|
||||
};
|
||||
|
||||
const response = await axios
|
||||
.post(url, qs.stringify(data))
|
||||
.catch((error) => error.response);
|
||||
|
||||
if (response?.status === 401) {
|
||||
Object.keys(Cookies.get() || {}).forEach((cookieName) => {
|
||||
Cookies.remove(cookieName);
|
||||
});
|
||||
// window.location.href = "/";
|
||||
} else {
|
||||
const { access_token, refresh_token } = response?.data || {};
|
||||
const dateTime = new Date();
|
||||
const newTime = dateTime.getTime() + 10 * 60 * 1000;
|
||||
Cookies.set("access_token", access_token, { expires: 1 });
|
||||
Cookies.set("refresh_token", refresh_token, { expires: 1 });
|
||||
Cookies.set("time_refresh", new Date(newTime).toISOString(), {
|
||||
expires: 1,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
return req;
|
||||
});
|
||||
|
||||
export default axiosInterceptor;
|
||||
|
|
@ -1,18 +1,19 @@
|
|||
import { getAPIInterceptor, postAPIInterceptor } from "@/config/api";
|
||||
import { httpGetInterceptor, httpPostInterceptor } from "../http-config/http-interceptor-service";
|
||||
|
||||
|
||||
export async function getAgendaSettingsById(id: any) {
|
||||
const url = `agenda-settings?id=${id}`;
|
||||
return getAPIInterceptor(url);
|
||||
return httpGetInterceptor(url);
|
||||
}
|
||||
|
||||
export async function getAgendaSettingsList(year = "", month = "", type = "") {
|
||||
const url = `agenda-settings/list?year=${year}&month=${month}&type=${type}`;
|
||||
return getAPIInterceptor(url);
|
||||
return httpGetInterceptor(url);
|
||||
}
|
||||
|
||||
export async function saveAgendaSettings(data: any) {
|
||||
const url = `agenda-settings`;
|
||||
return postAPIInterceptor(url, data);
|
||||
return httpPostInterceptor(url, data);
|
||||
}
|
||||
|
||||
export async function getPlanningDailyByTypeId(
|
||||
|
|
@ -25,12 +26,12 @@ export async function getPlanningDailyByTypeId(
|
|||
const url = `planning/pagination/daily?enablePage=1&time=1&size=${size}&page=${page}&date=${date}&typeId=${typeId}${
|
||||
parentId ? `&parentId=${parentId}` : ""
|
||||
}`;
|
||||
return getAPIInterceptor(url);
|
||||
return httpGetInterceptor(url);
|
||||
}
|
||||
|
||||
export async function getMonthlyPlanList(dates: any, typeId: number) {
|
||||
const url = `planning/monthly/list?date=${dates}&typeId=${typeId}`;
|
||||
return getAPIInterceptor(url);
|
||||
return httpGetInterceptor(url);
|
||||
}
|
||||
|
||||
export async function getWeeklyPlanList(
|
||||
|
|
@ -39,12 +40,12 @@ export async function getWeeklyPlanList(
|
|||
isMonthly = false
|
||||
) {
|
||||
const url = `planning/weekly/list?date=${dates}&typeId=${typeId}&isMonthly=${isMonthly}`;
|
||||
return getAPIInterceptor(url);
|
||||
return httpGetInterceptor(url);
|
||||
}
|
||||
|
||||
export async function getWeeklyPlanListByParentId(id: string, typeId: number) {
|
||||
const url = `planning/weekly/list?parentId=${id}&typeId=${typeId}`;
|
||||
return getAPIInterceptor(url);
|
||||
return httpGetInterceptor(url);
|
||||
}
|
||||
|
||||
export async function getPlanningPagination(
|
||||
|
|
@ -56,12 +57,12 @@ export async function getPlanningPagination(
|
|||
parentId = ""
|
||||
) {
|
||||
const url = `planning/pagination?enablePage=1&size=${size}&page=${page}&title=${title}&typeId=${typeId}&time=${time}&parentId=${parentId}`;
|
||||
return getAPIInterceptor(url);
|
||||
return httpGetInterceptor(url);
|
||||
}
|
||||
|
||||
export async function savePlanning(data: any) {
|
||||
const url = "planning";
|
||||
return postAPIInterceptor(url, data);
|
||||
return httpPostInterceptor(url, data);
|
||||
}
|
||||
|
||||
export async function getPlanningMonthlyPerSocmed(
|
||||
|
|
@ -71,7 +72,7 @@ export async function getPlanningMonthlyPerSocmed(
|
|||
parentId = ""
|
||||
) {
|
||||
const url = `planning/socmed/monthly?month=${month}&year=${year}&typeId=${typeId}&parentId=${parentId}`;
|
||||
return getAPIInterceptor(url);
|
||||
return httpGetInterceptor(url);
|
||||
}
|
||||
|
||||
export async function getPlanningDailyMedsosByPlatform(
|
||||
|
|
@ -81,5 +82,5 @@ export async function getPlanningDailyMedsosByPlatform(
|
|||
platformTypeId: string
|
||||
) {
|
||||
const url = `planning/pagination/daily?enablePage=1&size=${size}&page=${page}&date=${date}&typeId=2&platformTypeId=${platformTypeId}`;
|
||||
return getAPIInterceptor(url);
|
||||
return httpGetInterceptor(url);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,43 +1,33 @@
|
|||
import {
|
||||
getAPI,
|
||||
getAPIInterceptor,
|
||||
postAPI,
|
||||
postAPIInterceptor,
|
||||
postAPIWithJson,
|
||||
} from "../config/api";
|
||||
import { getAPIDummy } from "./http-config/axiosCustom";
|
||||
|
||||
import { httpPost } from "./http-config/http-base-service";
|
||||
import {
|
||||
httpGetInterceptor,
|
||||
httpGetInterceptorWithToken,
|
||||
httpPostInterceptor,
|
||||
} from "./http-config/http-interceptor-service";
|
||||
|
||||
export async function setLogin(data: any) {
|
||||
export async function login(data: any) {
|
||||
const pathUrl = "signin";
|
||||
return postAPI(pathUrl, data);
|
||||
return httpPost(pathUrl, data);
|
||||
}
|
||||
|
||||
export async function getProfile(token: any) {
|
||||
const url = "users/info";
|
||||
return getAPI(url, token);
|
||||
return httpGetInterceptorWithToken(url, token);
|
||||
}
|
||||
|
||||
export async function getInfoProfile() {
|
||||
const url = "users/info";
|
||||
return getAPIInterceptor(url);
|
||||
return httpGetInterceptor(url);
|
||||
}
|
||||
|
||||
export async function setupPassword(data: any) {
|
||||
const url = "setup-password";
|
||||
return postAPIInterceptor(url, data);
|
||||
return httpPostInterceptor(url, data);
|
||||
}
|
||||
|
||||
export async function saveUser(data: any) {
|
||||
const url = "users/save";
|
||||
return postAPIInterceptor(url, data);
|
||||
return httpPostInterceptor(url, data);
|
||||
}
|
||||
|
||||
export async function userInfo(token: any) {
|
||||
const pathUrl = `users/info`;
|
||||
return await httpGetInterceptorWithToken(pathUrl, token);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,4 @@
|
|||
import { title } from "process";
|
||||
import { httpGetInterceptor } from "../http-config/http-interceptor-service";
|
||||
import { getAPIInterceptor, postAPIInterceptor } from "@/config/api";
|
||||
import { httpGetInterceptor, httpPostInterceptor } from "../http-config/http-interceptor-service";
|
||||
|
||||
export async function paginationBlog(
|
||||
size: number,
|
||||
|
|
@ -14,15 +12,15 @@ export async function paginationBlog(
|
|||
|
||||
export async function postBlog(data: any) {
|
||||
const url = "blog";
|
||||
return postAPIInterceptor(url, data);
|
||||
return httpPostInterceptor(url, data);
|
||||
}
|
||||
|
||||
export async function getBlog(id: any) {
|
||||
const url = `blog/${id}`;
|
||||
return getAPIInterceptor(url);
|
||||
return httpGetInterceptor(url);
|
||||
}
|
||||
|
||||
export async function uploadThumbnailBlog(id: any, data: any) {
|
||||
const url = `blog/${id}/thumbnail`;
|
||||
return postAPIInterceptor(url, data);
|
||||
return httpPostInterceptor(url, data);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
import { getAPIInterceptor, postAPIInterceptor } from "@/config/api";
|
||||
import {
|
||||
httpGetInterceptor,
|
||||
httpPostInterceptor,
|
||||
|
|
@ -55,20 +54,20 @@ export async function saveTicketing(data: any) {
|
|||
|
||||
export async function getTicketingInternalDetail(id: any) {
|
||||
const url = `ticketing/internal?id=${id}`;
|
||||
return getAPIInterceptor(url);
|
||||
return httpGetInterceptor(url);
|
||||
}
|
||||
|
||||
export async function getTicketingInternalDiscussion(id: any) {
|
||||
const url = `ticketing/internal/discussion?ticketId=${id}`;
|
||||
return getAPIInterceptor(url);
|
||||
return httpGetInterceptor(url);
|
||||
}
|
||||
|
||||
export async function saveTicketInternalReply(data: any) {
|
||||
const url = "ticketing/internal/discussion";
|
||||
return postAPIInterceptor(url, data);
|
||||
return httpPostInterceptor(url, data);
|
||||
}
|
||||
|
||||
export async function getTicketingDetail(id: any) {
|
||||
const url = `ticketing?id=${id}`;
|
||||
return getAPIInterceptor(url);
|
||||
return httpGetInterceptor(url);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { getAPIInterceptor } from "@/config/api";
|
||||
import { httpGetInterceptor } from "../http-config/http-interceptor-service";
|
||||
import { httpGet, httpPost } from "../http-config/nulisAIApi";
|
||||
|
||||
export async function generateDataArticle(data: any) {
|
||||
|
|
@ -102,10 +102,10 @@ export async function generateDataBulkArticle(data: any) {
|
|||
|
||||
export async function listNulisAI(page: any, limit: any) {
|
||||
const url = `media/nulis-ai/pagination?enablePage=1&page=${page}&size=${limit}`;
|
||||
return getAPIInterceptor(url);
|
||||
return httpGetInterceptor(url);
|
||||
}
|
||||
|
||||
export async function detailMediaNulis(id: any) {
|
||||
const url = `media/nulis-ai?id=${id}`;
|
||||
return getAPIInterceptor({ url });
|
||||
return httpGetInterceptor({ url });
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
import { getAPI, getAPIInterceptor, postAPIInterceptor } from "@/config/api";
|
||||
import { httpGetInterceptor } from "../http-config/http-interceptor-service";
|
||||
import { httpGetInterceptor, httpPostInterceptor } from "../http-config/http-interceptor-service";
|
||||
|
||||
// export async function listDataAll(
|
||||
// isForSelf,
|
||||
|
|
@ -19,7 +18,7 @@ import { httpGetInterceptor } from "../http-config/http-interceptor-service";
|
|||
// }&endDate=${
|
||||
// endDate == undefined ? "" : endDate
|
||||
// }&needApprovalFromLevel=${needApprovalFromLevel}`;
|
||||
// return getAPIInterceptor({ url });
|
||||
// return httpGetInterceptor({ url });
|
||||
// }
|
||||
|
||||
export async function listDataAll(
|
||||
|
|
@ -37,7 +36,7 @@ export async function listDataAll(
|
|||
endDate: any,
|
||||
title: string = ""
|
||||
) {
|
||||
return await getAPIInterceptor(
|
||||
return await httpGetInterceptor(
|
||||
`media/list?enablePage=1&sortBy=createdAt&sort=desc&size=${limit}&page=${page}&isForSelf=${isForSelf}&isApproval=${isApproval}&typeId=${fileTypeFilter}&statusId=${statusFilter}&needApprovalFromLevel=${needApprovalFromLevel}&title=${title}`
|
||||
);
|
||||
}
|
||||
|
|
@ -56,7 +55,7 @@ export async function listDataImage(
|
|||
endDate: any,
|
||||
title: string = ""
|
||||
) {
|
||||
return await getAPIInterceptor(
|
||||
return await httpGetInterceptor(
|
||||
`media/list?enablePage=1&sortBy=createdAt&sort=desc&size=${limit}&page=${page}&typeId=1&isForSelf=${isForSelf}&isApproval=${isApproval}&categoryId=${categoryFilter}&statusId=${statusFilter}&needApprovalFromLevel=${needApprovalFromLevel}&creatorUserLevelName=${source}&creatorName=${creator}&startDate=${startDate}&endDate=${endDate}&title=${title}`
|
||||
);
|
||||
}
|
||||
|
|
@ -75,7 +74,7 @@ export async function listDataVideo(
|
|||
endDate: any,
|
||||
title: string = ""
|
||||
) {
|
||||
return await getAPIInterceptor(
|
||||
return await httpGetInterceptor(
|
||||
`media/list?enablePage=1&sortBy=createdAt&sort=desc&size=${limit}&page=${page}&typeId=2&isForSelf=${isForSelf}&isApproval=${isApproval}&categoryId=${categoryFilter}&statusId=${statusFilter}&needApprovalFromLevel=${needApprovalFromLevel}&creatorUserLevelName=${source}&creatorName=${creator}&startDate=${startDate}&endDate=${endDate}&title=${title}`
|
||||
);
|
||||
}
|
||||
|
|
@ -94,7 +93,7 @@ export async function listDataTeks(
|
|||
endDate: any,
|
||||
title: string = ""
|
||||
) {
|
||||
return await getAPIInterceptor(
|
||||
return await httpGetInterceptor(
|
||||
`media/list?enablePage=1&sortBy=createdAt&sort=desc&size=${limit}&page=${page}&typeId=3&isForSelf=${isForSelf}&isApproval=${isApproval}&categoryId=${categoryFilter}&statusId=${statusFilter}&needApprovalFromLevel=${needApprovalFromLevel}&creatorUserLevelName=${source}&creatorName=${creator}&startDate=${startDate}&endDate=${endDate}&title=${title}`
|
||||
);
|
||||
}
|
||||
|
|
@ -113,7 +112,7 @@ export async function listDataAudio(
|
|||
endDate: any,
|
||||
title: string = ""
|
||||
) {
|
||||
return await getAPIInterceptor(
|
||||
return await httpGetInterceptor(
|
||||
`media/list?enablePage=1&sortBy=createdAt&sort=desc&size=${limit}&page=${page}&typeId=4&isForSelf=${isForSelf}&isApproval=${isApproval}&categoryId=${categoryFilter}&statusId=${statusFilter}&needApprovalFromLevel=${needApprovalFromLevel}&creatorUserLevelName=${source}&creatorName=${creator}&startDate=${startDate}&endDate=${endDate}&title=${title}`
|
||||
);
|
||||
}
|
||||
|
|
@ -130,48 +129,48 @@ export async function listSPIT(
|
|||
}
|
||||
|
||||
export async function listNulisAI(limit: any, page: any, title: string = "") {
|
||||
return await getAPIInterceptor(
|
||||
return await httpGetInterceptor(
|
||||
`media/nulis-ai/pagination?enablePage=1&page=${page}&size=${limit}&title=${title}`
|
||||
);
|
||||
}
|
||||
|
||||
export async function getTagsBySubCategoryId(subCategory: any) {
|
||||
return await getAPIInterceptor(
|
||||
return await httpGetInterceptor(
|
||||
`media/tags/list?subCategoryId=${subCategory}`
|
||||
);
|
||||
}
|
||||
|
||||
export async function listEnableCategory(type: any) {
|
||||
const url = `media/categories/list/enable?enablePage=0&sort=desc&sortBy=id&type=${type}`;
|
||||
return getAPIInterceptor(url);
|
||||
return httpGetInterceptor(url);
|
||||
}
|
||||
|
||||
export async function listCategory(type: any) {
|
||||
const url = `media/categories/list/publish?enablePage=0&sort=desc&sortBy=id&categoryId=${type}`;
|
||||
return getAPIInterceptor(url);
|
||||
return httpGetInterceptor(url);
|
||||
}
|
||||
|
||||
export async function getTags() {
|
||||
const url = "media/tags/list";
|
||||
return getAPIInterceptor(url);
|
||||
return httpGetInterceptor(url);
|
||||
}
|
||||
|
||||
export async function createMedia(data: any) {
|
||||
const url = "media";
|
||||
return postAPIInterceptor(url, data);
|
||||
return httpPostInterceptor(url, data);
|
||||
}
|
||||
|
||||
export async function uploadThumbnail(id: any, data: any) {
|
||||
const url = `media/upload?id=${id}&operation=thumbnail`;
|
||||
return postAPIInterceptor(url, data);
|
||||
return httpPostInterceptor(url, data);
|
||||
}
|
||||
|
||||
export async function detailSPIT(id: any) {
|
||||
const url = `media/spit?id=${id}`;
|
||||
return getAPIInterceptor(url);
|
||||
return httpGetInterceptor(url);
|
||||
}
|
||||
|
||||
export async function convertSPIT(data: any) {
|
||||
const url = "media/spit/convert";
|
||||
return postAPIInterceptor(url, data);
|
||||
return httpPostInterceptor(url, data);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
import { getAPIInterceptor } from "@/config/api";
|
||||
import {
|
||||
httpGetInterceptor,
|
||||
httpPostInterceptor,
|
||||
|
|
@ -21,5 +20,5 @@ export async function createTask(data: any) {
|
|||
|
||||
export async function getContestById(id: any, pages = 0) {
|
||||
const url = `contest?id=${id}&page=${pages}`;
|
||||
return getAPIInterceptor(url);
|
||||
return httpGetInterceptor(url);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { getAPIInterceptor } from "@/config/api";
|
||||
import { httpGetInterceptor } from "../http-config/http-interceptor-service";
|
||||
|
||||
export async function detailMedia(id: any) {
|
||||
const url = `media?id=${id}`;
|
||||
return getAPIInterceptor(url);
|
||||
return httpGetInterceptor(url);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
import { getAPI, getAPIInterceptor } from "@/config/api";
|
||||
import { httpGet, httpPost } from "./http-config/http-base-service";
|
||||
import {
|
||||
httpGetInterceptor,
|
||||
httpGetInterceptorWithToken,
|
||||
} from "./http-config/http-interceptor-service";
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { getAPIInterceptor } from "@/config/api";
|
||||
import { httpGetInterceptor } from "../http-config/http-interceptor-service";
|
||||
|
||||
export async function getMediaTrackingMonitoring(page: number, size: number) {
|
||||
const url = `cekmedsos/monitoring/pagination?page=${page}&size=${size}`;
|
||||
return getAPIInterceptor(url);
|
||||
return httpGetInterceptor(url);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { getAPIInterceptor } from "@/config/api";
|
||||
import { httpGetInterceptor } from "../http-config/http-interceptor-service";
|
||||
|
||||
export async function getNotifications(page = 0, pageSize = 10) {
|
||||
const url = `notification/list?enablePage=1&page=${page}&pageSize=${pageSize}`;
|
||||
return getAPIInterceptor(url);
|
||||
return httpGetInterceptor(url);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
import { getAPIInterceptor, postAPIInterceptor } from "@/config/api";
|
||||
import { httpGetInterceptor } from "../http-config/http-interceptor-service";
|
||||
import { httpGetInterceptor, httpPostInterceptor } from "../http-config/http-interceptor-service";
|
||||
|
||||
export async function getPlanningSentPagination(
|
||||
size: number,
|
||||
|
|
@ -14,10 +13,10 @@ export async function getPlanningSentPagination(
|
|||
|
||||
export async function getPlanningById(id: any) {
|
||||
const url = `planning?id=${id}`;
|
||||
return getAPIInterceptor(url);
|
||||
return httpGetInterceptor(url);
|
||||
}
|
||||
|
||||
export async function publishPlanning(data: any) {
|
||||
const url = "planning/publish";
|
||||
return postAPIInterceptor(url, data);
|
||||
return httpPostInterceptor(url, data);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
import { title } from "process";
|
||||
import { httpGetInterceptor } from "../http-config/http-interceptor-service";
|
||||
import { type } from "os";
|
||||
import { getAPI, getAPIInterceptor, postAPIInterceptor } from "@/config/api";
|
||||
import { httpGetInterceptor, httpPostInterceptor } from "../http-config/http-interceptor-service";
|
||||
import { httpGet } from "../http-config/http-base-service";
|
||||
|
||||
export async function paginationSchedule(
|
||||
size: number,
|
||||
|
|
@ -16,31 +14,31 @@ export async function paginationSchedule(
|
|||
|
||||
export async function postSchedule(data: any) {
|
||||
const url = "schedule";
|
||||
return postAPIInterceptor(url, data);
|
||||
return httpPostInterceptor(url, data);
|
||||
}
|
||||
|
||||
export async function detailSchedule(id: any) {
|
||||
const url = `public/schedule?id=${id}`;
|
||||
return getAPIInterceptor(url);
|
||||
return httpGetInterceptor(url);
|
||||
}
|
||||
|
||||
export async function listScheduleTodayPublic(group = null) {
|
||||
const url = `public/schedule/today?group=${group}`;
|
||||
return getAPI( url, null );
|
||||
return httpGet( url, null );
|
||||
}
|
||||
|
||||
export async function listScheduleNextPublic(group = null) {
|
||||
const url = `public/schedule/next-activity?group=${group}`;
|
||||
return getAPI( url, null );
|
||||
return httpGet( url, null );
|
||||
}
|
||||
|
||||
export async function listSchedulePrevPublic(group = null) {
|
||||
const url = `public/schedule/prev-activity?group=${group}`;
|
||||
return getAPI( url, null );
|
||||
return httpGet( url, null );
|
||||
}
|
||||
|
||||
export async function listSchedule(group = null) {
|
||||
const url = `public/schedule/list?group=${group}`;
|
||||
return getAPI( url, null );
|
||||
return httpGet( url, null );
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,50 +1,6 @@
|
|||
"use client";
|
||||
import axios from "axios";
|
||||
import Cookies from "js-cookie";
|
||||
import qs from "qs";
|
||||
|
||||
import { data } from "@/app/[locale]/(protected)/charts/rechart/charts-rechart-bar/data";
|
||||
import { url } from "inspector";
|
||||
|
||||
const baseURL = "https://netidhub.com/api/";
|
||||
const tokenAuth = Cookies.get("access_token")
|
||||
? Cookies.get("access_token")
|
||||
: null;
|
||||
import { getAPIInterceptor } from "@/config/api";
|
||||
import axiosInterceptor from "@/config/axiosInterceptor";
|
||||
|
||||
export async function postAPIInterceptorTableau(url: string, data?: any) {
|
||||
const response = await axiosInterceptor
|
||||
.post(url, data)
|
||||
.catch((error) => error.response);
|
||||
|
||||
if (response?.status === 401) {
|
||||
Object.keys(Cookies.get()).forEach((cookieName) => {
|
||||
Cookies.remove(cookieName);
|
||||
});
|
||||
window.location.href = "/";
|
||||
} else if (response?.status > 300 && response?.status !== 401) {
|
||||
return {
|
||||
error: true,
|
||||
message: response?.data?.message,
|
||||
data: null,
|
||||
};
|
||||
} else if (response?.data?.success) {
|
||||
return {
|
||||
error: false,
|
||||
message: "success",
|
||||
data: response?.data,
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
error: true,
|
||||
message: response?.data?.message,
|
||||
data: null,
|
||||
};
|
||||
}
|
||||
import { httpPostInterceptor } from "../http-config/http-interceptor-service";
|
||||
|
||||
export async function generateTicket() {
|
||||
const url = "/admin/tableau-ticket";
|
||||
return postAPIInterceptorTableau(url);
|
||||
return httpPostInterceptor(url, null);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,6 @@
|
|||
import { title } from "process";
|
||||
import {
|
||||
deleteAPIInterceptor,
|
||||
getAPIInterceptor,
|
||||
postAPI,
|
||||
postAPIInterceptor,
|
||||
} from "../config/api";
|
||||
import {
|
||||
httpDeleteInterceptor,
|
||||
httpGetInterceptor,
|
||||
httpPostInterceptor,
|
||||
} from "./http-config/http-interceptor-service";
|
||||
|
|
@ -23,7 +18,7 @@ export async function listTask(
|
|||
taskType: string
|
||||
) {
|
||||
const url = `assignment/list?enablePage=1&size=${size}&page=${page}&title=${title}&taskType=${taskType}`;
|
||||
return getAPIInterceptor(url);
|
||||
return httpGetInterceptor(url);
|
||||
}
|
||||
|
||||
// export async function createTask(data: any) {
|
||||
|
|
@ -33,70 +28,70 @@ export async function listTask(
|
|||
|
||||
export async function createTask(data: any) {
|
||||
const pathUrl = "assignment";
|
||||
return postAPIInterceptor(pathUrl, data);
|
||||
return httpPostInterceptor(pathUrl, data);
|
||||
}
|
||||
|
||||
export async function getTask(id: any) {
|
||||
const url = `/assignment?id=${id}`;
|
||||
return getAPIInterceptor(url);
|
||||
return httpGetInterceptor(url);
|
||||
}
|
||||
|
||||
export async function forwardTask(data: any) {
|
||||
const url = "assignment/forward";
|
||||
return postAPIInterceptor(url, data);
|
||||
return httpPostInterceptor(url, data);
|
||||
}
|
||||
|
||||
export async function finishTask(id: any) {
|
||||
const url = `assignment/finish?id=${id}`;
|
||||
return postAPIInterceptor(url, id);
|
||||
return httpPostInterceptor(url, id);
|
||||
}
|
||||
|
||||
export async function deleteTask(id: any) {
|
||||
const url = `assignment?id=${id}`;
|
||||
return deleteAPIInterceptor(url, id);
|
||||
return httpDeleteInterceptor(url);
|
||||
}
|
||||
|
||||
export async function getUserLevelForAssignments() {
|
||||
const url = "/users/user-levels/assignment";
|
||||
return getAPIInterceptor(url);
|
||||
return httpGetInterceptor(url);
|
||||
}
|
||||
|
||||
export async function getAssignmentResponseList(id: any) {
|
||||
const url = `assignment/response?assignmentId=${id}`;
|
||||
return getAPIInterceptor({ url });
|
||||
return httpGetInterceptor({ url });
|
||||
}
|
||||
|
||||
export async function createAssignmentResponse(data: any) {
|
||||
const url = "assignment/response";
|
||||
return postAPIInterceptor(url, data);
|
||||
return httpPostInterceptor(url, data);
|
||||
}
|
||||
|
||||
export async function deleteAssignmentResponse(id: any) {
|
||||
const url = `assignment/response?id=${id}`;
|
||||
return deleteAPIInterceptor(url, id);
|
||||
return httpDeleteInterceptor(url);
|
||||
}
|
||||
|
||||
export async function getAcceptance(id: any, isAccept: any) {
|
||||
const url = `assignment/acceptance?id=${id}&isAccept=${isAccept}`;
|
||||
return getAPIInterceptor({ url });
|
||||
return httpGetInterceptor({ url });
|
||||
}
|
||||
|
||||
export async function acceptAssignment(id: any, isAccept: any) {
|
||||
const url = `assignment/acceptance?id=${id}`;
|
||||
return postAPIInterceptor(url, id);
|
||||
return httpPostInterceptor(url, id);
|
||||
}
|
||||
|
||||
export async function postFinishAcceptance(id: any) {
|
||||
const url = `assignment/finish-acceptance?id=${id}`;
|
||||
return postAPIInterceptor(url, id);
|
||||
return httpPostInterceptor(url, id);
|
||||
}
|
||||
|
||||
export async function getAcceptanceAssignmentStatus(id: any) {
|
||||
const url = `assignment/acceptance/status?id=${id}`;
|
||||
return getAPIInterceptor({ url });
|
||||
return httpGetInterceptor({ url });
|
||||
}
|
||||
|
||||
export async function getListAttachment(assignmentId: any, isForCreator: any) {
|
||||
const url = `media/list?&enablePage=0&assignmentId=${assignmentId}&isForAdmin=${isForCreator}`;
|
||||
return getAPIInterceptor({ url });
|
||||
return httpGetInterceptor({ url });
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue