[WIP] Фикс просроченного токена
This commit is contained in:
@@ -431,7 +431,7 @@ export default {
|
|||||||
background-color: var(--default-white)
|
background-color: var(--default-white)
|
||||||
border-radius: 4px
|
border-radius: 4px
|
||||||
width: 634px
|
width: 634px
|
||||||
min-height: 700px
|
min-height: 585px
|
||||||
box-shadow: var(--default-shadow)
|
box-shadow: var(--default-shadow)
|
||||||
|
|
||||||
.title
|
.title
|
||||||
|
|||||||
@@ -104,16 +104,10 @@ export default {
|
|||||||
saveEmployeesData(res) {
|
saveEmployeesData(res) {
|
||||||
this.employeesData = res.results;
|
this.employeesData = res.results;
|
||||||
},
|
},
|
||||||
logout() {
|
|
||||||
localStorage.removeItem("tokenAccess");
|
|
||||||
this.$router.push("/login");
|
|
||||||
},
|
|
||||||
fetchEmployeesData() {
|
fetchEmployeesData() {
|
||||||
fetchWrapper.get("general/employee/").then((res) => {
|
fetchWrapper
|
||||||
if (res.type === "client_error") {
|
.get("general/employee/")
|
||||||
this.logout();
|
.then((res) => this.saveEmployeesData(res));
|
||||||
} else this.saveEmployeesData(res);
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
fetchEventsData() {
|
fetchEventsData() {
|
||||||
fetchWrapper
|
fetchWrapper
|
||||||
|
|||||||
@@ -118,10 +118,6 @@ export default {
|
|||||||
this.fetchDataClients();
|
this.fetchDataClients();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
logout() {
|
|
||||||
localStorage.removeItem("tokenAccess");
|
|
||||||
this.$router.push("/login");
|
|
||||||
},
|
|
||||||
async fetchDataClients() {
|
async fetchDataClients() {
|
||||||
let response = {};
|
let response = {};
|
||||||
if (this.textSearch) {
|
if (this.textSearch) {
|
||||||
@@ -130,25 +126,18 @@ export default {
|
|||||||
this.limit
|
this.limit
|
||||||
}&offset=${(this.currentTablePage - 1) * this.limit}`
|
}&offset=${(this.currentTablePage - 1) * this.limit}`
|
||||||
);
|
);
|
||||||
if (response.type === "client_error") {
|
|
||||||
this.logout();
|
|
||||||
} else {
|
|
||||||
this.saveDataClients(response);
|
this.saveDataClients(response);
|
||||||
this.saveFilteredClientsCount(response);
|
this.saveFilteredClientsCount(response);
|
||||||
this.paginationInfo = {
|
this.paginationInfo = {
|
||||||
currentPage: this.currentTablePage,
|
currentPage: this.currentTablePage,
|
||||||
length: this.calculatePageCount(this.filteredClientsCount),
|
length: this.calculatePageCount(this.filteredClientsCount),
|
||||||
};
|
};
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
response = await fetchWrapper.get(
|
response = await fetchWrapper.get(
|
||||||
`general/person/?limit=${this.limit}&offset=${
|
`general/person/?limit=${this.limit}&offset=${
|
||||||
(this.currentTablePage - 1) * this.limit
|
(this.currentTablePage - 1) * this.limit
|
||||||
}`
|
}`
|
||||||
);
|
);
|
||||||
if (response.type === "client_error") {
|
|
||||||
this.logout();
|
|
||||||
} else {
|
|
||||||
this.saveDataClients(response);
|
this.saveDataClients(response);
|
||||||
this.saveClientsCount(response);
|
this.saveClientsCount(response);
|
||||||
this.paginationInfo = {
|
this.paginationInfo = {
|
||||||
@@ -156,7 +145,6 @@ export default {
|
|||||||
length: this.calculatePageCount(this.clientsCount),
|
length: this.calculatePageCount(this.clientsCount),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
|
||||||
},
|
},
|
||||||
calculatePageCount(count) {
|
calculatePageCount(count) {
|
||||||
return Math.ceil(count / this.limit);
|
return Math.ceil(count / this.limit);
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ export default {
|
|||||||
|
|
||||||
<style lang="sass" scoped>
|
<style lang="sass" scoped>
|
||||||
.wrapper-info
|
.wrapper-info
|
||||||
min-height: 443px
|
min-height: 336px
|
||||||
max-height: 443px
|
max-height: 443px
|
||||||
overflow-y: auto
|
overflow-y: auto
|
||||||
color: var(--font-grey-color)
|
color: var(--font-grey-color)
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import router from "@/router";
|
||||||
|
|
||||||
function prepareUrl(url) {
|
function prepareUrl(url) {
|
||||||
if (url.startsWith("http")) return url;
|
if (url.startsWith("http")) return url;
|
||||||
return `http://45.84.227.122:8080/api/${url}`;
|
return `http://45.84.227.122:8080/api/${url}`;
|
||||||
@@ -12,7 +14,10 @@ function handleRequest(method, url, headers, attempts, body, type) {
|
|||||||
})();
|
})();
|
||||||
})
|
})
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
if (res) return res.json();
|
if (res.status === 401) {
|
||||||
|
localStorage.removeItem("tokenAccess");
|
||||||
|
return router.push("/login");
|
||||||
|
} else if (res) return res.json();
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
return err;
|
return err;
|
||||||
|
|||||||
Reference in New Issue
Block a user