refs #5989 btn redirection #69

Merged
alexm merged 19 commits from 5989-redirectSalix into dev 2023-08-09 10:39:54 +00:00
1 changed files with 6 additions and 18 deletions
Showing only changes of commit a79ae24423 - Show all commits

View File

@ -19,26 +19,14 @@ onMounted(() => stateStore.setMounted());
function redirect(id) {
const currentURL = window.location.href;
const salixBaseURL = 'https://salix.verdnatura.es/#!/';
const routeRegex = /\/#\/(\w+)(?:\/(\d+))?/;
const dashboardRegex = /\/#\/dashboard/;
const claimRegex = /\/#\/claim\/(\d+)\/summary/;
const invoiceOutRegex = /\/#\/invoice-out\/(\d+)\/summary/;
if (currentURL.match(dashboardRegex)) {
window.location.href = salixBaseURL;
} else if (currentURL.match(claimRegex)) {
const claimID = currentURL.match(claimRegex)[1];
const redirectURL = salixBaseURL + `claim/${claimID}/summary`;
window.location.href = redirectURL;
} else if (currentURL.match(invoiceOutRegex)) {
const invoiceOutID = currentURL.match(invoiceOutRegex)[1];
const redirectURL = salixBaseURL + `invoice-out/${invoiceOutID}/summary`;
const match = currentURL.match(routeRegex);
if (match) {
const [, element, number] = match;
const redirectURL =
salixBaseURL + (number ? `${element}/${number}/summary` : `${element}/index`);
window.location.href = redirectURL;
} else {
window.location.href = salixBaseURL;