177 lines
4.7 KiB
TypeScript
177 lines
4.7 KiB
TypeScript
import qs from "qs";
|
|
import { getAPIDummy } from "./http-config/axiosCustom";
|
|
import { httpGet, httpPost } from "./http-config/http-base-service";
|
|
import {
|
|
httpGetInterceptor,
|
|
httpGetInterceptorWithToken,
|
|
httpPostInterceptor,
|
|
postAPIWithJson,
|
|
} from "./http-config/http-interceptor-service";
|
|
|
|
export async function login(data: any) {
|
|
const pathUrl = "signin";
|
|
return httpPost(pathUrl, data);
|
|
}
|
|
|
|
export async function doLogin(data: any) {
|
|
const pathUrl = "signin";
|
|
return httpPost(pathUrl, data);
|
|
}
|
|
|
|
// export async function login(data: any, csrfToken: string) {
|
|
// const url = 'http://localhost:8080/mediahub/users/signin';
|
|
// try {
|
|
// const response = await fetch(url, {
|
|
// method: 'POST',
|
|
// credentials: 'include',
|
|
// headers: {
|
|
// 'Content-Type': 'application/json',
|
|
// 'X-XSRF-TOKEN': csrfToken || ''
|
|
// }
|
|
// });
|
|
|
|
// if (!response.ok) {
|
|
// throw new Error(`HTTP error! status: ${response.status}`);
|
|
// }
|
|
// return response; // Menampilkan data yang diterima dari API
|
|
// } catch (error) {
|
|
// console.error('Fetch error: ', error);
|
|
// }
|
|
// }
|
|
|
|
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 getProfile(token: any) {
|
|
const url = "users/info";
|
|
return httpGetInterceptorWithToken(url, token);
|
|
}
|
|
|
|
export async function postEmailValidation(data: any) {
|
|
const url = "public/users/email-validation";
|
|
return httpPostInterceptor(url, data);
|
|
}
|
|
|
|
export async function postSetupEmail(data: any) {
|
|
const url = "public/users/setup-email";
|
|
return httpPostInterceptor(url, data);
|
|
}
|
|
|
|
export async function verifyOTPByUsername(username: any, otp: any) {
|
|
const url = `public/users/verify-otp?username=${username}&otp=${otp}`;
|
|
return httpPost(url);
|
|
}
|
|
|
|
export async function getSubjects() {
|
|
const url = "inbox/subjects";
|
|
return httpGetInterceptor(url);
|
|
}
|
|
|
|
export async function getInfoProfile() {
|
|
const url = "users/info";
|
|
return httpGetInterceptor(url);
|
|
}
|
|
|
|
export async function setupPassword(data: any) {
|
|
const url = "setup-password";
|
|
return httpPostInterceptor(url, data);
|
|
}
|
|
|
|
export async function saveUser(data: any) {
|
|
const url = "users/save";
|
|
const headers = {
|
|
"content-type": "application/json",
|
|
};
|
|
return httpPost(url, headers);
|
|
}
|
|
|
|
export async function saveInstitutes(data: any) {
|
|
const url = "public/users/save-institutes";
|
|
const headers = {
|
|
"content-type": "application/json",
|
|
};
|
|
return httpPost(url, headers);
|
|
}
|
|
|
|
export async function postRegistration(data: any) {
|
|
const url = "public/users/save";
|
|
return httpPost(url, data);
|
|
}
|
|
|
|
export async function requestOTP(data: any) {
|
|
const url = "public/users/otp-request";
|
|
return httpPostInterceptor(url, data);
|
|
}
|
|
|
|
export async function verifyOTP(email: any, otp: any) {
|
|
const url = `public/users/verify-otp?email=${email}&otp=${otp}`;
|
|
return httpPostInterceptor(url);
|
|
}
|
|
|
|
export async function verifyRegistrationOTP(data: any) {
|
|
const url = "public/users/verify-otp";
|
|
return httpPostInterceptor(url, data);
|
|
}
|
|
|
|
export async function getDataByNIK(reqid: any, nik: any) {
|
|
const url = `http://spitpolri.com/api/back_end/get_ktp?reqid=${reqid}&nik=${nik}`;
|
|
return getAPIDummy(url);
|
|
}
|
|
|
|
export async function listInstitusi(roleId: any) {
|
|
const url = `public/users/institutes?categoryRoleId=${roleId}`;
|
|
return httpGetInterceptor(url);
|
|
}
|
|
|
|
export async function listProvince() {
|
|
const url = "public/users/provinces";
|
|
return httpGetInterceptor(url);
|
|
}
|
|
|
|
export async function listCity(id: any) {
|
|
const url = `public/users/cities?provId=${id}`;
|
|
return httpGetInterceptor(url);
|
|
}
|
|
|
|
export async function listDistricts(id: any) {
|
|
const url = `public/users/districts?cityId=${id}`;
|
|
return httpGetInterceptor(url);
|
|
}
|
|
|
|
export async function getDataByNRP(reqid: any, nrp: any) {
|
|
const url = `http://spitpolri.com/api/back_end/get_nrp?reqid=${reqid}&nrp=${nrp}`;
|
|
return getAPIDummy(url);
|
|
}
|
|
|
|
export async function getDataJournalist(cert: any) {
|
|
const url = `public/users/search-journalist?cert=${cert}`;
|
|
return httpGetInterceptor(url);
|
|
}
|
|
|
|
export async function getDataPersonil(nrp: any) {
|
|
const url = `public/users/search-personil?nrp=${nrp}`;
|
|
return httpGetInterceptor(url);
|
|
}
|