fix: roles, permission and access on profile page

This commit is contained in:
Jannat Patel
2025-11-06 12:21:12 +05:30
parent 27d2297e2b
commit 28be3891d2
8 changed files with 90 additions and 30 deletions

View File

@@ -124,19 +124,13 @@ const props = defineProps({
onMounted(() => {
if ($user.data) profile.reload()
setActiveTab()
})
const profile = createResource({
url: 'frappe.client.get',
makeParams(values) {
return {
doctype: 'User',
filters: {
username: props.username,
},
}
url: 'lms.lms.api.get_profile_details',
params: {
username: props.username,
},
})
@@ -183,6 +177,7 @@ watch(
() => props.username,
() => {
profile.reload()
getProfileRoles()
}
)
@@ -199,6 +194,7 @@ const hasHigherAccess = () => {
}
const isEvaluatorOrModerator = () => {
console.log(profile.data)
return (
profile.data?.roles.filter(
(row) => row.role === 'Moderator' || row.role === 'Evaluator'
@@ -210,7 +206,7 @@ const getTabButtons = () => {
let buttons = [{ label: 'About' }, { label: 'Certificates' }]
if ($user.data?.is_moderator) buttons.push({ label: 'Roles' })
if (hasHigherAccess() && isEvaluatorOrModerator()) {
if (hasHigherAccess()) {
buttons.push({ label: 'Slots' })
buttons.push({ label: 'Schedule' })
}

View File

@@ -36,7 +36,7 @@
</Calendar>
</div>
</div>
<Event v-model="showEvent" :event="currentEvent" />
<Event v-if="showEvent" v-model="showEvent" :event="currentEvent" />
</template>
<script setup>
import { Calendar, createListResource, Button } from 'frappe-ui'

View File

@@ -153,6 +153,7 @@ import { Play, X, Check, Settings } from 'lucide-vue-next'
import { sessionStore } from '@/stores/session'
import { useRouter } from 'vue-router'
import { openSettings } from '@/utils'
import { useSettings } from '@/stores/settings'
const user = inject<any>('$user')
const code = ref<string | null>('')
@@ -162,7 +163,8 @@ const errorMessage = ref<string | null>(null)
const testCaseSection = ref<HTMLElement | null>(null)
const testCases = ref<TestCase[]>([])
const boilerplate = ref<string>('')
const { brand, livecodeURL } = sessionStore()
const { brand } = sessionStore()
const { livecodeURL } = useSettings()
const router = useRouter()
const fromLesson = ref(false)
const falconURL = ref<string>('https://falcon.frappe.io/')