424 lines
11 KiB
JavaScript
424 lines
11 KiB
JavaScript
import axios from "axios"
|
|
|
|
axios.interceptors.request.use(
|
|
config => {
|
|
config.headers = {
|
|
// Accept: "application/json",
|
|
"Access-Control-Allow-Origin": "*",
|
|
// "Access-Control-Expose-Headers": "Access-Control-Allow-Origin",
|
|
// "Access-Control-Allow-Headers": "Origin, X-API-KEY, X-Requested-With, Content-Type, Accept, Access-Control-Request-Method, Access-Control-Allow-Headers, Authorization, observe, enctype, Content-Length, X-Csrf-Token",
|
|
// "Content-Type": "application/json;charset=UTF-8",
|
|
'Authorization': (localStorage && localStorage.getItem('access_token')) ? `Bearer ${localStorage.getItem('access_token')}` : '',
|
|
// 'uuid': 'dummy'
|
|
};
|
|
// config.headers['Authorization'] = `Bearer ${localStorage.getItem('token')}`;
|
|
// config.baseURL = process.env.REACT_APP_MAIN_API
|
|
return config;
|
|
},
|
|
error => {
|
|
return Promise.reject(error);
|
|
}
|
|
);
|
|
|
|
const postAuxEnd = (path, postData, media=false) => {
|
|
const basePath = media ? process.env.REACT_APP_MAIN_API : process.env.REACT_APP_MAIN_API
|
|
let newPostData = {}
|
|
if(!media){
|
|
newPostData = {...postData}
|
|
}else{
|
|
newPostData = new FormData();
|
|
for (let data in postData) {
|
|
newPostData.append(data, postData[data]);
|
|
}
|
|
}
|
|
return axios.post(`${basePath}${path}`, newPostData).then(res => {
|
|
return res
|
|
}).catch(err => {
|
|
throw new Error(err.response.data.error_message);
|
|
// throw new Error(err);
|
|
})
|
|
}
|
|
|
|
const getAuxEnd = (path, reqData= null) => {
|
|
const basePath = process.env.REACT_APP_MAIN_API
|
|
return axios.get(`${basePath}${path}`,{ params: reqData }).then(res => {
|
|
return res
|
|
// localStorage.clear();
|
|
// window.location.href = `/login?sessionExpired=true`;
|
|
}).catch(err => {
|
|
throw new Error(err);
|
|
// throw new Error(err.response.data.message);
|
|
// return err
|
|
})
|
|
}
|
|
|
|
// FUNCTION TO AUTHORIZE USER IN
|
|
export const userToken = (reqData) => {
|
|
let postData = {
|
|
...reqData
|
|
}
|
|
return postAuxEnd('/Authorize', postData, false)
|
|
}
|
|
|
|
// FUNCTION TO LOGIN USER IN
|
|
export const loginUser = (reqData) => {
|
|
let postData = {
|
|
...reqData
|
|
}
|
|
return postAuxEnd('/panel/Login', postData, false)
|
|
}
|
|
|
|
// FUNCTION TO GET USER INFO DATA
|
|
export const userInfo = (reqData) => {
|
|
let postData = {
|
|
...reqData
|
|
}
|
|
return postAuxEnd('/panel/account', postData, false)
|
|
}
|
|
|
|
// FUNCTION TO GET DASHBOARD TOP BAR SECTION
|
|
export const topBar = (reqData) => {
|
|
let postData = {
|
|
...reqData,
|
|
}
|
|
return postAuxEnd(`/panel/account/bar`, postData, false)
|
|
}
|
|
|
|
// FUNCTION TO GET PROFILE DATA
|
|
export const profileDetails = (reqData) => {
|
|
let postData = {
|
|
...reqData,
|
|
}
|
|
return postAuxEnd(`/panel/account/profile`, postData, false)
|
|
}
|
|
|
|
// FUNCTION TO UPDATE PROFILE
|
|
export const updateProfile = (reqData) => {
|
|
let postData = {
|
|
...reqData,
|
|
}
|
|
return postAuxEnd(`/panel/account/profile-update`, postData, false)
|
|
}
|
|
|
|
// FUNCTION TO UPDATE LINKS
|
|
export const updateLinks = (reqData) => {
|
|
let postData = {
|
|
...reqData,
|
|
}
|
|
return postAuxEnd(`/panel/account/profilelinks-update`, postData, false)
|
|
}
|
|
|
|
// FUNCTION TO GET PRODUCT BY ID
|
|
export const MyProductData = (reqData) => {
|
|
let postData = {
|
|
...reqData,
|
|
}
|
|
return postAuxEnd(`/panel/myproduct/dash`, postData, false)
|
|
}
|
|
|
|
export const StripeSubscriptionCreate = (reqData) => {
|
|
let postData = {
|
|
...reqData,
|
|
}
|
|
return postAuxEnd(`/panel/subscription/start`, postData, false)
|
|
}
|
|
|
|
// FUNCTION TO GET CALENDAR EVENTS
|
|
export const getCalendarEvents = (reqData) => {
|
|
let postData = {
|
|
...reqData,
|
|
}
|
|
return postAuxEnd(`/panel/account/calendar`, postData, false)
|
|
}
|
|
|
|
// FUNCTION TO GET CONTACT DATA
|
|
export const contactData = (reqData) => {
|
|
let postData = {
|
|
...reqData,
|
|
}
|
|
return postAuxEnd(`/panel/contacts`, postData, false)
|
|
}
|
|
|
|
// FUNCTION TO GET COMMENTS DATA
|
|
export const commentsData = (reqData) => {
|
|
let postData = {
|
|
...reqData,
|
|
}
|
|
return postAuxEnd(`/panel/comments`, postData, false)
|
|
}
|
|
|
|
// FUNCTION TO GET DASHBOARD PRODUCT URL DATA SECTION
|
|
export const productsURL = (reqData) => {
|
|
let postData = {
|
|
...reqData,
|
|
}
|
|
return postAuxEnd(`/panel/account/products/url`, postData, false)
|
|
}
|
|
|
|
// FUNCTION TO GET DASHBOARD PAYMENTS
|
|
export const getDashPayments = (reqData) => {
|
|
let postData = {
|
|
...reqData,
|
|
}
|
|
return postAuxEnd(`/panel/account/payments`, postData, false)
|
|
}
|
|
|
|
// FUNCTION TO GET DASHBOARD PRODUCT DATA SECTION
|
|
export const productsData = (reqData) => {
|
|
let postData = {
|
|
...reqData,
|
|
}
|
|
return postAuxEnd(`/panel/account/products`, postData, false)
|
|
}
|
|
|
|
// FUNCTION TO REFRESH SITE
|
|
export const productRefreshSite = (reqData) => {
|
|
let postData = {
|
|
...reqData,
|
|
}
|
|
return postAuxEnd(`/panel/account/products/refresh`, postData, false)
|
|
}
|
|
|
|
// FUNCTION TO GET DASHBOARD RECENT ACTIONS SECTION
|
|
export const recentActions = (reqData) => {
|
|
let postData = {
|
|
...reqData,
|
|
token: localStorage.getItem('token'), // USER TOKEN
|
|
uid: localStorage.getItem('uid') // USER UID
|
|
}
|
|
//return getAuxEnd(`/panel/account/actions`)
|
|
return postAuxEnd(`/panel/account/actions`, postData, false)
|
|
}
|
|
|
|
// FUNCTION TO VERIFY RESET TOKEN
|
|
export const verifyResetToken = (reqData) => {
|
|
let postData = {
|
|
...reqData
|
|
}
|
|
return postAuxEnd('/panel/auth/resetverify', postData, false)
|
|
}
|
|
|
|
// FUNCTION TO COMPLETE PASSWORD RESET
|
|
export const completePWDReset = (reqData) => {
|
|
let postData = {
|
|
...reqData
|
|
}
|
|
return postAuxEnd('/panel/auth/resetcomplete', postData, false)
|
|
}
|
|
|
|
// FUNCTION TO SUBMIT PAGE TAB SETTINGS
|
|
export const pageSettings = (reqData) => {
|
|
let postData = {
|
|
...reqData,
|
|
}
|
|
return postAuxEnd(`/panel/myproduct/settings`, postData, false)
|
|
}
|
|
|
|
// FUNCTION TO GET SETTINGS DATA
|
|
export const getSettingsData = (reqData) => {
|
|
let postData = {
|
|
...reqData,
|
|
}
|
|
return postAuxEnd(`/panel/myproduct/settings/values`, postData, false)
|
|
}
|
|
|
|
// FUNCTION TO GET MY PRODUCT CONFIGURATION
|
|
export const getMyProductConfig = (reqData) => {
|
|
let postData = {
|
|
...reqData,
|
|
}
|
|
return postAuxEnd(`/panel/myproduct/configuration`, postData, false)
|
|
}
|
|
|
|
// FUNCTION TO GET SETTINGS DATA
|
|
export const getProductTemplateData = (reqData) => {
|
|
let postData = {
|
|
...reqData,
|
|
}
|
|
return postAuxEnd(`/panel/account/products/templates`, postData, false)
|
|
}
|
|
|
|
export const getProductColorStyles = (reqData) => {
|
|
let postData = {
|
|
...reqData,
|
|
}
|
|
return postAuxEnd(`/panel/account/products/color-styles`, postData, false)
|
|
}
|
|
|
|
export const getTemplateConfig = (reqData) => {
|
|
let postData = {
|
|
...reqData,
|
|
}
|
|
return postAuxEnd(`/panel/myproduct/template-config`, postData, false)
|
|
}
|
|
|
|
// FUNCTION TO ACTIVATE TEMPLATE
|
|
export const activateTemplate = (reqData) => {
|
|
let postData = {
|
|
...reqData,
|
|
}
|
|
return postAuxEnd(`/panel/account/template/activate`, postData, false)
|
|
}
|
|
|
|
export const activateColorStyle = (reqData) => {
|
|
let postData = {
|
|
...reqData,
|
|
}
|
|
return postAuxEnd(`/panel/account/colorstyle/activate`, postData, false)
|
|
}
|
|
|
|
|
|
// FUNCTION TO GET PRODUCT SUBSCRIPTIONS
|
|
export const completeProfile = (reqData) => {
|
|
let postData = {
|
|
...reqData,
|
|
}
|
|
return postAuxEnd(`/panel/account/startprofile`, postData, false)
|
|
}
|
|
|
|
// FUNCTION TO COMPLETE PROFILE
|
|
export const getSubscriptions = (reqData) => {
|
|
let postData = {
|
|
...reqData,
|
|
}
|
|
return postAuxEnd(`/panel/subscription/products`, postData, false)
|
|
}
|
|
|
|
export const getMediaFileList = (reqData) => {
|
|
let postData = {
|
|
...reqData,
|
|
}
|
|
return postAuxEnd(`/panel/account/media-files`, postData, false)
|
|
}
|
|
|
|
export const uploadFile = (reqData) => {
|
|
let postData = {
|
|
...reqData,
|
|
}
|
|
return postAuxEnd(`/upload/webfiles`, postData, true)
|
|
}
|
|
|
|
// FUNCTION TO CHANGE TEMPLATE MEDIA SET
|
|
export const templateMediaSet = (reqData) => {
|
|
let postData = {
|
|
...reqData,
|
|
}
|
|
return postAuxEnd(`/panel/myproduct/template-media-set`, postData, false)
|
|
}
|
|
|
|
export const getReportsTopicsList = (reqData) => {
|
|
let postData = {
|
|
...reqData,
|
|
}
|
|
return postAuxEnd(`/panel/report/topics`, postData, false)
|
|
}
|
|
|
|
// FUNCTION TO GET PAYMENT REPORTS
|
|
export const getPaymentReports = (reqData) => {
|
|
let postData = {
|
|
...reqData,
|
|
}
|
|
return postAuxEnd(`/panel/report/item/payment`, postData, false)
|
|
}
|
|
|
|
// FUNCTION TO GET PRODUCT REPORTS
|
|
export const getProductReports = (reqData) => {
|
|
let postData = {
|
|
...reqData,
|
|
}
|
|
return postAuxEnd(`/panel/report/item/product`, postData, false)
|
|
}
|
|
|
|
// FUNCTION TO GET SYSTEM REPORTS
|
|
export const getSystemReports = (reqData) => {
|
|
let postData = {
|
|
...reqData,
|
|
}
|
|
return postAuxEnd(`/panel/report/item/system`, postData, false)
|
|
}
|
|
|
|
// FUNCTION TO GET COMMON PRACTICE
|
|
export const getCommonPractice = (reqData) => {
|
|
let postData = {
|
|
...reqData,
|
|
}
|
|
return postAuxEnd(`/panel/common/practice`, postData, false)
|
|
}
|
|
|
|
// FUNCTION TO SET EXTERNAL URL
|
|
export const setExternalURL = (reqData) => {
|
|
let postData = {
|
|
...reqData
|
|
}
|
|
return postAuxEnd('/panel/myproduct/external-url', postData, false)
|
|
}
|
|
|
|
// FUNCTION TO UPLOAD PROFILE IMAGE
|
|
export const uploadProfileImg = (reqData) => {
|
|
let postData = {
|
|
...reqData,
|
|
}
|
|
return postAuxEnd(`/upload/profile-picture`, postData, true)
|
|
// throw new Error('Opps')
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// FUNCTION TO REGISTER USER
|
|
export const signUpUser = (reqData) => {
|
|
let postData = {
|
|
...reqData
|
|
}
|
|
return postAuxEnd('/panel/Register', postData, false)
|
|
}
|
|
|
|
// FUNCTION TO VERIFY EMAIL
|
|
export const verifyEmail = (reqData) => {
|
|
let postData = {
|
|
...reqData
|
|
}
|
|
return postAuxEnd('/panel/Register/verify', postData, false)
|
|
}
|
|
|
|
// FUNCTION TO COMPLETE REGISTRATION
|
|
export const completeRegistration = (reqData) => {
|
|
let postData = {
|
|
...reqData
|
|
}
|
|
return postAuxEnd('/panel/Register/complete', postData, false)
|
|
}
|
|
|
|
// FUNCTION TO SUBSCRIBE
|
|
export const subscribe = (reqData) => {
|
|
let postData = {
|
|
...reqData,
|
|
token: localStorage.getItem('token'), // USER TOKEN
|
|
uid: localStorage.getItem('uid') // USER UID
|
|
}
|
|
return postAuxEnd(`/panel/myproduct/subscription`, postData, false)
|
|
}
|
|
|
|
|
|
// FUNCTION TO RESET USER PASSWORD
|
|
export const recoverPWD = (reqData) => {
|
|
let postData = {
|
|
...reqData
|
|
}
|
|
return postAuxEnd('/panel/auth/reset', postData, false)
|
|
}
|
|
|
|
// FUNCTION TO GET MY PRODUCT PROVISION DATA
|
|
export const productProvision = (reqData) => {
|
|
let postData = {
|
|
...reqData,
|
|
token: localStorage.getItem('token'), // USER TOKEN
|
|
uid: localStorage.getItem('uid') // USER UID
|
|
}
|
|
return postAuxEnd(`/panel/myproduct/provision`, postData, false)
|
|
// return getAuxEnd(`/panel/myproduct/provision`, postData)
|
|
}
|
|
|