Implemented by Ralph autonomous loop. Iteration: 3 Co-Authored-By: Claude <noreply@anthropic.com>
188 lines
5.7 KiB
JavaScript
188 lines
5.7 KiB
JavaScript
import { createRouter, createWebHistory } from 'vue-router'
|
|
|
|
const routes = [
|
|
{
|
|
path: '/login',
|
|
name: 'Login',
|
|
component: () => import('@/views/LoginWrapper.vue'),
|
|
meta: { requiresAuth: false, title: 'Autentificare - ROA2WEB' }
|
|
},
|
|
{
|
|
path: '/reports',
|
|
component: () => import('@/modules/reports/ReportsLayout.vue'),
|
|
meta: { requiresAuth: true },
|
|
children: [
|
|
{
|
|
path: 'dashboard',
|
|
name: 'Dashboard',
|
|
component: () => import('@reports/views/DashboardView.vue'),
|
|
meta: { requiresAuth: true, title: 'Dashboard - ROA2WEB' }
|
|
},
|
|
{
|
|
path: 'invoices',
|
|
name: 'Invoices',
|
|
component: () => import('@reports/views/InvoicesView.vue'),
|
|
meta: { requiresAuth: true, title: 'Facturi - ROA2WEB' }
|
|
},
|
|
{
|
|
// US-519: Redirect old bank-cash route to /reports/cash
|
|
path: 'bank-cash',
|
|
redirect: '/reports/cash'
|
|
},
|
|
{
|
|
// US-519: Separate Cash page
|
|
path: 'cash',
|
|
name: 'Cash',
|
|
component: () => import('@reports/views/CashView.vue'),
|
|
meta: { requiresAuth: true, title: 'Casă - ROA2WEB' }
|
|
},
|
|
{
|
|
// US-519: Separate Bank page
|
|
path: 'bank',
|
|
name: 'Bank',
|
|
component: () => import('@reports/views/BankView.vue'),
|
|
meta: { requiresAuth: true, title: 'Bancă - ROA2WEB' }
|
|
},
|
|
{
|
|
path: 'trial-balance',
|
|
name: 'TrialBalance',
|
|
component: () => import('@reports/views/TrialBalanceView.vue'),
|
|
meta: { requiresAuth: true, title: 'Balanță de Verificare - ROA2WEB' }
|
|
},
|
|
{
|
|
path: 'telegram',
|
|
name: 'Telegram',
|
|
component: () => import('@reports/views/TelegramView.vue'),
|
|
meta: { requiresAuth: true, title: 'Telegram Bot - ROA2WEB' }
|
|
},
|
|
{
|
|
path: 'cache-stats',
|
|
name: 'CacheStats',
|
|
component: () => import('@reports/views/CacheStatsView.vue'),
|
|
meta: { requiresAuth: true, title: 'Statistici Cache - ROA2WEB' }
|
|
},
|
|
{
|
|
path: 'server-logs',
|
|
name: 'ServerLogs',
|
|
component: () => import('@reports/views/ServerLogsView.vue'),
|
|
meta: { requiresAuth: true, title: 'Server Logs - ROA2WEB' }
|
|
},
|
|
{
|
|
path: 'maturity-analysis',
|
|
name: 'MaturityAnalysis',
|
|
component: () => import('@reports/views/MaturityAnalysisView.vue'),
|
|
meta: { requiresAuth: true, title: 'Analiză Scadențe - ROA2WEB' }
|
|
},
|
|
{
|
|
// US-603: Single route for Detailed Invoices with tabs (Clienți/Furnizori)
|
|
path: 'detailed-invoices',
|
|
name: 'DetailedInvoices',
|
|
component: () => import('@reports/views/DetailedInvoicesView.vue'),
|
|
meta: { requiresAuth: true, title: 'Facturi Detaliate - ROA2WEB' }
|
|
}
|
|
]
|
|
},
|
|
{
|
|
path: '/data-entry',
|
|
component: () => import('@/modules/data-entry/DataEntryLayout.vue'),
|
|
meta: { requiresAuth: true },
|
|
children: [
|
|
{
|
|
path: '',
|
|
name: 'ReceiptsList',
|
|
component: () => import('@data-entry/views/receipts/ReceiptsListView.vue'),
|
|
meta: { requiresAuth: true, title: 'Lista Bonuri - ROA2WEB' }
|
|
},
|
|
{
|
|
path: 'create',
|
|
name: 'ReceiptCreate',
|
|
component: () => import('@data-entry/views/receipts/ReceiptCreateUnifiedView.vue'),
|
|
meta: { requiresAuth: true, title: 'Bon Nou - ROA2WEB' }
|
|
},
|
|
{
|
|
path: 'create-old',
|
|
name: 'ReceiptCreateOld',
|
|
component: () => import('@data-entry/views/receipts/ReceiptCreateView.vue'),
|
|
meta: { requiresAuth: true, title: 'Bon Nou (Legacy) - ROA2WEB' }
|
|
},
|
|
{
|
|
path: ':id',
|
|
name: 'ReceiptDetail',
|
|
component: () => import('@data-entry/views/receipts/ReceiptCreateUnifiedView.vue'),
|
|
meta: { requiresAuth: true, title: 'Detalii Bon - ROA2WEB' }
|
|
},
|
|
{
|
|
path: ':id/edit',
|
|
name: 'ReceiptEdit',
|
|
component: () => import('@data-entry/views/receipts/ReceiptCreateUnifiedView.vue'),
|
|
meta: { requiresAuth: true, title: 'Editare Bon - ROA2WEB' }
|
|
},
|
|
{
|
|
path: 'ocr-metrics',
|
|
name: 'OCRMetrics',
|
|
component: () => import('@data-entry/views/OCRMetricsView.vue'),
|
|
meta: { requiresAuth: true, title: 'Metrici OCR - ROA2WEB' }
|
|
},
|
|
{
|
|
// US-013: Redirect old bulk-upload route to main list (backwards compatibility)
|
|
path: 'bulk-upload',
|
|
redirect: '/data-entry'
|
|
}
|
|
]
|
|
},
|
|
{
|
|
path: '/settings',
|
|
name: 'SettingsHub',
|
|
component: () => import('@/modules/reports/ReportsLayout.vue'),
|
|
meta: { requiresAuth: true },
|
|
children: [
|
|
{
|
|
path: '',
|
|
name: 'Settings',
|
|
component: () => import('@reports/views/SettingsHubView.vue'),
|
|
meta: { requiresAuth: true, title: 'Setări - ROA2WEB' }
|
|
}
|
|
]
|
|
},
|
|
{
|
|
path: '/dashboard',
|
|
name: 'MainDashboard',
|
|
component: () => import('@reports/views/DashboardView.vue'),
|
|
meta: { requiresAuth: true, title: 'Dashboard - ROA2WEB' }
|
|
},
|
|
{
|
|
path: '/',
|
|
redirect: '/dashboard'
|
|
},
|
|
{
|
|
path: '/:pathMatch(.*)*',
|
|
redirect: '/dashboard'
|
|
}
|
|
]
|
|
|
|
const router = createRouter({
|
|
history: createWebHistory(import.meta.env.BASE_URL),
|
|
routes
|
|
})
|
|
|
|
// Navigation guard for authentication
|
|
router.beforeEach((to, from, next) => {
|
|
const isAuthenticated = !!localStorage.getItem('access_token')
|
|
|
|
if (to.meta.requiresAuth && !isAuthenticated) {
|
|
next('/login')
|
|
} else if (to.path === '/login' && isAuthenticated) {
|
|
next('/reports/dashboard')
|
|
} else {
|
|
next()
|
|
}
|
|
})
|
|
|
|
// Set page title after navigation
|
|
router.afterEach((to) => {
|
|
document.title = to.meta.title || 'ROA2WEB'
|
|
window.scrollTo(0, 0)
|
|
})
|
|
|
|
export default router
|