fix: show role options based on logged in user's role
(cherry picked from commit 12213de4780926a16ac07a06eb3ce36aa858047d)
This commit is contained in:
parent
d0cbad0ab1
commit
142a94e042
@ -28,11 +28,7 @@
|
||||
class="mt-4"
|
||||
v-model="role"
|
||||
:label="__('Invite as')"
|
||||
:options="[
|
||||
{ label: __('Sales User'), value: 'Sales User' },
|
||||
{ label: __('Manager'), value: 'Sales Manager' },
|
||||
{ label: __('Admin'), value: 'System Manager' },
|
||||
]"
|
||||
:options="roleOptions"
|
||||
:description="description"
|
||||
/>
|
||||
</div>
|
||||
@ -92,6 +88,7 @@
|
||||
<script setup>
|
||||
import MultiSelectEmailInput from '@/components/Controls/MultiSelectEmailInput.vue'
|
||||
import { validateEmail, convertArrayToString } from '@/utils'
|
||||
import { usersStore } from '@/stores/users'
|
||||
import {
|
||||
createListResource,
|
||||
createResource,
|
||||
@ -102,6 +99,7 @@ import { useOnboarding } from 'frappe-ui/frappe'
|
||||
import { ref, computed } from 'vue'
|
||||
|
||||
const { updateOnboardingStep } = useOnboarding('frappecrm')
|
||||
const { isAdmin, isManager } = usersStore()
|
||||
|
||||
const invitees = ref([])
|
||||
const role = ref('Sales User')
|
||||
@ -112,12 +110,20 @@ const description = computed(() => {
|
||||
'System Manager':
|
||||
'Can manage all aspects of the CRM, including user management, customizations and settings.',
|
||||
'Sales Manager':
|
||||
'Can manage and invite new agents, and create public & private views (reports).',
|
||||
'Can manage and invite new users, and create public & private views (reports).',
|
||||
'Sales User':
|
||||
'Can work with leads and deals and create private views (reports).',
|
||||
}[role.value]
|
||||
})
|
||||
|
||||
const roleOptions = computed(() => {
|
||||
return [
|
||||
{ value: 'Sales User', label: __('Sales User') },
|
||||
...(isManager() ? [{ value: 'Sales Manager', label: __('Manager') }] : []),
|
||||
...(isAdmin() ? [{ value: 'System Manager', label: __('Admin') }] : []),
|
||||
]
|
||||
})
|
||||
|
||||
const roleMap = {
|
||||
'Sales User': __('Sales User'),
|
||||
'Sales Manager': __('Manager'),
|
||||
@ -134,7 +140,7 @@ const inviteByEmail = createResource({
|
||||
},
|
||||
onSuccess(data) {
|
||||
if (data?.existing_invites?.length) {
|
||||
error.value = __('Agent with email {0} already exists', [
|
||||
error.value = __('User with email {0} already exists', [
|
||||
data.existing_invites.join(', '),
|
||||
])
|
||||
} else {
|
||||
|
||||
@ -49,6 +49,10 @@ export const usersStore = defineStore('crm-users', () => {
|
||||
return usersByName[email]
|
||||
}
|
||||
|
||||
function isAdmin(email) {
|
||||
return getUser(email).is_admin
|
||||
}
|
||||
|
||||
function isManager(email) {
|
||||
return getUser(email).is_manager
|
||||
}
|
||||
@ -68,6 +72,7 @@ export const usersStore = defineStore('crm-users', () => {
|
||||
return {
|
||||
users,
|
||||
getUser,
|
||||
isAdmin,
|
||||
isManager,
|
||||
isAgent,
|
||||
getUserRole,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user