Compare commits
2 Commits
612a6e3dfe
...
e4a0eb463b
| Author | SHA1 | Date | |
|---|---|---|---|
| e4a0eb463b | |||
| 20551fee63 |
@@ -7,7 +7,9 @@
|
||||
</button>
|
||||
</div>
|
||||
<div class="header-block__logo">
|
||||
<a :href="MAIN_SITE_URL">
|
||||
<img :src="logo" alt="logo" />
|
||||
</a>
|
||||
</div>
|
||||
<div class="header-block__title">
|
||||
<slot>
|
||||
@@ -52,6 +54,7 @@
|
||||
import { computed, ref } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { useUIStore } from '@/store/ui'
|
||||
import { MAIN_SITE_URL } from '@/enums'
|
||||
import { gallery } from '@/utils/gallery'
|
||||
import useAuth from '@/composables/useAuth'
|
||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
||||
@@ -149,7 +152,12 @@ const iconList = [
|
||||
display: none;
|
||||
}
|
||||
|
||||
a {
|
||||
display: block;
|
||||
}
|
||||
|
||||
img {
|
||||
display: block;
|
||||
margin: 0 auto;
|
||||
height: 3.5rem;
|
||||
object-fit: contain;
|
||||
|
||||
+4
-1
@@ -220,8 +220,11 @@ export const MISSIONARY_REQUEST_STATUS = Object.freeze({
|
||||
rejected: 'رد شده',
|
||||
})
|
||||
|
||||
export const MAIN_SITE_URL = 'https://madresebanoo.ir/'
|
||||
|
||||
// Landing route per role after login / when a logged-in user hits a guest
|
||||
// page. Roles not listed here fall back to the student dashboard.
|
||||
// page. Roles not listed here fall back to the student dashboard. Approved
|
||||
// users of every role except admin bypass this and land on MAIN_SITE_URL.
|
||||
export const ROLE_HOME_ROUTES = Object.freeze({
|
||||
admin: 'admin-dashboard',
|
||||
counselor: 'counselor-dashboard',
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
import { ROLE_HOME_ROUTES } from '@/enums'
|
||||
import { useAuthStore } from '@/store/auth'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import { MAIN_SITE_URL, ROLE_HOME_ROUTES } from '@/enums'
|
||||
|
||||
export const shouldLandOnMainSite = (auth) =>
|
||||
auth.role !== 'admin' && auth.user?.status === 'approved'
|
||||
|
||||
export const useRedirectAfterLogin = () => {
|
||||
const router = useRouter()
|
||||
@@ -13,6 +16,10 @@ export const useRedirectAfterLogin = () => {
|
||||
router.push(redirect).catch(() => router.push('/'))
|
||||
return
|
||||
}
|
||||
if (shouldLandOnMainSite(auth)) {
|
||||
window.location.href = MAIN_SITE_URL
|
||||
return
|
||||
}
|
||||
const target = { name: ROLE_HOME_ROUTES[auth.role] || 'student-dashboard' }
|
||||
router.push(target).catch(() => router.push('/'))
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
<template>
|
||||
<aside class="admin-sidebar">
|
||||
<div class="admin-sidebar__logo">
|
||||
<a :href="MAIN_SITE_URL">
|
||||
<img :src="logo" alt="مدرسه بانو" />
|
||||
</a>
|
||||
</div>
|
||||
<nav class="admin-sidebar__nav">
|
||||
<ul>
|
||||
@@ -56,6 +58,7 @@
|
||||
<script setup>
|
||||
import { ref, watch } from 'vue'
|
||||
import { RouterLink } from 'vue-router'
|
||||
import { MAIN_SITE_URL } from '@/enums'
|
||||
import { gallery } from '@/utils/gallery'
|
||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
||||
import SidebarLogout from '@/layouts/sidebars/SidebarLogout.vue'
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
<template>
|
||||
<aside class="counselor-sidebar">
|
||||
<div class="counselor-sidebar__logo">
|
||||
<a :href="MAIN_SITE_URL">
|
||||
<img :src="logo" alt="مدرسه بانو" />
|
||||
</a>
|
||||
</div>
|
||||
<nav class="counselor-sidebar__nav">
|
||||
<ul>
|
||||
@@ -23,6 +25,7 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { MAIN_SITE_URL } from '@/enums'
|
||||
import { gallery } from '@/utils/gallery'
|
||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
||||
import SidebarLogout from '@/layouts/sidebars/SidebarLogout.vue'
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
<template>
|
||||
<aside class="student-sidebar" :style="{ backgroundImage: `url(${bgPattern})` }">
|
||||
<div class="student-sidebar__logo">
|
||||
<a :href="MAIN_SITE_URL">
|
||||
<img :src="logo" alt="مدرسه بانو" />
|
||||
</a>
|
||||
</div>
|
||||
<nav class="student-sidebar__nav">
|
||||
<ul>
|
||||
@@ -23,6 +25,7 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { MAIN_SITE_URL } from '@/enums'
|
||||
import { gallery } from '@/utils/gallery'
|
||||
import SvgIcon from '@/components/icons/SvgIcon.vue'
|
||||
import SidebarLogout from '@/layouts/sidebars/SidebarLogout.vue'
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { ROLE_HOME_ROUTES } from '@/enums'
|
||||
import { useAuthStore } from '@/store/auth'
|
||||
import { MAIN_SITE_URL, ROLE_HOME_ROUTES } from '@/enums'
|
||||
import { tokenService } from '@/services/api/token-service'
|
||||
import { shouldLandOnMainSite } from '@/features/auth/composables/useRedirectAfterLogin'
|
||||
|
||||
const APP_TITLE = 'مدرسه بانو'
|
||||
|
||||
@@ -19,6 +20,10 @@ export const guestGuard = (to) => {
|
||||
if (!to.meta?.requiresGuest) return
|
||||
if (tokenService.hasToken()) {
|
||||
const auth = useAuthStore()
|
||||
if (shouldLandOnMainSite(auth)) {
|
||||
window.location.href = MAIN_SITE_URL
|
||||
return false
|
||||
}
|
||||
return { name: ROLE_HOME_ROUTES[auth.role] || 'student-dashboard' }
|
||||
}
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user