diff --git a/src/components/NavBar.vue b/src/components/NavBar.vue index 7b7b1097f..a13e933b6 100644 --- a/src/components/NavBar.vue +++ b/src/components/NavBar.vue @@ -16,6 +16,34 @@ const token = session.getToken(); const appName = 'Lilium'; onMounted(() => stateStore.setMounted()); + +function redirect(id) { + const currentURL = window.location.href; + + const salixBaseURL = 'https://salix.verdnatura.es/#!/'; + + 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`; + + window.location.href = redirectURL; + } else { + window.location.href = salixBaseURL; + } +}