fix: use multi select user input and show already exist error if user with email exist or invited
(cherry picked from commit d06ac91052021be38952d9956e418ff868c11af5)
This commit is contained in:
parent
1810b31647
commit
ffd24933cd
@ -11,7 +11,7 @@
|
|||||||
<div
|
<div
|
||||||
class="p-2 group bg-surface-gray-2 hover:bg-surface-gray-3 rounded"
|
class="p-2 group bg-surface-gray-2 hover:bg-surface-gray-3 rounded"
|
||||||
>
|
>
|
||||||
<MultiSelectEmailInput
|
<MultiSelectUserInput
|
||||||
class="flex-1"
|
class="flex-1"
|
||||||
inputClass="!bg-surface-gray-2 hover:!bg-surface-gray-3 group-hover:!bg-surface-gray-3"
|
inputClass="!bg-surface-gray-2 hover:!bg-surface-gray-3 group-hover:!bg-surface-gray-3"
|
||||||
:placeholder="__('john@doe.com')"
|
:placeholder="__('john@doe.com')"
|
||||||
@ -20,9 +20,15 @@
|
|||||||
:error-message="
|
:error-message="
|
||||||
(value) => __('{0} is an invalid email address', [value])
|
(value) => __('{0} is an invalid email address', [value])
|
||||||
"
|
"
|
||||||
:fetchContacts="false"
|
:fetchUsers="false"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
<div
|
||||||
|
v-if="userExistMessage || inviteeExistMessage"
|
||||||
|
class="text-xs text-ink-red-3 mt-1.5"
|
||||||
|
>
|
||||||
|
{{ userExistMessage || inviteeExistMessage }}
|
||||||
|
</div>
|
||||||
<FormControl
|
<FormControl
|
||||||
type="select"
|
type="select"
|
||||||
class="mt-4"
|
class="mt-4"
|
||||||
@ -86,7 +92,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script setup>
|
<script setup>
|
||||||
import MultiSelectEmailInput from '@/components/Controls/MultiSelectEmailInput.vue'
|
import MultiSelectUserInput from '@/components/Controls/MultiSelectUserInput.vue'
|
||||||
import { validateEmail, convertArrayToString } from '@/utils'
|
import { validateEmail, convertArrayToString } from '@/utils'
|
||||||
import { usersStore } from '@/stores/users'
|
import { usersStore } from '@/stores/users'
|
||||||
import {
|
import {
|
||||||
@ -99,12 +105,44 @@ import { useOnboarding } from 'frappe-ui/frappe'
|
|||||||
import { ref, computed } from 'vue'
|
import { ref, computed } from 'vue'
|
||||||
|
|
||||||
const { updateOnboardingStep } = useOnboarding('frappecrm')
|
const { updateOnboardingStep } = useOnboarding('frappecrm')
|
||||||
const { isAdmin, isManager } = usersStore()
|
const { users, isAdmin, isManager } = usersStore()
|
||||||
|
|
||||||
const invitees = ref([])
|
const invitees = ref([])
|
||||||
const role = ref('Sales User')
|
const role = ref('Sales User')
|
||||||
const error = ref(null)
|
const error = ref(null)
|
||||||
|
|
||||||
|
const userExistMessage = computed(() => {
|
||||||
|
const inviteesSet = new Set(invitees.value)
|
||||||
|
if (!inviteesSet.size) return null
|
||||||
|
|
||||||
|
if (!users.data?.crmUsers?.length) return null
|
||||||
|
const existingEmails = users.data.crmUsers.map((user) => user.name)
|
||||||
|
const existingUsersSet = new Set(existingEmails)
|
||||||
|
|
||||||
|
const existingInvitees = inviteesSet.intersection(existingUsersSet)
|
||||||
|
if (existingInvitees.size === 0) return null
|
||||||
|
|
||||||
|
return __('User with email {0} already exists', [
|
||||||
|
Array.from(existingInvitees).join(', '),
|
||||||
|
])
|
||||||
|
})
|
||||||
|
|
||||||
|
const inviteeExistMessage = computed(() => {
|
||||||
|
const inviteesSet = new Set(invitees.value)
|
||||||
|
if (!inviteesSet.size) return null
|
||||||
|
|
||||||
|
if (!pendingInvitations.data?.length) return null
|
||||||
|
const existingEmails = pendingInvitations.data.map((user) => user.email)
|
||||||
|
const existingUsersSet = new Set(existingEmails)
|
||||||
|
|
||||||
|
const existingInvitees = inviteesSet.intersection(existingUsersSet)
|
||||||
|
if (existingInvitees.size === 0) return null
|
||||||
|
|
||||||
|
return __('User with email {0} already invited', [
|
||||||
|
Array.from(existingInvitees).join(', '),
|
||||||
|
])
|
||||||
|
})
|
||||||
|
|
||||||
const description = computed(() => {
|
const description = computed(() => {
|
||||||
return {
|
return {
|
||||||
'System Manager':
|
'System Manager':
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user