re-structure to monorepo.

This commit is contained in:
a.bouhuolia
2023-02-03 01:02:31 +02:00
parent 8242ec64ba
commit 7a0a13f9d5
10400 changed files with 46966 additions and 17223 deletions

View File

@@ -0,0 +1,25 @@
// @ts-nocheck
import axios from '@/services/axios';
export default {
get(resource, params) {
return axios.get(`/api/${resource}`, params);
},
post(resource, params, config) {
return axios.post(`/api/${resource}`, params, config);
},
update(resource, slug, params) {
return axios.put(`/api/${resource}/${slug}`, params);
},
put(resource, params) {
return axios.put(`/api/${resource}`, params);
},
delete(resource, params) {
return axios.delete(`/api/${resource}`, params);
}
};

View File

@@ -0,0 +1,4 @@
// @ts-nocheck
import dashboard from '@/routes/dashboard';

View File

@@ -0,0 +1,30 @@
// @ts-nocheck
import ApiService from '@/services/ApiService';
export default class RemoteDataBinding {
execute(state) {
return this.getData(state);
}
getData(state) {
const pageQuery = `$skip=${state.skip}&$top=${state.take}`;
let sortQuery = '';
if ((state.sorted || []).length) {
sortQuery = `&$orderby=` + (state).sorted.map((obj) => {
return obj.direction === 'descending' ? `${obj.name} desc` : obj.name;
}).reverse().join(',');
}
this.ajax.url = `${this.baseUrl}?${pageQuery}${sortQuery}&$inlinecount=allpages&$format=json`;
return ApiService.get(this.ajax.url).then((response) => {
let data = JSON.parse(response);
return {
result: data['d']['results'],
count: parseInt(data['d']['__count'], 10),
};
});
}
}

View File

@@ -0,0 +1,41 @@
// @ts-nocheck
import axios from 'axios';
import { store } from '@/store/createStore';
const http = axios.create();
http.interceptors.request.use((request) => {
const state = store.getState();
const { token, organization } = state.authentication;
const locale = 'en';
if (token) {
request.headers.common['x-access-token'] = token;
}
if (organization) {
request.headers.common['organization-id'] = organization;
}
if (locale) {
request.headers.common['Accept-Language'] = locale;
}
request.headers.common['Accept-Language'] = 'ar';
return request;
}, (error) => {
return Promise.reject(error);
});
http.interceptors.response.use((response) => response, (error) => {
const { status } = error.response;
// if (status >= 500) {
// store.dispatch(setGlobalErrors({ something_wrong: true }));
// }
// if (status === 401) {
// // store.dispatch(setGlobalErrors({ session_expired: true }));
// // store.dispatch(logout());
// }
return Promise.reject(error);
});
export default http;

View File

@@ -0,0 +1,23 @@
// @ts-nocheck
import * as Yup from 'yup';
Yup.addMethod(Yup.string, 'digits', function () {
return this.test(
'is-digits',
'${path} should be digits only.',
value => /^(0|[1-9]\d*)$/.test(value),
);
});
Yup.addMethod(Yup.number, 'decimalScale', function(scale) {
return this.test(
'numeric-length',
'${path} should decimal length ',
(value) => {
const reg = new RegExp(/^(?:\d{1,13}|(?!.{15})\d+\.\d+)$/);
return reg.test(value);
},
);
})
export default Yup;