feat: pivot to social media workflow app
This commit is contained in:
@@ -1,115 +1,147 @@
|
||||
import { useAuthStore } from '@/stores/authStore.js';
|
||||
import { createRouter, createWebHistory } from 'vue-router';
|
||||
|
||||
import CreatorHome from '@/views/creators/CreatorHome.vue';
|
||||
import CreatorLayout from '@/views/creators/CreatorLayout.vue';
|
||||
|
||||
const LoginView = () => import('@/views/auth/LoginView.vue');
|
||||
|
||||
const About = () => import('@/views/documentation/About.vue');
|
||||
const ContentPolicy = () => import('@/views/documentation/ContentPolicy.vue');
|
||||
const CreatorGuide = () => import('@/views/documentation/CreatorGuide.vue');
|
||||
const DocumentationLayout = () => import('@/views/documentation/DocumentationLayout.vue');
|
||||
const FAQ = () => import('@/views/documentation/FAQ.vue');
|
||||
const HelpAndContact = () => import('@/views/documentation/HelpAndContact.vue');
|
||||
const Pricing = () => import('@/views/documentation/Pricing.vue');
|
||||
const TermsAndConditions = () => import('@/views/documentation/TermsAndConditions.vue');
|
||||
const ProfilePage = () => import('@/views/profile/ProfilePage.vue');
|
||||
const PaymentCompleted = () => import('@/views/creators/PaymentCompleted.vue');
|
||||
const PaymentFailed = () => import('@/views/creators/PaymentFailed.vue');
|
||||
const Landing = () => import('@/views/main/Landing.vue');
|
||||
|
||||
const CreateCreator = () => import('@/views/creators/CreateCreator.vue');
|
||||
const RegisterView = () => import('@/views/auth/RegisterView.vue');
|
||||
const ForgotPasswordView = () => import('@/views/auth/ForgotPasswordView.vue');
|
||||
const ResetPasswordView = () => import('@/views/auth/ResetPasswordView.vue');
|
||||
const VerifyEmailView = () => import('@/views/auth/VerifyEmailView.vue');
|
||||
const OverviewView = () => import('@/views/app/OverviewView.vue');
|
||||
const DashboardView = () => import('@/views/app/DashboardView.vue');
|
||||
const ChannelsView = () => import('@/views/app/ChannelsView.vue');
|
||||
const CampaignsView = () => import('@/views/app/ProjectsView.vue');
|
||||
const CampaignDetailView = () => import('@/views/app/ProjectDetailView.vue');
|
||||
const MediaLibraryView = () => import('@/views/app/MediaLibraryView.vue');
|
||||
const WorkspaceCreateView = () => import('@/views/app/WorkspaceCreateView.vue');
|
||||
const SettingsLayoutView = () => import('@/views/app/SettingsLayoutView.vue');
|
||||
const UserSettingsView = () => import('@/views/app/UserSettingsView.vue');
|
||||
const IntegrationsSettingsView = () => import('@/views/app/IntegrationsSettingsView.vue');
|
||||
const WorkspaceSettingsView = () => import('@/views/app/WorkspaceSettingsView.vue');
|
||||
const ReviewQueueView = () => import('@/views/app/ReviewQueueView.vue');
|
||||
const ContentItemsView = () => import('@/views/app/ContentItemsView.vue');
|
||||
const ContentItemDetailView = () => import('@/views/app/ContentItemDetailView.vue');
|
||||
|
||||
const routes = [
|
||||
{
|
||||
path: '/landing',
|
||||
path: '/',
|
||||
name: 'landing',
|
||||
component: Landing,
|
||||
},
|
||||
{
|
||||
path: '/',
|
||||
redirect: { name: 'landing' },
|
||||
path: '/app',
|
||||
redirect: { name: 'dashboard' },
|
||||
},
|
||||
{
|
||||
path: '/@:creator',
|
||||
component: CreatorLayout,
|
||||
path: '/app/dashboard',
|
||||
name: 'dashboard',
|
||||
component: OverviewView,
|
||||
meta: { requiresAuth: true },
|
||||
},
|
||||
{
|
||||
path: '/app/workspace',
|
||||
name: 'workspace-dashboard',
|
||||
component: DashboardView,
|
||||
meta: { requiresAuth: true },
|
||||
},
|
||||
{
|
||||
path: '/app/channels',
|
||||
name: 'channels',
|
||||
component: ChannelsView,
|
||||
meta: { requiresAuth: true },
|
||||
},
|
||||
{
|
||||
path: '/app/media-library',
|
||||
name: 'media-library',
|
||||
component: MediaLibraryView,
|
||||
meta: { requiresAuth: true },
|
||||
},
|
||||
{
|
||||
path: '/app/campaigns',
|
||||
name: 'campaigns',
|
||||
component: CampaignsView,
|
||||
meta: { requiresAuth: true },
|
||||
},
|
||||
{
|
||||
path: '/app/campaigns/:projectId',
|
||||
name: 'campaign-detail',
|
||||
component: CampaignDetailView,
|
||||
meta: { requiresAuth: true },
|
||||
},
|
||||
{
|
||||
path: '/app/reviews',
|
||||
name: 'review-queue',
|
||||
component: ReviewQueueView,
|
||||
meta: { requiresAuth: true },
|
||||
},
|
||||
{
|
||||
path: '/app/workspace-settings',
|
||||
name: 'workspace-settings',
|
||||
component: WorkspaceSettingsView,
|
||||
meta: { requiresAuth: true, roles: ['Administrator', 'Manager'] },
|
||||
},
|
||||
{
|
||||
path: '/app/workspaces/new',
|
||||
name: 'workspace-create',
|
||||
component: WorkspaceCreateView,
|
||||
meta: { requiresAuth: true, roles: ['Administrator', 'Manager'] },
|
||||
},
|
||||
{
|
||||
path: '/app/settings',
|
||||
component: SettingsLayoutView,
|
||||
meta: { requiresAuth: true },
|
||||
children: [
|
||||
{
|
||||
path: '',
|
||||
name: 'creator',
|
||||
component: CreatorHome,
|
||||
redirect: { name: 'settings-user-information' },
|
||||
},
|
||||
{
|
||||
path: 'tip-completed',
|
||||
name: 'PaymentCompleted',
|
||||
component: PaymentCompleted,
|
||||
path: 'user-information',
|
||||
name: 'settings-user-information',
|
||||
component: UserSettingsView,
|
||||
},
|
||||
{
|
||||
path: 'tip-cancelled',
|
||||
name: 'PaymentFailed',
|
||||
component: PaymentFailed,
|
||||
path: 'workspaces',
|
||||
name: 'settings-workspaces',
|
||||
component: WorkspaceSettingsView,
|
||||
meta: { requiresAuth: true, roles: ['Administrator', 'Manager'] },
|
||||
},
|
||||
{
|
||||
path: 'integrations',
|
||||
name: 'settings-integrations',
|
||||
component: IntegrationsSettingsView,
|
||||
meta: { requiresAuth: true, roles: ['Administrator', 'Manager'] },
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: '/documents',
|
||||
component: DocumentationLayout,
|
||||
children: [
|
||||
{
|
||||
path: 'helpandcontact',
|
||||
name: 'helpandcontact',
|
||||
component: HelpAndContact,
|
||||
},
|
||||
{
|
||||
path: 'termsandconditions',
|
||||
name: 'termsandconditions',
|
||||
component: TermsAndConditions,
|
||||
},
|
||||
{
|
||||
path: 'contentpolicy',
|
||||
name: 'contentpolicy',
|
||||
component: ContentPolicy,
|
||||
},
|
||||
{
|
||||
path: 'faq',
|
||||
name: 'FAQ',
|
||||
component: FAQ,
|
||||
},
|
||||
{
|
||||
path: 'about',
|
||||
name: 'about',
|
||||
component: About,
|
||||
},
|
||||
{
|
||||
path: 'pricing',
|
||||
name: 'pricing',
|
||||
component: Pricing,
|
||||
},
|
||||
],
|
||||
path: '/app/content',
|
||||
name: 'content-items',
|
||||
component: ContentItemsView,
|
||||
meta: { requiresAuth: true },
|
||||
},
|
||||
{
|
||||
path: '/app/content/new',
|
||||
name: 'content-item-create',
|
||||
component: ContentItemDetailView,
|
||||
meta: { requiresAuth: true },
|
||||
},
|
||||
{
|
||||
path: '/app/content/:id',
|
||||
name: 'content-item-detail',
|
||||
component: ContentItemDetailView,
|
||||
meta: { requiresAuth: true },
|
||||
},
|
||||
{
|
||||
path: '/login',
|
||||
name: 'login',
|
||||
component: LoginView,
|
||||
meta: { notAuthenticated: true },
|
||||
props: route => ({ returnUrl: route.query.returnUrl || '/landing' }),
|
||||
props: route => ({ returnUrl: route.query.returnUrl || '/app/dashboard' }),
|
||||
},
|
||||
{
|
||||
path: '/profile',
|
||||
name: 'profile',
|
||||
component: ProfilePage,
|
||||
meta: { requiresAuth: true },
|
||||
},
|
||||
{
|
||||
path: '/create-creator',
|
||||
name: 'create-creator',
|
||||
component: CreateCreator,
|
||||
meta: { requiresAuth: true },
|
||||
redirect: { name: 'dashboard' },
|
||||
},
|
||||
{
|
||||
path: '/register',
|
||||
@@ -136,6 +168,10 @@ const routes = [
|
||||
component: VerifyEmailView,
|
||||
meta: { notAuthenticated: true },
|
||||
},
|
||||
{
|
||||
path: '/:pathMatch(.*)*',
|
||||
redirect: { name: 'landing' },
|
||||
},
|
||||
];
|
||||
|
||||
const router = createRouter({
|
||||
@@ -154,10 +190,16 @@ router.beforeEach((to, from, next) => {
|
||||
query: { returnUrl: to.fullPath },
|
||||
});
|
||||
} else {
|
||||
const requiredRoles = to.matched.flatMap(record => record.meta.roles ?? []);
|
||||
if (requiredRoles.length > 0 && !authStore.hasAnyRole(requiredRoles)) {
|
||||
next({ name: 'dashboard' });
|
||||
return;
|
||||
}
|
||||
|
||||
next();
|
||||
}
|
||||
} else if (to.matched.some(record => record.meta.notAuthenticated)) {
|
||||
if (authStore.isAuthenticated) next({ name: 'landing' });
|
||||
if (authStore.isAuthenticated) next({ name: 'dashboard' });
|
||||
else next();
|
||||
} else {
|
||||
next();
|
||||
|
||||
Reference in New Issue
Block a user