feat: fixing all services
This commit is contained in:
parent
f716962438
commit
cd1bf08771
|
|
@ -27,7 +27,7 @@ import {
|
||||||
saveManualContext,
|
saveManualContext,
|
||||||
updateManualArticle,
|
updateManualArticle,
|
||||||
} from "@/service/generate-article";
|
} from "@/service/generate-article";
|
||||||
import { getUserLevels } from "@/service/user-levels/user-levels-service";
|
import { getUserLevels } from "@/service/user-levels-service";
|
||||||
import { Checkbox } from "@/components/ui/checkbox";
|
import { Checkbox } from "@/components/ui/checkbox";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { getCategoryById } from "@/service/master-categories";
|
import { getCategoryById } from "@/service/master-categories";
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ import { z } from "zod";
|
||||||
import ReactSelect from "react-select";
|
import ReactSelect from "react-select";
|
||||||
import makeAnimated from "react-select/animated";
|
import makeAnimated from "react-select/animated";
|
||||||
import { editMasterUsers, getDetailMasterUsers } from "@/service/master-user";
|
import { editMasterUsers, getDetailMasterUsers } from "@/service/master-user";
|
||||||
import { getAllUserLevels } from "@/service/user-levels/user-levels-service";
|
import { getAllUserLevels } from "@/service/user-levels-service";
|
||||||
import { listUserRole } from "@/service/master-user-role";
|
import { listUserRole } from "@/service/master-user-role";
|
||||||
import { Card } from "../ui/card";
|
import { Card } from "../ui/card";
|
||||||
import { Label } from "../ui/label";
|
import { Label } from "../ui/label";
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ import ReactSelect from "react-select";
|
||||||
import makeAnimated from "react-select/animated";
|
import makeAnimated from "react-select/animated";
|
||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
import { zodResolver } from "@hookform/resolvers/zod";
|
||||||
import { createMasterUser } from "@/service/master-user";
|
import { createMasterUser } from "@/service/master-user";
|
||||||
import { getAllUserLevels } from "@/service/user-levels/user-levels-service";
|
import { getAllUserLevels } from "@/service/user-levels-service";
|
||||||
import { listUserRole } from "@/service/master-user-role";
|
import { listUserRole } from "@/service/master-user-role";
|
||||||
import { Card } from "../ui/card";
|
import { Card } from "../ui/card";
|
||||||
import { Input } from "../ui/input";
|
import { Input } from "../ui/input";
|
||||||
|
|
|
||||||
|
|
@ -78,13 +78,13 @@ export default function Login() {
|
||||||
secure: true,
|
secure: true,
|
||||||
sameSite: "strict",
|
sameSite: "strict",
|
||||||
});
|
});
|
||||||
const resActivity = await saveActivity(
|
await saveActivity(
|
||||||
{
|
{
|
||||||
activityTypeId: 1,
|
activityTypeId: 1,
|
||||||
url: "https://dev.mikulnews.com/auth",
|
url: "https://dev.mikulnews.com/auth",
|
||||||
userId: profile?.data?.data?.id,
|
userId: profile?.data?.data?.id,
|
||||||
},
|
},
|
||||||
accessData?.id_token
|
response?.data?.data?.access_token
|
||||||
);
|
);
|
||||||
Cookies.set("profile_picture", profile?.data?.data?.profilePictureUrl, {
|
Cookies.set("profile_picture", profile?.data?.data?.profilePictureUrl, {
|
||||||
expires: 1,
|
expires: 1,
|
||||||
|
|
|
||||||
|
|
@ -27,12 +27,12 @@ import Image from "next/image";
|
||||||
import { Switch } from "@/components/ui/switch";
|
import { Switch } from "@/components/ui/switch";
|
||||||
import useDisclosure from "@/components/useDisclosure";
|
import useDisclosure from "@/components/useDisclosure";
|
||||||
import {
|
import {
|
||||||
createAdvertiseById,
|
|
||||||
createMediaFileAdvertise,
|
createMediaFileAdvertise,
|
||||||
deleteAdvertise,
|
deleteAdvertise,
|
||||||
editAdvertise,
|
editAdvertise,
|
||||||
editAdvertiseIsActive,
|
editAdvertiseIsActive,
|
||||||
getAdvertise,
|
getAdvertise,
|
||||||
|
getAdvertiseById,
|
||||||
} from "@/service/advertisement";
|
} from "@/service/advertisement";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { Input } from "@/components/ui/input";
|
import { Input } from "@/components/ui/input";
|
||||||
|
|
@ -226,7 +226,7 @@ export default function AdvertiseTable(props: { triggerRefresh: boolean }) {
|
||||||
};
|
};
|
||||||
|
|
||||||
const openModal = async (id: number) => {
|
const openModal = async (id: number) => {
|
||||||
const res = await createAdvertiseById(Number(id));
|
const res = await getAdvertiseById(Number(id));
|
||||||
const data = res?.data?.data;
|
const data = res?.data?.data;
|
||||||
setValue("id", String(data?.id));
|
setValue("id", String(data?.id));
|
||||||
setValue("title", data?.title);
|
setValue("title", data?.title);
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
import { PaginationRequest } from "@/types/globals";
|
import { httpGet, httpPost } from "./http-config/http-base-services";
|
||||||
import { httpGet, httpPost, httpPut } from "./http-config/axios-base-service";
|
|
||||||
|
|
||||||
export async function saveActivity(data: any, token?: string) {
|
export async function saveActivity(data: any, token?: string) {
|
||||||
const headers = token
|
const headers = token
|
||||||
|
|
@ -11,11 +10,10 @@ export async function saveActivity(data: any, token?: string) {
|
||||||
"content-type": "application/json",
|
"content-type": "application/json",
|
||||||
};
|
};
|
||||||
const pathUrl = `/activity-logs`;
|
const pathUrl = `/activity-logs`;
|
||||||
return await httpPost(pathUrl, headers, data);
|
return await httpPost(pathUrl, data, headers);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getActivity() {
|
export async function getActivity() {
|
||||||
const headers = { "content-type": "application/json" };
|
|
||||||
const pathUrl = `/activity-logs/statistics`;
|
const pathUrl = `/activity-logs/statistics`;
|
||||||
return await httpGet(pathUrl, headers);
|
return await httpGet(pathUrl);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,68 +1,42 @@
|
||||||
import {
|
|
||||||
httpDeleteInterceptor,
|
|
||||||
httpGet,
|
|
||||||
httpPost,
|
|
||||||
httpPut,
|
|
||||||
} from "./http-config/axios-base-service";
|
|
||||||
import Cookies from "js-cookie";
|
import Cookies from "js-cookie";
|
||||||
|
import { httpDeleteInterceptor, httpPostInterceptor, httpPutInterceptor } from "./http-config/http-interceptor-services";
|
||||||
|
import { httpGet } from "./http-config/http-base-services";
|
||||||
|
|
||||||
const token = Cookies.get("access_token");
|
const token = Cookies.get("access_token");
|
||||||
|
|
||||||
export async function createAdvertise(data: any) {
|
export async function createAdvertise(data: any) {
|
||||||
const headers = {
|
|
||||||
"content-type": "application/json",
|
|
||||||
Authorization: `Bearer ${token}`,
|
|
||||||
};
|
|
||||||
const pathUrl = `/advertisement`;
|
const pathUrl = `/advertisement`;
|
||||||
return await httpPost(pathUrl, headers, data);
|
return await httpPostInterceptor(pathUrl, data);
|
||||||
}
|
}
|
||||||
export async function createMediaFileAdvertise(id: string | number, data: any) {
|
export async function createMediaFileAdvertise(id: string | number, data: any) {
|
||||||
const headers = {
|
const headers = {
|
||||||
"content-type": "multipart/form-data",
|
"content-type": "multipart/form-data",
|
||||||
};
|
};
|
||||||
const pathUrl = `/advertisement/upload/${id}`;
|
const pathUrl = `/advertisement/upload/${id}`;
|
||||||
return await httpPost(pathUrl, headers, data);
|
return await httpPostInterceptor(pathUrl, data, headers);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getAdvertise(data: any) {
|
export async function getAdvertise(data: any) {
|
||||||
const headers = {
|
const pathUrl = `/advertisement?page=${data?.page || 1}&limit=${data?.limit || ""}&placement=${data?.placement || ""}&isPublish=${data.isPublish || ""}`;
|
||||||
"content-type": "application/json",
|
return await httpGet(pathUrl);
|
||||||
};
|
|
||||||
const pathUrl = `/advertisement?page=${data?.page || 1}&limit=${
|
|
||||||
data?.limit || ""
|
|
||||||
}&placement=${data?.placement || ""}&isPublish=${data.isPublish || ""}`;
|
|
||||||
return await httpGet(pathUrl, headers);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function createAdvertiseById(id: number) {
|
export async function getAdvertiseById(id: number) {
|
||||||
const headers = {
|
|
||||||
"content-type": "application/json",
|
|
||||||
};
|
|
||||||
const pathUrl = `/advertisement/${id}`;
|
const pathUrl = `/advertisement/${id}`;
|
||||||
return await httpGet(pathUrl, headers);
|
return await httpGet(pathUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function editAdvertise(data: any) {
|
export async function editAdvertise(data: any) {
|
||||||
const headers = {
|
|
||||||
"content-type": "application/json",
|
|
||||||
};
|
|
||||||
const pathUrl = `/advertisement/${data?.id}`;
|
const pathUrl = `/advertisement/${data?.id}`;
|
||||||
return await httpPut(pathUrl, headers, data);
|
return await httpPutInterceptor(pathUrl, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function editAdvertiseIsActive(data: any) {
|
export async function editAdvertiseIsActive(data: any) {
|
||||||
const headers = {
|
|
||||||
"content-type": "application/json",
|
|
||||||
Authorization: `Bearer ${token}`,
|
|
||||||
};
|
|
||||||
const pathUrl = `/advertisement/publish/${data?.id}?isPublish=${data?.isActive}`;
|
const pathUrl = `/advertisement/publish/${data?.id}?isPublish=${data?.isActive}`;
|
||||||
return await httpPut(pathUrl, headers);
|
return await httpPutInterceptor(pathUrl, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function deleteAdvertise(id: number) {
|
export async function deleteAdvertise(id: number) {
|
||||||
const headers = {
|
|
||||||
"content-type": "application/json",
|
|
||||||
};
|
|
||||||
const pathUrl = `/advertisement/${id}`;
|
const pathUrl = `/advertisement/${id}`;
|
||||||
return await httpDeleteInterceptor(pathUrl, headers);
|
return await httpDeleteInterceptor(pathUrl);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
import { PaginationRequest } from "@/types/globals";
|
import { PaginationRequest } from "@/types/globals";
|
||||||
import Cookies from "js-cookie";
|
|
||||||
import { httpGet } from "./http-config/http-base-services";
|
import { httpGet } from "./http-config/http-base-services";
|
||||||
import { httpDeleteInterceptor, httpGetInterceptor, httpPostInterceptor, httpPutInterceptor } from "./http-config/http-interceptor-services";
|
import { httpDeleteInterceptor, httpGetInterceptor, httpPostInterceptor, httpPutInterceptor } from "./http-config/http-interceptor-services";
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,8 @@ const baseURL = "https://dev.mikulnews.com/api";
|
||||||
const axiosBaseInstance = axios.create({
|
const axiosBaseInstance = axios.create({
|
||||||
baseURL,
|
baseURL,
|
||||||
headers: {
|
headers: {
|
||||||
"content-type": "application/json",
|
"Content-Type": "application/json",
|
||||||
|
"X-Client-Key": "bb65b1ad-e954-4a1a-b4d0-74df5bb0b640"
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,154 +0,0 @@
|
||||||
import { getCsrfToken } from "../master-user";
|
|
||||||
import axiosInterceptorInstance from "./axios-interceptor-instance";
|
|
||||||
import axiosBaseInstance from "./http-base-instance";
|
|
||||||
import mediahubBaseInstance from "./mediahub-base-service";
|
|
||||||
import Cookies from "js-cookie";
|
|
||||||
|
|
||||||
const defaultHeaders = {
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
};
|
|
||||||
|
|
||||||
export async function httpPost(pathUrl: any, headers: any, data?: any) {
|
|
||||||
const resCsrf = await getCsrfToken();
|
|
||||||
const csrfToken = resCsrf?.data?.csrf_token;
|
|
||||||
|
|
||||||
const mergedHeaders = {
|
|
||||||
...defaultHeaders,
|
|
||||||
...headers,
|
|
||||||
...(csrfToken ? { "X-CSRF-TOKEN": csrfToken } : {}),
|
|
||||||
};
|
|
||||||
|
|
||||||
const response = await axiosBaseInstance
|
|
||||||
.post(pathUrl, data, { headers: mergedHeaders })
|
|
||||||
.catch(function (error: any) {
|
|
||||||
console.log(error);
|
|
||||||
return error.response;
|
|
||||||
});
|
|
||||||
console.log("Response base svc : ", response);
|
|
||||||
if (response?.status == 200 || response?.status == 201) {
|
|
||||||
return {
|
|
||||||
error: false,
|
|
||||||
message: "success",
|
|
||||||
data: response?.data,
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
return {
|
|
||||||
error: true,
|
|
||||||
message: response?.data?.message || response?.data || null,
|
|
||||||
data: null,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function httpGet(pathUrl: any, headers: any) {
|
|
||||||
const response = await axiosInterceptorInstance
|
|
||||||
.get(pathUrl, { headers })
|
|
||||||
.catch(function (error: any) {
|
|
||||||
console.log(error);
|
|
||||||
return error.response;
|
|
||||||
});
|
|
||||||
console.log("Response base svc : ", response);
|
|
||||||
if (response?.status == 200 || response?.status == 201) {
|
|
||||||
return {
|
|
||||||
error: false,
|
|
||||||
message: "success",
|
|
||||||
data: response?.data,
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
return {
|
|
||||||
error: true,
|
|
||||||
message: response?.data?.message || response?.data || null,
|
|
||||||
data: null,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function httpPut(pathUrl: any, headers: any, data?: any) {
|
|
||||||
const resCsrf = await getCsrfToken();
|
|
||||||
const csrfToken = resCsrf?.data?.csrf_token;
|
|
||||||
|
|
||||||
const defaultHeaders = {
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
};
|
|
||||||
const mergedHeaders = {
|
|
||||||
...defaultHeaders,
|
|
||||||
...headers,
|
|
||||||
...(csrfToken ? { "X-CSRF-TOKEN": csrfToken } : {}),
|
|
||||||
};
|
|
||||||
|
|
||||||
const response = await axiosBaseInstance
|
|
||||||
.put(pathUrl, data, { headers: mergedHeaders })
|
|
||||||
.catch(function (error: any) {
|
|
||||||
console.log(error);
|
|
||||||
return error.response;
|
|
||||||
});
|
|
||||||
console.log("Response base svc : ", response);
|
|
||||||
if (response?.status == 200 || response?.status == 201) {
|
|
||||||
return {
|
|
||||||
error: false,
|
|
||||||
message: "success",
|
|
||||||
data: response?.data,
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
return {
|
|
||||||
error: true,
|
|
||||||
message: response?.data?.message || response?.data || null,
|
|
||||||
data: null,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function httpDeleteInterceptor(pathUrl: any, headers: any) {
|
|
||||||
const resCsrf = await getCsrfToken();
|
|
||||||
const csrfToken = resCsrf?.data?.csrf_token;
|
|
||||||
|
|
||||||
const defaultHeaders = {
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
};
|
|
||||||
const mergedHeaders = {
|
|
||||||
...defaultHeaders,
|
|
||||||
...headers,
|
|
||||||
...(csrfToken ? { "X-CSRF-TOKEN": csrfToken } : {}),
|
|
||||||
};
|
|
||||||
|
|
||||||
const response = await axiosBaseInstance
|
|
||||||
.delete(pathUrl, { headers: mergedHeaders })
|
|
||||||
.catch((error) => error.response);
|
|
||||||
console.log("Response interceptor : ", response);
|
|
||||||
if (response?.status == 200 || response?.status == 201) {
|
|
||||||
return {
|
|
||||||
error: false,
|
|
||||||
message: "success",
|
|
||||||
data: response?.data,
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
return {
|
|
||||||
error: true,
|
|
||||||
message: response?.data?.message || response?.data || null,
|
|
||||||
data: null,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function mediahubGet(pathUrl: any, headers: any) {
|
|
||||||
const response = await mediahubBaseInstance
|
|
||||||
.get(pathUrl, { headers })
|
|
||||||
.catch(function (error: any) {
|
|
||||||
console.log(error);
|
|
||||||
return error.response;
|
|
||||||
});
|
|
||||||
console.log("Response base svc : ", response);
|
|
||||||
if (response?.status == 200 || response?.status == 201) {
|
|
||||||
return {
|
|
||||||
error: false,
|
|
||||||
message: "success",
|
|
||||||
data: response?.data,
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
return {
|
|
||||||
error: true,
|
|
||||||
message: response?.data?.message || response?.data || null,
|
|
||||||
data: null,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,14 +0,0 @@
|
||||||
import axios from "axios";
|
|
||||||
|
|
||||||
const baseURL = "https://dev.mikulnews.com/api";
|
|
||||||
|
|
||||||
const axiosBaseInstance = axios.create({
|
|
||||||
baseURL,
|
|
||||||
headers: {
|
|
||||||
"content-type": "application/json",
|
|
||||||
"X-Client-Key": "bb65b1ad-e954-4a1a-b4d0-74df5bb0b640"
|
|
||||||
},
|
|
||||||
withCredentials: true,
|
|
||||||
});
|
|
||||||
|
|
||||||
export default axiosBaseInstance;
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import axiosBaseInstance from "./http-base-instance";
|
import axiosBaseInstance from "./axios-base-instance";
|
||||||
|
|
||||||
const defaultHeaders = {
|
const defaultHeaders = {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
|
|
|
||||||
|
|
@ -1,12 +0,0 @@
|
||||||
import axios from "axios";
|
|
||||||
|
|
||||||
const baseURL = "https://mediahub.polri.go.id/api";
|
|
||||||
|
|
||||||
const mediahubBaseInstance = axios.create({
|
|
||||||
baseURL,
|
|
||||||
headers: {
|
|
||||||
"content-type": "application/json",
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
export default mediahubBaseInstance;
|
|
||||||
|
|
@ -1,75 +1,50 @@
|
||||||
import { PaginationRequest } from "@/types/globals";
|
import { PaginationRequest } from "@/types/globals";
|
||||||
import {
|
|
||||||
httpDeleteInterceptor,
|
|
||||||
httpGet,
|
|
||||||
httpPost,
|
|
||||||
httpPut,
|
|
||||||
} from "./http-config/axios-base-service";
|
|
||||||
import Cookies from "js-cookie";
|
import Cookies from "js-cookie";
|
||||||
|
import { httpDeleteInterceptor, httpGetInterceptor, httpPostInterceptor, httpPutInterceptor } from "./http-config/http-interceptor-services";
|
||||||
|
|
||||||
const token = Cookies.get("access_token");
|
const token = Cookies.get("access_token");
|
||||||
|
|
||||||
export async function createMagazine(data: any) {
|
export async function createMagazine(data: any) {
|
||||||
const headers = {
|
|
||||||
"content-type": "application/json",
|
|
||||||
Authorization: `Bearer ${token}`,
|
|
||||||
};
|
|
||||||
const pathUrl = `/magazines`;
|
const pathUrl = `/magazines`;
|
||||||
return await httpPost(pathUrl, headers, data);
|
return await httpPostInterceptor(pathUrl, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getListMagazine(props: PaginationRequest) {
|
export async function getListMagazine(props: PaginationRequest) {
|
||||||
const { page, limit, search, startDate, endDate } = props;
|
const { page, limit, search, startDate, endDate } = props;
|
||||||
const headers = {
|
return await httpGetInterceptor(
|
||||||
"content-type": "application/json",
|
|
||||||
};
|
|
||||||
return await httpGet(
|
|
||||||
`/magazines?limit=${limit}&page=${page}&title=${search}&startDate=${
|
`/magazines?limit=${limit}&page=${page}&title=${search}&startDate=${
|
||||||
startDate || ""
|
startDate || ""
|
||||||
}&endDate=${endDate || ""}`,
|
}&endDate=${endDate || ""}`
|
||||||
headers
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function updateMagazine(id: string, data: any) {
|
export async function updateMagazine(id: string, data: any) {
|
||||||
const headers = {
|
|
||||||
"content-type": "application/json",
|
|
||||||
};
|
|
||||||
const pathUrl = `/magazines/${id}`;
|
const pathUrl = `/magazines/${id}`;
|
||||||
return await httpPut(pathUrl, headers, data);
|
return await httpPutInterceptor(pathUrl, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getMagazineById(id: string) {
|
export async function getMagazineById(id: string) {
|
||||||
const headers = {
|
return await httpGetInterceptor(`/magazines/${id}`);
|
||||||
"content-type": "application/json",
|
|
||||||
};
|
|
||||||
return await httpGet(`/magazines/${id}`, headers);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function deleteMagazine(id: string) {
|
export async function deleteMagazine(id: string) {
|
||||||
const headers = {
|
return await httpDeleteInterceptor(`magazines/${id}`);
|
||||||
"content-type": "application/json",
|
|
||||||
};
|
|
||||||
return await httpDeleteInterceptor(`magazines/${id}`, headers);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function uploadMagazineFile(id: string, data: any) {
|
export async function uploadMagazineFile(id: string, data: any) {
|
||||||
const headers = {
|
const headers = {
|
||||||
"content-type": "multipart/form-data",
|
"content-type": "multipart/form-data",
|
||||||
};
|
};
|
||||||
return await httpPost(`/magazine-files/${id}`, headers, data);
|
return await httpPostInterceptor(`/magazine-files/${id}`, data, headers);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function uploadMagazineThumbnail(id: string, data: any) {
|
export async function uploadMagazineThumbnail(id: string, data: any) {
|
||||||
const headers = {
|
const headers = {
|
||||||
"content-type": "multipart/form-data",
|
"content-type": "multipart/form-data",
|
||||||
};
|
};
|
||||||
return await httpPost(`/magazines/thumbnail/${id}`, headers, data);
|
return await httpPostInterceptor(`/magazines/thumbnail/${id}`, data, headers);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function deleteMagazineFiles(id: number) {
|
export async function deleteMagazineFiles(id: number) {
|
||||||
const headers = {
|
return await httpDeleteInterceptor(`magazine-files/${id}`);
|
||||||
"content-type": "multipart/form-data",
|
|
||||||
};
|
|
||||||
return await httpDeleteInterceptor(`magazine-files/${id}`, headers);
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,47 +1,29 @@
|
||||||
import {
|
|
||||||
httpDeleteInterceptor,
|
|
||||||
httpGet,
|
|
||||||
httpPost,
|
|
||||||
httpPut,
|
|
||||||
} from "./http-config/axios-base-service";
|
|
||||||
import Cookies from "js-cookie";
|
import Cookies from "js-cookie";
|
||||||
|
import { httpDeleteInterceptor, httpGetInterceptor, httpPostInterceptor, httpPutInterceptor } from "./http-config/http-interceptor-services";
|
||||||
|
|
||||||
const token = Cookies.get("access_token");
|
const token = Cookies.get("access_token");
|
||||||
|
|
||||||
export async function createCategory(data: any) {
|
export async function createCategory(data: any) {
|
||||||
const headers = {
|
|
||||||
"content-type": "application/json",
|
|
||||||
Authorization: `Bearer ${token}`,
|
|
||||||
};
|
|
||||||
const pathUrl = `/article-categories`;
|
const pathUrl = `/article-categories`;
|
||||||
return await httpPost(pathUrl, headers, data);
|
return await httpPostInterceptor(pathUrl, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function updateCategory(id: string, data: any) {
|
export async function updateCategory(id: string, data: any) {
|
||||||
const headers = {
|
|
||||||
"content-type": "application/json",
|
|
||||||
};
|
|
||||||
const pathUrl = `/article-categories/${id}`;
|
const pathUrl = `/article-categories/${id}`;
|
||||||
return await httpPut(pathUrl, headers, data);
|
return await httpPutInterceptor(pathUrl, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getCategoryById(id: number) {
|
export async function getCategoryById(id: number) {
|
||||||
const headers = {
|
return await httpGetInterceptor(`/article-categories/${id}`);
|
||||||
"content-type": "application/json",
|
|
||||||
};
|
|
||||||
return await httpGet(`/article-categories/${id}`, headers);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function deleteCategory(id: number) {
|
export async function deleteCategory(id: number) {
|
||||||
const headers = {
|
return await httpDeleteInterceptor(`article-categories/${id}`);
|
||||||
"content-type": "application/json",
|
|
||||||
};
|
|
||||||
return await httpDeleteInterceptor(`article-categories/${id}`, headers);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function uploadCategoryThumbnail(id: string, data: any) {
|
export async function uploadCategoryThumbnail(id: string, data: any) {
|
||||||
const headers = {
|
const headers = {
|
||||||
"content-type": "multipart/form-data",
|
"content-type": "multipart/form-data",
|
||||||
};
|
};
|
||||||
return await httpPost(`/article-categories/thumbnail/${id}`, headers, data);
|
return await httpPostInterceptor(`/article-categories/thumbnail/${id}`, data, headers);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,42 +1,29 @@
|
||||||
import {
|
|
||||||
httpDeleteInterceptor,
|
|
||||||
httpGet,
|
|
||||||
httpPost,
|
|
||||||
} from "./http-config/axios-base-service";
|
|
||||||
|
|
||||||
import Cookies from "js-cookie";
|
import Cookies from "js-cookie";
|
||||||
|
import { httpDeleteInterceptor, httpGetInterceptor, httpPostInterceptor } from "./http-config/http-interceptor-services";
|
||||||
|
|
||||||
const token = Cookies.get("access_token");
|
const token = Cookies.get("access_token");
|
||||||
|
|
||||||
export async function listUserRole(data: any) {
|
export async function listUserRole(data: any) {
|
||||||
const headers = {
|
return await httpGetInterceptor(
|
||||||
"content-type": "application/json",
|
`/user-roles?limit=${data.limit}&page=${data.page}`
|
||||||
};
|
|
||||||
return await httpGet(
|
|
||||||
`/user-roles?limit=${data.limit}&page=${data.page}`,
|
|
||||||
headers
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function createMasterUserRole(data: any) {
|
export async function createMasterUserRole(data: any) {
|
||||||
const headers = {
|
|
||||||
"content-type": "application/json",
|
|
||||||
Authorization: `Bearer ${token}`,
|
|
||||||
};
|
|
||||||
const pathUrl = `/user-roles`;
|
const pathUrl = `/user-roles`;
|
||||||
return await httpPost(pathUrl, headers, data);
|
return await httpPostInterceptor(pathUrl, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getMasterUserRoleById(id: any) {
|
export async function getMasterUserRoleById(id: any) {
|
||||||
const headers = {
|
const headers = {
|
||||||
"content-type": "application/json",
|
"content-type": "application/json",
|
||||||
};
|
};
|
||||||
return await httpGet(`/user-roles/${id}`, headers);
|
return await httpGetInterceptor(`/user-roles/${id}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function deleteMasterUserRole(id: string) {
|
export async function deleteMasterUserRole(id: string) {
|
||||||
const headers = {
|
const headers = {
|
||||||
"content-type": "application/json",
|
"content-type": "application/json",
|
||||||
};
|
};
|
||||||
return await httpDeleteInterceptor(`/user-roles/${id}`, headers);
|
return await httpDeleteInterceptor(`/user-roles/${id}`);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -46,9 +46,13 @@ export async function postSignIn(data: any) {
|
||||||
return await httpPost(pathUrl, data);
|
return await httpPost(pathUrl, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getProfile(code?: string) {
|
export async function getProfile(token?: string) {
|
||||||
|
const headers = {
|
||||||
|
"content-type": "application/json",
|
||||||
|
"Authorization": `Bearer ${token}`,
|
||||||
|
};
|
||||||
const pathUrl = `/users/info`;
|
const pathUrl = `/users/info`;
|
||||||
return await httpGet(pathUrl);
|
return await httpGet(pathUrl, headers);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function updateProfile(data: any) {
|
export async function updateProfile(data: any) {
|
||||||
|
|
|
||||||
|
|
@ -1,47 +1,28 @@
|
||||||
import { PaginationRequest } from "@/types/globals";
|
import { PaginationRequest } from "@/types/globals";
|
||||||
import {
|
import { httpGetInterceptor, httpPostInterceptor, httpPutInterceptor } from "./http-config/http-interceptor-services";
|
||||||
httpDeleteInterceptor,
|
import { httpGet } from "./http-config/http-base-services";
|
||||||
httpGet,
|
|
||||||
httpPost,
|
|
||||||
httpPut,
|
|
||||||
} from "./http-config/axios-base-service";
|
|
||||||
|
|
||||||
export async function createCustomStaticPage(data: any) {
|
export async function createCustomStaticPage(data: any) {
|
||||||
const headers = {
|
|
||||||
"content-type": "application/json",
|
|
||||||
};
|
|
||||||
const pathUrl = `/custom-static-pages`;
|
const pathUrl = `/custom-static-pages`;
|
||||||
return await httpPost(pathUrl, headers, data);
|
return await httpPostInterceptor(pathUrl, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function editCustomStaticPage(data: any) {
|
export async function editCustomStaticPage(data: any) {
|
||||||
const headers = {
|
|
||||||
"content-type": "application/json",
|
|
||||||
};
|
|
||||||
const pathUrl = `/custom-static-pages/${data.id}`;
|
const pathUrl = `/custom-static-pages/${data.id}`;
|
||||||
return await httpPut(pathUrl, headers, data);
|
return await httpPutInterceptor(pathUrl, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getCustomStaticPage(props: PaginationRequest) {
|
export async function getCustomStaticPage(props: PaginationRequest) {
|
||||||
const { page, limit, search } = props;
|
const { page, limit, search } = props;
|
||||||
const headers = {
|
const pathUrl = `/custom-static-pages?limit=${limit}&page=${page}&title=${search}`;
|
||||||
"content-type": "application/json",
|
return await httpGetInterceptor(pathUrl);
|
||||||
};
|
|
||||||
return await httpGet(
|
|
||||||
`/custom-static-pages?limit=${limit}&page=${page}&title=${search}`,
|
|
||||||
headers
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getCustomStaticDetail(id: string) {
|
export async function getCustomStaticDetail(id: string) {
|
||||||
const headers = {
|
return await httpGetInterceptor(`/custom-static-pages/${id}`);
|
||||||
"content-type": "application/json",
|
|
||||||
};
|
|
||||||
return await httpGet(`/custom-static-pages/${id}`, headers);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getCustomStaticDetailBySlug(slug: string) {
|
export async function getCustomStaticDetailBySlug(slug: string) {
|
||||||
const headers = {
|
const pathUrl = `/custom-static-pages/slug/${slug}`;
|
||||||
"content-type": "application/json",
|
return await httpGet(pathUrl);
|
||||||
};
|
|
||||||
return await httpGet(`/custom-static-pages/slug/${slug}`, headers);
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,30 @@
|
||||||
|
|
||||||
|
import Cookies from "js-cookie";
|
||||||
|
import { httpGetInterceptor, httpPostInterceptor, httpPutInterceptor } from "./http-config/http-interceptor-services";
|
||||||
|
const token = Cookies.get("access_token");
|
||||||
|
|
||||||
|
export async function getAllUserLevels(data?: any) {
|
||||||
|
const pathUrl = `user-levels?limit=${data?.limit || ""}&levelNumber=${
|
||||||
|
data?.levelNumber || ""
|
||||||
|
}&name=${data?.search || ""}&page=${data?.page || "1"}`
|
||||||
|
return await httpGetInterceptor(pathUrl);
|
||||||
|
}
|
||||||
|
export async function getUserLevels(id: string) {
|
||||||
|
return await httpGetInterceptor(`user-levels/${id}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getAccountById(id: string) {
|
||||||
|
return await httpGetInterceptor(`user-account/findById/${id}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function createUserLevels(data: any) {
|
||||||
|
return await httpPostInterceptor(`user-levels`, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function editUserLevels(id: string, data: any) {
|
||||||
|
return await httpPutInterceptor(`user-levels/${id}`, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function changeIsApproval(data: any) {
|
||||||
|
return await httpPutInterceptor(`user-levels/enable-approval`, data);
|
||||||
|
}
|
||||||
|
|
@ -1,52 +0,0 @@
|
||||||
|
|
||||||
import Cookies from "js-cookie";
|
|
||||||
import { httpGet, httpPost, httpPut } from "../http-config/axios-base-service";
|
|
||||||
|
|
||||||
const token = Cookies.get("access_token");
|
|
||||||
|
|
||||||
export async function getAllUserLevels(data?: any) {
|
|
||||||
const headers = {
|
|
||||||
"content-type": "application/json",
|
|
||||||
};
|
|
||||||
return await httpGet(
|
|
||||||
`user-levels?limit=${data?.limit || ""}&levelNumber=${
|
|
||||||
data?.levelNumber || ""
|
|
||||||
}&name=${data?.search || ""}&page=${data?.page || "1"}`,
|
|
||||||
headers
|
|
||||||
);
|
|
||||||
}
|
|
||||||
export async function getUserLevels(id: string) {
|
|
||||||
const headers = {
|
|
||||||
"content-type": "application/json",
|
|
||||||
};
|
|
||||||
return await httpGet(`user-levels/${id}`, headers);
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function getAccountById(id: string) {
|
|
||||||
const headers = {
|
|
||||||
"content-type": "application/json",
|
|
||||||
};
|
|
||||||
return await httpGet(`user-account/findById/${id}`, headers);
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function createUserLevels(request: any) {
|
|
||||||
const headers = {
|
|
||||||
"content-type": "application/json",
|
|
||||||
};
|
|
||||||
return await httpPost(`user-levels`, headers, request);
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function editUserLevels(id: string, request: any) {
|
|
||||||
const headers = {
|
|
||||||
"content-type": "application/json",
|
|
||||||
};
|
|
||||||
return await httpPut(`user-levels/${id}`, headers, request);
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function changeIsApproval(request: any) {
|
|
||||||
const headers = {
|
|
||||||
"content-type": "application/json",
|
|
||||||
Authorization: `Bearer ${token}`,
|
|
||||||
};
|
|
||||||
return await httpPut(`user-levels/enable-approval`, headers, request);
|
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue