767 lines
21 KiB
JavaScript
767 lines
21 KiB
JavaScript
import { createRouter, createWebHistory } from "vue-router";
|
|
import Default from "../views/dashboards/Default.vue";
|
|
import Automotive from "../views/dashboards/Automotive.vue";
|
|
import SmartHome from "../views/dashboards/SmartHome.vue";
|
|
import VRDefault from "../views/dashboards/vr/VRDefault.vue";
|
|
import VRInfo from "../views/dashboards/vr/VRInfo.vue";
|
|
import CRM from "../views/dashboards/CRM.vue";
|
|
import Overview from "../views/pages/profile/Overview.vue";
|
|
import Teams from "../views/pages/profile/Teams.vue";
|
|
import Projects from "../views/pages/profile/Projects.vue";
|
|
import General from "../views/pages/projects/General.vue";
|
|
import Timeline from "../views/pages/projects/Timeline.vue";
|
|
import NewProject from "../views/pages/projects/NewProject.vue";
|
|
import Pricing from "../views/pages/Pricing.vue";
|
|
import RTL from "../views/pages/Rtl.vue";
|
|
import Charts from "../views/pages/Charts.vue";
|
|
import SweetAlerts from "../views/pages/SweetAlerts.vue";
|
|
import Notifications from "../views/pages/Notifications.vue";
|
|
import Kanban from "../views/applications/Kanban.vue";
|
|
import Wizard from "../views/applications/wizard/Wizard.vue";
|
|
import DataTables from "../views/applications/DataTables.vue";
|
|
import Calendar from "../views/applications/Calendar.vue";
|
|
import Analytics from "../views/applications/analytics/Analytics.vue";
|
|
import EcommerceOverview from "../views/ecommerce/overview/Overview.vue";
|
|
import NewProduct from "../views/ecommerce/products/NewProduct.vue";
|
|
import EditProduct from "../views/ecommerce/EditProduct.vue";
|
|
import ProductPage from "../views/ecommerce/ProductPage.vue";
|
|
import ProductsList from "../views/ecommerce/ProductsList.vue";
|
|
import OrderDetails from "../views/ecommerce/Orders/OrderDetails";
|
|
import OrderList from "../views/ecommerce/Orders/OrderList";
|
|
import Referral from "../views/ecommerce/Referral";
|
|
import Reports from "../views/pages/Users/Reports.vue";
|
|
import NewUser from "../views/pages/Users/NewUser.vue";
|
|
import Settings from "../views/pages/Account/Settings.vue";
|
|
import Billing from "../views/pages/Account/Billing.vue";
|
|
import Invoice from "../views/pages/Account/Invoice.vue";
|
|
import Security from "../views/pages/Account/Security.vue";
|
|
import Widgets from "../views/pages/Widgets.vue";
|
|
import Basic from "../views/auth/signin/Basic.vue";
|
|
import Cover from "../views/auth/signin/Cover.vue";
|
|
import Illustration from "../views/auth/signin/Illustration.vue";
|
|
import ResetBasic from "../views/auth/reset/Basic.vue";
|
|
import ResetCover from "../views/auth/reset/Cover.vue";
|
|
import ResetIllustration from "../views/auth/reset/Illustration.vue";
|
|
import VerificationBasic from "../views/auth/verification/Basic.vue";
|
|
import VerificationCover from "../views/auth/verification/Cover.vue";
|
|
import VerificationIllustration from "../views/auth/verification/Illustration.vue";
|
|
import SignupBasic from "../views/auth/signup/Basic.vue";
|
|
import SignupCover from "../views/auth/signup/Cover.vue";
|
|
import SignupIllustration from "../views/auth/signup/Illustration.vue";
|
|
import Error404 from "../views/auth/error/Error404.vue";
|
|
import Error500 from "../views/auth/error/Error500.vue";
|
|
import lockBasic from "../views/auth/lock/Basic.vue";
|
|
import lockCover from "../views/auth/lock/Cover.vue";
|
|
import lockIllustration from "../views/auth/lock/Illustration.vue";
|
|
|
|
//ROUTE SHOULD USED
|
|
|
|
const routes = [
|
|
{
|
|
path: "/",
|
|
name: "/",
|
|
redirect: "/dashboards/dashboard-default",
|
|
},
|
|
{
|
|
path: "/dashboard",
|
|
redirect: "/dashboards/dashboard-default",
|
|
},
|
|
{
|
|
path: "/login",
|
|
name: "Login",
|
|
component: () => import("@/views/pages/Login.vue"),
|
|
meta: { public: true, guestOnly: true, guestLayout: true },
|
|
},
|
|
{
|
|
path: "/register",
|
|
name: "Register",
|
|
component: () => import("@/views/pages/Register.vue"),
|
|
meta: { public: true, guestOnly: true, guestLayout: true },
|
|
},
|
|
{
|
|
path: "/dashboards/dashboard-default",
|
|
name: "Default",
|
|
component: Default,
|
|
},
|
|
{
|
|
path: "/dashboards/automotive",
|
|
name: "Automotive",
|
|
component: Automotive,
|
|
},
|
|
{
|
|
path: "/dashboards/smart-home",
|
|
name: "Smart Home",
|
|
component: SmartHome,
|
|
},
|
|
{
|
|
path: "/dashboards/vr/vr-default",
|
|
name: "VR Default",
|
|
component: VRDefault,
|
|
},
|
|
{
|
|
path: "/dashboards/vr/vr-info",
|
|
name: "VR Info",
|
|
component: VRInfo,
|
|
},
|
|
{
|
|
path: "/dashboards/crm",
|
|
name: "CRM",
|
|
component: CRM,
|
|
},
|
|
{
|
|
path: "/pages/profile/overview",
|
|
name: "Profile Overview",
|
|
component: Overview,
|
|
},
|
|
{
|
|
path: "/pages/profile/teams",
|
|
name: "Teams",
|
|
component: Teams,
|
|
},
|
|
{
|
|
path: "/pages/profile/projects",
|
|
name: "All Projects",
|
|
component: Projects,
|
|
},
|
|
{
|
|
path: "/pages/projects/general",
|
|
name: "General",
|
|
component: General,
|
|
},
|
|
{
|
|
path: "/pages/projects/timeline",
|
|
name: "Timeline",
|
|
component: Timeline,
|
|
},
|
|
{
|
|
path: "/pages/projects/new-project",
|
|
name: "New Project",
|
|
component: NewProject,
|
|
},
|
|
{
|
|
path: "/pages/pricing-page",
|
|
name: "Pricing Page",
|
|
component: Pricing,
|
|
},
|
|
{
|
|
path: "/pages/rtl-page",
|
|
name: "RTL",
|
|
component: RTL,
|
|
},
|
|
{
|
|
path: "/pages/charts",
|
|
name: "Charts",
|
|
component: Charts,
|
|
},
|
|
{
|
|
path: "/pages/widgets",
|
|
name: "Widgets",
|
|
component: Widgets,
|
|
},
|
|
{
|
|
path: "/pages/sweet-alerts",
|
|
name: "Sweet Alerts",
|
|
component: SweetAlerts,
|
|
},
|
|
{
|
|
path: "/pages/notifications",
|
|
name: "Notifications",
|
|
component: Notifications,
|
|
},
|
|
{
|
|
path: "/applications/kanban",
|
|
name: "Kanban",
|
|
component: Kanban,
|
|
},
|
|
{
|
|
path: "/applications/wizard",
|
|
name: "Wizard",
|
|
component: Wizard,
|
|
},
|
|
{
|
|
path: "/applications/data-tables",
|
|
name: "Data Tables",
|
|
component: DataTables,
|
|
},
|
|
{
|
|
path: "/applications/calendar",
|
|
name: "Calendar",
|
|
component: Calendar,
|
|
},
|
|
{
|
|
path: "/applications/analytics",
|
|
name: "Analytics",
|
|
component: Analytics,
|
|
},
|
|
{
|
|
path: "/ecommerce/overview",
|
|
name: "Overview",
|
|
component: EcommerceOverview,
|
|
},
|
|
{
|
|
path: "/ecommerce/products/new-product",
|
|
name: "New Product",
|
|
component: NewProduct,
|
|
},
|
|
{
|
|
path: "/ecommerce/products/edit-product",
|
|
name: "Edit Product",
|
|
component: EditProduct,
|
|
},
|
|
{
|
|
path: "/ecommerce/products/product-page",
|
|
name: "Product Page",
|
|
component: ProductPage,
|
|
},
|
|
{
|
|
path: "/ecommerce/products/products-list",
|
|
name: "Products List",
|
|
component: ProductsList,
|
|
},
|
|
{
|
|
path: "/ecommerce/Orders/order-details",
|
|
name: "Order Details",
|
|
component: OrderDetails,
|
|
},
|
|
{
|
|
path: "/ecommerce/Orders/order-list",
|
|
name: "Order List",
|
|
component: OrderList,
|
|
},
|
|
{
|
|
path: "/ecommerce/referral",
|
|
name: "Referral",
|
|
component: Referral,
|
|
},
|
|
{
|
|
path: "/pages/users/reports",
|
|
name: "Reports",
|
|
component: Reports,
|
|
},
|
|
{
|
|
path: "/pages/users/new-user",
|
|
name: "New User",
|
|
component: NewUser,
|
|
},
|
|
{
|
|
path: "/pages/account/settings",
|
|
name: "Settings",
|
|
component: Settings,
|
|
},
|
|
{
|
|
path: "/pages/account/billing",
|
|
name: "Billing",
|
|
component: Billing,
|
|
},
|
|
{
|
|
path: "/pages/account/invoice",
|
|
name: "Invoice",
|
|
component: Invoice,
|
|
},
|
|
{
|
|
path: "/pages/account/Security",
|
|
name: "Security",
|
|
component: Security,
|
|
},
|
|
{
|
|
path: "/authentication/signin/basic",
|
|
name: "Signin Basic",
|
|
component: Basic,
|
|
meta: { guestLayout: true },
|
|
},
|
|
{
|
|
path: "/authentication/signin/cover",
|
|
name: "Signin Cover",
|
|
component: Cover,
|
|
meta: { guestLayout: true },
|
|
},
|
|
{
|
|
path: "/authentication/signin/illustration",
|
|
name: "Signin Illustration",
|
|
component: Illustration,
|
|
meta: { guestLayout: true },
|
|
},
|
|
{
|
|
path: "/authentication/reset/basic",
|
|
name: "Reset Basic",
|
|
component: ResetBasic,
|
|
meta: { guestLayout: true },
|
|
},
|
|
{
|
|
path: "/authentication/reset/cover",
|
|
name: "Reset Cover",
|
|
component: ResetCover,
|
|
meta: { guestLayout: true },
|
|
},
|
|
{
|
|
path: "/authentication/reset/illustration",
|
|
name: "Reset Illustration",
|
|
component: ResetIllustration,
|
|
meta: { guestLayout: true },
|
|
},
|
|
{
|
|
path: "/authentication/lock/basic",
|
|
name: "Lock Basic",
|
|
component: lockBasic,
|
|
meta: { guestLayout: true },
|
|
},
|
|
{
|
|
path: "/authentication/lock/cover",
|
|
name: "Lock Cover",
|
|
component: lockCover,
|
|
meta: { guestLayout: true },
|
|
},
|
|
{
|
|
path: "/authentication/lock/illustration",
|
|
name: "Lock Illustration",
|
|
component: lockIllustration,
|
|
meta: { guestLayout: true },
|
|
},
|
|
{
|
|
path: "/authentication/verification/basic",
|
|
name: "Verification Basic",
|
|
component: VerificationBasic,
|
|
meta: { guestLayout: true },
|
|
},
|
|
{
|
|
path: "/authentication/verification/cover",
|
|
name: "Verification Cover",
|
|
component: VerificationCover,
|
|
meta: { guestLayout: true },
|
|
},
|
|
{
|
|
path: "/authentication/verification/illustration",
|
|
name: "Verification Illustration",
|
|
component: VerificationIllustration,
|
|
meta: { guestLayout: true },
|
|
},
|
|
{
|
|
path: "/authentication/signup/basic",
|
|
name: "Signup Basic",
|
|
component: SignupBasic,
|
|
meta: { guestLayout: true },
|
|
},
|
|
{
|
|
path: "/authentication/signup/cover",
|
|
name: "Signup Cover",
|
|
component: SignupCover,
|
|
meta: { guestLayout: true },
|
|
},
|
|
{
|
|
path: "/authentication/signup/illustration",
|
|
name: "Signup Illustration",
|
|
component: SignupIllustration,
|
|
meta: { guestLayout: true },
|
|
},
|
|
{
|
|
path: "/authentication/error/error404",
|
|
name: "Error Error404",
|
|
component: Error404,
|
|
meta: { guestLayout: true },
|
|
},
|
|
{
|
|
path: "/authentication/error/error500",
|
|
name: "Error Error500",
|
|
component: Error500,
|
|
meta: { guestLayout: true },
|
|
},
|
|
{
|
|
path: "/crm/contact",
|
|
name: "Gestion contacts",
|
|
component: () => import("@/views/pages/CRM/Contacts.vue"),
|
|
},
|
|
{
|
|
path: "/crm/localisation-clients",
|
|
name: "Localisation clients",
|
|
component: () => import("@/views/pages/CRM/LocalisationClients.vue"),
|
|
},
|
|
{
|
|
path: "/crm/clients",
|
|
name: "Gestion clients",
|
|
component: () => import("@/views/pages/CRM/Clients.vue"),
|
|
},
|
|
{
|
|
path: "/crm/new-client",
|
|
name: "Creation client",
|
|
component: () => import("@/views/pages/CRM/AddClient.vue"),
|
|
},
|
|
{
|
|
path: "/crm/client/:id",
|
|
name: "Client details",
|
|
component: () => import("@/views/pages/CRM/ClientDetails.vue"),
|
|
},
|
|
{
|
|
path: "/crm/new-contact",
|
|
name: "Add Contact",
|
|
component: () => import("@/views/pages/CRM/AddContact.vue"),
|
|
},
|
|
// Agenda
|
|
{
|
|
path: "/agenda",
|
|
name: "Agenda",
|
|
component: () => import("@/views/pages/Agenda.vue"),
|
|
},
|
|
// Courriel
|
|
{
|
|
path: "/courriel",
|
|
name: "Courriel",
|
|
component: () => import("@/views/pages/Courriel.vue"),
|
|
},
|
|
// Webmailing
|
|
{
|
|
path: "/webmailing",
|
|
name: "Webmailing",
|
|
component: () => import("@/views/pages/Webmailing.vue"),
|
|
},
|
|
// Messages internes
|
|
{
|
|
path: "/messages",
|
|
name: "Messages internes",
|
|
component: () => import("@/views/pages/InternalMessages.vue"),
|
|
},
|
|
// Statistiques Thanatopracteurs
|
|
{
|
|
path: "/statistiques/thanatopracteurs",
|
|
name: "Statistiques Thanatopracteurs",
|
|
component: () => import("@/views/pages/StatistiquesThanatopracteurs.vue"),
|
|
},
|
|
// Clients - Statistiques
|
|
{
|
|
path: "/clients/statistiques",
|
|
name: "Statistiques clients",
|
|
component: () => import("@/views/pages/Clients/Statistiques.vue"),
|
|
},
|
|
// Fournisseurs
|
|
{
|
|
path: "/fournisseurs",
|
|
name: "Gestion fournisseurs",
|
|
component: () => import("@/views/pages/Fournisseurs/Fournisseurs.vue"),
|
|
},
|
|
{
|
|
path: "/fournisseurs/new",
|
|
name: "Creation fournisseur",
|
|
component: () => import("@/views/pages/Fournisseurs/AddFournisseur.vue"),
|
|
},
|
|
{
|
|
path: "/fournisseurs/:id",
|
|
name: "Fournisseur details",
|
|
component: () =>
|
|
import("@/views/pages/Fournisseurs/FournisseurDetails.vue"),
|
|
},
|
|
{
|
|
path: "/fournisseurs/contacts",
|
|
name: "Contacts fournisseurs",
|
|
component: () => import("@/views/pages/Fournisseurs/Contacts.vue"),
|
|
},
|
|
{
|
|
path: "/fournisseurs/commandes",
|
|
name: "Commandes fournisseurs",
|
|
component: () => import("@/views/pages/Fournisseurs/Commandes.vue"),
|
|
},
|
|
{
|
|
path: "/fournisseurs/commandes/new",
|
|
name: "Nouvelle Commande",
|
|
component: () => import("@/views/pages/Fournisseurs/NewCommande.vue"),
|
|
},
|
|
{
|
|
path: "/fournisseurs/commandes/:id",
|
|
name: "Commande Details",
|
|
component: () => import("@/views/pages/Fournisseurs/CommandeDetail.vue"),
|
|
},
|
|
{
|
|
path: "/fournisseurs/factures",
|
|
name: "Factures fournisseurs",
|
|
component: () => import("@/views/pages/Fournisseurs/Factures.vue"),
|
|
},
|
|
{
|
|
path: "/fournisseurs/statistiques",
|
|
name: "Statistiques fournisseurs",
|
|
component: () => import("@/views/pages/Fournisseurs/Statistiques.vue"),
|
|
},
|
|
// Sous-Traitants
|
|
{
|
|
path: "/sous-traitants",
|
|
name: "Gestion sous-traitants",
|
|
component: () => import("@/views/pages/SousTraitants/SousTraitants.vue"),
|
|
},
|
|
{
|
|
path: "/sous-traitants/contacts",
|
|
name: "Contacts sous-traitants",
|
|
component: () => import("@/views/pages/SousTraitants/Contacts.vue"),
|
|
},
|
|
{
|
|
path: "/sous-traitants/commandes",
|
|
name: "Commandes sous-traitants",
|
|
component: () => import("@/views/pages/SousTraitants/Commandes.vue"),
|
|
},
|
|
{
|
|
path: "/sous-traitants/factures",
|
|
name: "Factures sous-traitants",
|
|
component: () => import("@/views/pages/SousTraitants/Factures.vue"),
|
|
},
|
|
{
|
|
path: "/sous-traitants/statistiques",
|
|
name: "Statistiques sous-traitants",
|
|
component: () => import("@/views/pages/SousTraitants/Statistiques.vue"),
|
|
},
|
|
// Ventes
|
|
{
|
|
path: "/ventes/devis",
|
|
name: "Devis",
|
|
component: () => import("@/views/pages/Ventes/Devis.vue"),
|
|
},
|
|
{
|
|
path: "/ventes/devis/:id",
|
|
name: "Quote Details",
|
|
component: () => import("@/views/pages/Ventes/QuoteDetail.vue"),
|
|
},
|
|
{
|
|
path: "/ventes/devis/new",
|
|
name: "Nouveau Devis",
|
|
component: () => import("@/views/pages/Ventes/NewQuote.vue"),
|
|
},
|
|
// Invoices
|
|
{
|
|
path: "/ventes/factures",
|
|
name: "Liste Factures",
|
|
component: () => import("@/views/pages/Ventes/InvoiceList.vue"),
|
|
},
|
|
{
|
|
path: "/ventes/factures/new",
|
|
name: "Nouvelle Facture",
|
|
component: () => import("@/views/pages/Ventes/NewInvoice.vue"),
|
|
},
|
|
{
|
|
path: "/ventes/factures/:id",
|
|
name: "Invoice Details",
|
|
component: () => import("@/views/pages/Ventes/InvoiceDetail.vue"),
|
|
},
|
|
// Avoirs
|
|
{
|
|
path: "/avoirs",
|
|
name: "Liste Avoirs",
|
|
component: () => import("@/views/pages/Avoirs/AvoirList.vue"),
|
|
},
|
|
{
|
|
path: "/avoirs/new",
|
|
name: "Nouvel Avoir",
|
|
component: () => import("@/views/pages/Avoirs/NewAvoir.vue"),
|
|
},
|
|
{
|
|
path: "/avoirs/:id",
|
|
name: "Avoir Details",
|
|
component: () => import("@/views/pages/Avoirs/AvoirDetail.vue"),
|
|
},
|
|
// Client Groups
|
|
{
|
|
path: "/clients/groups",
|
|
name: "ClientGroups",
|
|
component: () => import("@/views/pages/Clients/ClientGroups.vue"),
|
|
},
|
|
{
|
|
path: "/clients/groups/new",
|
|
name: "NewClientGroup",
|
|
component: () => import("@/views/pages/Clients/NewClientGroup.vue"),
|
|
},
|
|
{
|
|
path: "/clients/groups/:id",
|
|
name: "ClientGroupDetail",
|
|
component: () => import("@/views/pages/Clients/ClientGroupDetail.vue"),
|
|
},
|
|
{
|
|
path: "/clients/groups/:id/edit",
|
|
name: "EditClientGroup",
|
|
component: () => import("@/views/pages/Clients/NewClientGroup.vue"),
|
|
},
|
|
{
|
|
path: "/ventes/statistiques",
|
|
name: "Statistiques ventes",
|
|
component: () => import("@/views/pages/Ventes/Statistiques.vue"),
|
|
},
|
|
// Stock
|
|
{
|
|
path: "/stock/reception",
|
|
name: "Reception stock",
|
|
component: () => import("@/views/pages/Stock/Reception.vue"),
|
|
},
|
|
{
|
|
path: "/stock",
|
|
name: "Gestion stock",
|
|
component: () => import("@/views/pages/Stock/Stock.vue"),
|
|
},
|
|
{
|
|
path: "/stock/produits",
|
|
name: "Gestion de produits",
|
|
component: () => import("@/views/pages/Stock/Products.vue"),
|
|
},
|
|
{
|
|
path: "/stock/produits/new",
|
|
name: "Creation produit",
|
|
component: () => import("@/views/pages/Stock/AddProduct.vue"),
|
|
},
|
|
{
|
|
path: "/stock/produits/details/:id",
|
|
name: "Product details",
|
|
component: () => import("@/views/pages/Stock/ProductDetails.vue"),
|
|
},
|
|
// Employés
|
|
{
|
|
path: "/employes",
|
|
name: "Gestion employes",
|
|
component: () => import("@/views/pages/Employes/Employees.vue"),
|
|
},
|
|
{
|
|
path: "/employes/new",
|
|
name: "Creation employé",
|
|
component: () => import("@/views/pages/CRM/AddEmployee.vue"),
|
|
},
|
|
{
|
|
path: "/employes/:id",
|
|
name: "Employee details",
|
|
component: () => import("@/views/pages/CRM/EmployeeDetails.vue"),
|
|
},
|
|
{
|
|
path: "/employes/ndf",
|
|
name: "NDF",
|
|
component: () => import("@/views/pages/Employes/NDF.vue"),
|
|
},
|
|
{
|
|
path: "/employes/vehicules",
|
|
name: "Véhicules",
|
|
component: () => import("@/views/pages/Employes/Vehicules.vue"),
|
|
},
|
|
{
|
|
path: "/employes/absences",
|
|
name: "Absences",
|
|
component: () => import("@/views/pages/Employes/Absences.vue"),
|
|
},
|
|
{
|
|
path: "/employes/thanatopracteurs",
|
|
name: "Gestion thanatopractitioners",
|
|
component: () =>
|
|
import("@/views/pages/Thanatopractitioners/Thanatopractitioners.vue"),
|
|
},
|
|
{
|
|
path: "/employes/thanatopracteurs/new",
|
|
name: "Creation thanatopractitioner",
|
|
component: () =>
|
|
import("@/views/pages/Thanatopractitioners/AddThanatopractitioner.vue"),
|
|
},
|
|
{
|
|
path: "/employes/thanatopracteurs/:id",
|
|
name: "Thanatopractitioner details",
|
|
component: () =>
|
|
import(
|
|
"@/views/pages/Thanatopractitioners/ThanatopractitionerDetails.vue"
|
|
),
|
|
},
|
|
{
|
|
path: "/interventions",
|
|
name: "Interventions",
|
|
component: () => import("@/views/pages/Interventions/Interventions.vue"),
|
|
},
|
|
{
|
|
path: "/interventions/new",
|
|
name: "Add Intervention",
|
|
component: () => import("@/views/pages/Interventions/AddIntervention.vue"),
|
|
},
|
|
{
|
|
path: "/intervention/:id",
|
|
name: "Intervention details",
|
|
component: () =>
|
|
import("@/views/pages/Interventions/InterventionDetails.vue"),
|
|
},
|
|
{
|
|
path: "/defunts",
|
|
name: "Defunts",
|
|
component: () => import("@/views/pages/Defunts/ListeDefunts.vue"),
|
|
},
|
|
{
|
|
path: "/defunts/new",
|
|
name: "Add Defunts",
|
|
component: () => import("@/views/pages/Defunts/AddDefunt.vue"),
|
|
},
|
|
{
|
|
path: "/defunts/:id",
|
|
name: "Defunt details",
|
|
component: () => import("@/views/pages/Defunts/DefuntDetails.vue"),
|
|
},
|
|
// Paramétrage
|
|
{
|
|
path: "/parametrage/droits",
|
|
name: "Gestion droits",
|
|
component: () => import("@/views/pages/Parametrage/Droits.vue"),
|
|
},
|
|
{
|
|
path: "/parametrage/emails",
|
|
name: "Gestion emails",
|
|
component: () => import("@/views/pages/Parametrage/Emails.vue"),
|
|
},
|
|
{
|
|
path: "/parametrage/modeles",
|
|
name: "Gestion modeles",
|
|
component: () => import("@/views/pages/Parametrage/Modeles.vue"),
|
|
},
|
|
{
|
|
path: "/parametrage/categories-produits",
|
|
name: "Product Categories",
|
|
component: () => import("@/views/pages/Parametrage/ProductCategories.vue"),
|
|
},
|
|
];
|
|
|
|
const router = createRouter({
|
|
history: createWebHistory(process.env.BASE_URL),
|
|
routes,
|
|
linkActiveClass: "active",
|
|
});
|
|
|
|
// Auth guard using Pinia store and Laravel Sanctum session
|
|
import { useAuthStore } from "@/stores/auth";
|
|
import pinia from "@/plugins/pinia";
|
|
|
|
const DASHBOARD = "/dashboards/dashboard-default";
|
|
const LOGIN = "/login"; // canonical login path without redirect query
|
|
|
|
router.beforeEach(async (to, from, next) => {
|
|
const auth = useAuthStore(pinia);
|
|
const isPublic = to.matched.some((r) => r.meta && r.meta.public === true);
|
|
const isGuestOnly = to.matched.some(
|
|
(r) => r.meta && r.meta.guestOnly === true
|
|
);
|
|
const isLoginRoute = to.name === "Login" || to.name === "Signin";
|
|
|
|
// Initialize auth from localStorage token if not already done
|
|
if (!auth.checked) {
|
|
const token = localStorage.getItem("auth_token");
|
|
if (token) {
|
|
// Token exists, set it and try to fetch user
|
|
auth.token = token;
|
|
try {
|
|
await auth.fetchMe();
|
|
} catch (error) {
|
|
// If token is invalid, clear it and continue as unauthenticated
|
|
console.warn("Invalid token, clearing auth");
|
|
localStorage.removeItem("auth_token");
|
|
auth.token = null;
|
|
auth.user = null;
|
|
auth.checked = true;
|
|
}
|
|
} else {
|
|
// No token, mark as checked
|
|
auth.checked = true;
|
|
}
|
|
}
|
|
|
|
if (auth.isAuthenticated) {
|
|
// Prevent authenticated users from visiting guest-only routes (like sign-in)
|
|
if (isGuestOnly || isLoginRoute) return next(DASHBOARD);
|
|
return next();
|
|
}
|
|
|
|
// Not authenticated: allow public/guest routes (like sign-in), otherwise send to login (no redirect param)
|
|
if (isPublic || isGuestOnly || isLoginRoute) return next();
|
|
return next({ path: LOGIN, replace: true });
|
|
});
|
|
|
|
export default router;
|