added loading state to undentified error from oform request
This commit is contained in:
parent
14bdc19485
commit
303b069335
@ -91,6 +91,8 @@ class OformsStore {
|
|||||||
getOforms = (filter = OformsFilter.getDefault()) => {
|
getOforms = (filter = OformsFilter.getDefault()) => {
|
||||||
const { domain, path } = this.authStore.settingsStore.formGallery;
|
const { domain, path } = this.authStore.settingsStore.formGallery;
|
||||||
|
|
||||||
|
console.log("getoforms");
|
||||||
|
|
||||||
const formName = "&fields[0]=name_form";
|
const formName = "&fields[0]=name_form";
|
||||||
const updatedAt = "&fields[1]=updatedAt";
|
const updatedAt = "&fields[1]=updatedAt";
|
||||||
const size = "&fields[2]=file_size";
|
const size = "&fields[2]=file_size";
|
||||||
@ -103,16 +105,26 @@ class OformsStore {
|
|||||||
const fields = `${formName}${updatedAt}${size}${filePages}${defaultDescription}${templateDescription}${cardPrewiew}${templateImage}`;
|
const fields = `${formName}${updatedAt}${size}${filePages}${defaultDescription}${templateDescription}${cardPrewiew}${templateImage}`;
|
||||||
const params = `?${fields}&${filter.toApiUrlParams()}`;
|
const params = `?${fields}&${filter.toApiUrlParams()}`;
|
||||||
|
|
||||||
return new Promise(async (resolve) => {
|
const apiUrl = combineUrl(domain, path, params);
|
||||||
const apiUrl = combineUrl(domain, path, params);
|
|
||||||
let oforms = await getOforms(apiUrl).catch((err) => {
|
const resPromise = new Promise(async (resolve, reject) => {
|
||||||
const errStatus = err.response.status;
|
try {
|
||||||
const oformLoadFail = errStatus === 404 || errStatus === 500;
|
const oforms = await getOforms(apiUrl);
|
||||||
if (oformLoadFail) this.oformsLoadError = true;
|
this.oformsLoadError = false;
|
||||||
else this.oformsLoadError = false;
|
resolve(oforms);
|
||||||
});
|
} catch (err) {
|
||||||
resolve(oforms);
|
if (err.response) {
|
||||||
|
const status = err.response.status;
|
||||||
|
const isApiError = status === 404 || status === 500;
|
||||||
|
if (isApiError) this.oformsLoadError = true;
|
||||||
|
} else {
|
||||||
|
this.setOformFiles(null);
|
||||||
|
}
|
||||||
|
reject(err);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
return resPromise;
|
||||||
};
|
};
|
||||||
|
|
||||||
fetchOforms = async (filter = OformsFilter.getDefault()) => {
|
fetchOforms = async (filter = OformsFilter.getDefault()) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user