Files

64 lines
1.5 KiB
TypeScript

import { ref, computed } from 'vue'
export type UserRole = 'student' | 'teacher' | 'admin'
export interface UserProfile {
id: string
name: string
role: UserRole
code: string
avatar?: string
title?: string
}
const mockUsers: Record<UserRole, UserProfile> = {
student: {
id: 's-101',
name: 'محمدصادق حسینی',
role: 'student',
code: '۱۴۰۱۰۱۲۳',
title: 'طلبه پایه چهارم',
avatar: 'https://api.dicebear.com/7.x/bottts/svg?seed=student1'
},
teacher: {
id: 't-201',
name: 'حجت‌الاسلام والمسلمین استاد رفیعی',
role: 'teacher',
code: '۱۰۸۵',
title: 'مدرس سطوح عالی فقه و اصول',
avatar: 'https://api.dicebear.com/7.x/bottts/svg?seed=teacher1'
},
admin: {
id: 'a-301',
name: 'حاج آقای حسینیان (معاونت آموزش)',
role: 'admin',
code: '۳۰۱',
title: 'مدیر آموزش و امور طلاب',
avatar: 'https://api.dicebear.com/7.x/bottts/svg?seed=admin1'
}
}
const currentRole = ref<UserRole>('student')
export const useAuth = () => {
const currentUser = computed(() => mockUsers[currentRole.value])
const setRole = (role: UserRole) => {
currentRole.value = role
}
const roleLabels: Record<UserRole, string> = {
student: 'طلبه',
teacher: 'استاد',
admin: 'آموزش'
}
return {
currentRole,
currentUser,
setRole,
roleLabels,
mockUsers
}
}