mediahub-fe/service/landing/landing.ts

341 lines
9.4 KiB
TypeScript

import { httpGet, httpPost } from "../http-config/http-base-service";
import {
httpDeleteInterceptor,
httpGetInterceptor,
httpGetInterceptorForMetadata,
httpPostInterceptor,
} from "../http-config/http-interceptor-service";
export async function getCsrfToken() {
const pathUrl = "csrf";
const headers = {
"content-type": "application/json",
};
return httpGet(pathUrl, headers);
// const url = 'https://new.netidhub.com/api/csrf';
// try {
// const response = await fetch(url, {
// method: 'GET',
// credentials: 'include'
// });
// if (!response.ok) {
// throw new Error(`HTTP error! status: ${response.status}`);
// }
// const data = await response.json();
// console.log("csrf : ", data);
// return data;
// } catch (error) {
// console.error('Fetch error: ', error);
// }
}
export async function getHeroData(isInt: Boolean = false, unitType = "") {
return await httpGetInterceptor(
`media/public/list?enablePage=1&sort=desc&sortBy=createdAt&size=5&page=0&typeId=1&title=&categoryId=&fileFormats=&tags=&group=&startDate=&endDate=&month=&year=&isInt=${isInt}${
unitType == ""
? ""
: unitType == "polda"
? "&isAllPolda=true"
: "&isAllSatker=true"
}`
);
}
export async function listStaticBanner(
group: any = "",
isInt: Boolean = false
) {
const url = `media/public/banner?group=${group}&isInt=${isInt}`;
return httpGetInterceptor(url);
}
export async function listPopUp(group: any = "", isInt: Boolean = false) {
const url = `media/public/interstitial?group=${group}&isInt=${isInt}`;
return httpGetInterceptor(url);
}
export async function getPublicCategoryData(
group: any = "",
type: string = "",
isInt: boolean = false,
page: number = 1
) {
return await httpGetInterceptor(
`media/categories/list?enablePage=1&size=12&sort=desc&sortBy=id&page=${
page - 1
}&group=${group}&type=${type}&isInt=${isInt}`
);
}
export async function getPublicCategoryDataNew(
group: any = "",
type: string = "",
isInt: boolean = false,
page: number = 1
) {
return await httpGetInterceptor(
`media/categories/list/publish?enablePage=1&size=12&sort=desc&sortBy=id&page=${
page - 1
}&group=${group}&type=${type}&isInt=${isInt}`
);
}
export async function getCategoryData() {
return await httpGetInterceptor(
`media/categories/list/publish?enablePage=1&sort=desc&sortBy=updatedAt&size=12&type=`
);
}
export async function getListContent(props: any) {
return await httpGetInterceptor(
`media/public/list?enablePage=1&sort=desc&sortBy=${props.sortBy}&size=${props.size}&isInt=${props.isInt}&typeId=${props.contentTypeId}&title=${props.title}&group=${props.group}&categoryId=&fileFormats=&tags=&startDate=&endDate=&month=&year=`
);
}
export async function getPrivacy() {
return await httpGetInterceptor(`general/privacy-policy/1`);
}
export async function getIndeksData() {
return await httpGetInterceptor(
`blog/public/pagination?enablePage=1&page=0&size=20`
);
}
export async function getIndeksDataFilter(
type: string,
search: string,
category: string,
size = 10,
page = 0,
sortBy = "createdAt",
format = "",
tag = "",
group = "",
startDate = "",
endDate = "",
month = "",
year = "",
isInt = false
) {
return await httpGetInterceptor(
`blog/public/pagination?enablePage=1&sort=desc&sortBy=${sortBy}&size=${size}&page=${page}&typeId=${type}&title=${search}&categoryId=${category}&fileFormats=${format}&tags=${tag}&group=${group}&startDate=${startDate}&endDate=${endDate}&month=${month}&year=${year}&isInt=${isInt}`
);
}
export async function getDetail(slug: string) {
return await httpGetInterceptor(`media/public?slug=${slug}&state=mabes`);
}
export async function getDetailMetaData(slug: string) {
return await httpGetInterceptorForMetadata(
`media/public?slug=${slug}&state=mabes&isSummary=true`
);
}
export async function getDetailIndeks() {
return await httpGetInterceptor(
`blog/public/pagination?enablePage=1&page=0&size=6`
);
}
export async function getFeedback() {
return await httpGetInterceptor(`master/feedback/list`);
}
export async function postUserFeedback() {
return await httpGetInterceptor(`feedback/user`);
}
export async function listCategory(type = "") {
return await httpGetInterceptor(
`media/categories/list/enable?enablePage=1&sort=desc&sortBy=updatedAt&size=12&type=${type}`
);
}
export async function publicDetailBlog(slug: any) {
return await httpGetInterceptor(`blog/public/read/${slug}`);
}
export async function listData(
type: string,
search: string,
category: string,
size = 10,
page = 0,
sortBy = "createdAt",
format = "",
tag = "",
group = "",
startDate = "",
endDate = "",
month = "",
year = "",
isInt = false
) {
return await httpGetInterceptor(
`media/public/list?enablePage=1&sort=desc&sortBy=${sortBy}&size=${size}&page=${page}&typeId=${type}&title=${search}&categoryId=${category}&fileFormats=${format}&tags=${tag}&group=${group}&startDate=${startDate}&endDate=${endDate}&month=${month}&year=${year}&isInt=${isInt}`
);
}
export async function listDataRegional(
type: string,
search: string,
category: string,
format = "",
tag = "",
startDate = "",
endDate = "",
month = "",
year = "",
size = 10,
page = 0,
sortBy = "createdAt"
) {
return await httpGetInterceptor(
`media/public/regional-list?enablePage=1&size=${size}&page=${page}&sort=desc&sortBy=${sortBy}&typeId=${type}&title=${search}&categoryId=${category}&fileFormats=${format}&tags=${tag}&startDate=${startDate}&endDate=${endDate}&month=${month}&year=${year}`
);
}
export async function getUserLevelListByParent(id: any) {
return await httpGetInterceptor(`users/user-levels/list?userLevelId=${id}`);
}
export async function getInfoProfile() {
return await httpGetInterceptor(`users/info`);
}
export async function getListPorvinces() {
return await httpGetInterceptor(`public/users/provinces`);
}
export async function getUsersTeams(id: any) {
return await httpGetInterceptor(`users?instituteId=${id}`);
}
export async function mediaWishlist(
type: any,
instituteId: any,
search: any,
category: any,
size: string,
page: number,
sortBy: undefined,
format: string
) {
return await httpGetInterceptor(
`/media/wishlist/list?enablePage=1&size=${size}&page=${page}&typeId=${type}&instituteId=${instituteId}`
);
}
export async function checkWishlistStatus(mediaId: any) {
return await httpGetInterceptor(`/media/wishlist/status?mediaId=${mediaId}`);
}
export async function listRole() {
const url = "public/users/roles";
return httpGetInterceptor(url);
}
export async function deleteWishlist(id: any) {
return await httpDeleteInterceptor(`media/wishlist?id=${id}`);
}
export async function getContentRewritePagination(page = 0, size = 10) {
return await httpGetInterceptor(
`media/rewrite/pagination?size=${size}&page=${page}`
);
}
export async function getContentRewrite(id: any) {
return await httpGetInterceptor(`media/rewrite?id=${id}`);
}
export async function listDataAll(
type: any,
search: any,
category: any,
format = "",
tag = "",
group = "",
startDate = "",
endDate = "",
month = "",
year = ""
) {
return await httpGetInterceptor(
`media/public/list?enablePage=1&size=20&sort=desc&typeId=${type}&title=${search}&categoryId=${category}&fileFormats=${format}&tags=${tag}&group=${group}&startDate=${startDate}&endDate=${endDate}&month=${month}&year=${year}`
);
}
export async function saveWishlist(data: { mediaUploadId: string }) {
const url = "/media/wishlist";
return httpPostInterceptor(url, data);
}
export async function getPublicSuggestionList(slug: any) {
const url = `media/public/suggestion?mediaId=${slug}`;
// const headers = {
// "content-Type": "application/json",
// };
return httpGetInterceptor(url);
}
export async function getUserNotifications(page = 0, typeId: any) {
const url = `notification/public/list?enablePage=1&page=${page}&typeId=${typeId}`;
return httpGetInterceptor(url);
}
export async function forgotPassword(username: any) {
const url = `forgot-password?username=${username}`;
return httpPost(url);
}
export async function saveUserReports(data: any) {
const url = "public/users/reports";
return httpPostInterceptor(url, data);
}
export async function listCarousel() {
const url = "/media/public/banner";
return httpGetInterceptor(url);
}
export async function createPublicSuggestion(data: any) {
const url = "media/public/suggestion";
return httpPostInterceptor(url, data);
}
export async function deletePublicSuggestion(slug: any) {
const url = `media/public/suggestion?id=${slug}`;
return httpDeleteInterceptor(url);
}
export async function postBlogComments(data: any) {
const url = "blog/comments";
return httpPostInterceptor(url, data);
}
export async function getBlogComments(slug: any) {
const url = `blog/comments?blogId=${slug}`;
const headers = {
"content-Type": "application/json",
};
return httpGet(url, headers);
}
export async function deleteBlogComments(slug: any) {
const url = `blog/comments?id=${slug}`;
return httpDeleteInterceptor(url);
}
export async function sendMessage(data: any) {
const url = "inbox";
return httpPostInterceptor(url, data);
}
export async function enableListCategory() {
const url = `media/categories/list/publish?enablePage=1`;
return httpPostInterceptor(url);
}