fix: do not show contacts in dropdown in invite member page
This commit is contained in:
parent
08f042589d
commit
55a67bbc0c
@ -123,6 +123,12 @@ def invite_by_email(emails: str, role: str):
|
|||||||
for email in to_invite:
|
for email in to_invite:
|
||||||
frappe.get_doc(doctype="CRM Invitation", email=email, role=role).insert(ignore_permissions=True)
|
frappe.get_doc(doctype="CRM Invitation", email=email, role=role).insert(ignore_permissions=True)
|
||||||
|
|
||||||
|
return {
|
||||||
|
"existing_members": existing_members,
|
||||||
|
"existing_invites": existing_invites,
|
||||||
|
"to_invite": to_invite,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def get_file_uploader_defaults(doctype: str):
|
def get_file_uploader_defaults(doctype: str):
|
||||||
|
|||||||
@ -58,6 +58,21 @@
|
|||||||
class="p-1.5 max-h-[12rem] overflow-y-auto"
|
class="p-1.5 max-h-[12rem] overflow-y-auto"
|
||||||
static
|
static
|
||||||
>
|
>
|
||||||
|
<div
|
||||||
|
v-if="!options.length"
|
||||||
|
class="flex gap-2 rounded px-2 py-1 text-base text-ink-gray-5"
|
||||||
|
>
|
||||||
|
<FeatherIcon
|
||||||
|
v-if="fetchContacts"
|
||||||
|
name="search"
|
||||||
|
class="h-4"
|
||||||
|
/>
|
||||||
|
{{
|
||||||
|
fetchContacts
|
||||||
|
? __('No results found')
|
||||||
|
: __('Type an email address to add')
|
||||||
|
}}
|
||||||
|
</div>
|
||||||
<ComboboxOption
|
<ComboboxOption
|
||||||
v-for="option in options"
|
v-for="option in options"
|
||||||
:key="option.value"
|
:key="option.value"
|
||||||
@ -137,6 +152,10 @@ const props = defineProps({
|
|||||||
type: Function,
|
type: Function,
|
||||||
default: (value) => `${value} is an Invalid value`,
|
default: (value) => `${value} is an Invalid value`,
|
||||||
},
|
},
|
||||||
|
fetchContacts: {
|
||||||
|
type: Boolean,
|
||||||
|
default: true,
|
||||||
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
const values = defineModel()
|
const values = defineModel()
|
||||||
@ -191,17 +210,19 @@ const filterOptions = createResource({
|
|||||||
})
|
})
|
||||||
|
|
||||||
const options = computed(() => {
|
const options = computed(() => {
|
||||||
let searchedContacts = filterOptions.data || []
|
let searchedContacts = props.fetchContacts ? filterOptions.data : []
|
||||||
if (!searchedContacts.length && query.value) {
|
if (!searchedContacts.length && query.value) {
|
||||||
searchedContacts.push({
|
searchedContacts.push({
|
||||||
label: query.value,
|
label: query.value,
|
||||||
value: query.value,
|
value: query.value,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return searchedContacts
|
return searchedContacts || []
|
||||||
})
|
})
|
||||||
|
|
||||||
function reload(val) {
|
function reload(val) {
|
||||||
|
if (!props.fetchContacts) return
|
||||||
|
|
||||||
filterOptions.update({
|
filterOptions.update({
|
||||||
params: { txt: val },
|
params: { txt: val },
|
||||||
})
|
})
|
||||||
|
|||||||
@ -20,6 +20,7 @@
|
|||||||
:error-message="
|
:error-message="
|
||||||
(value) => __('{0} is an invalid email address', [value])
|
(value) => __('{0} is an invalid email address', [value])
|
||||||
"
|
"
|
||||||
|
:fetchContacts="false"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<FormControl
|
<FormControl
|
||||||
@ -127,10 +128,17 @@ const inviteByEmail = createResource({
|
|||||||
role: role.value,
|
role: role.value,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onSuccess() {
|
onSuccess(data) {
|
||||||
|
if (data?.existing_invites?.length) {
|
||||||
|
error.value = __('Agent with email {0} already exists', [
|
||||||
|
data.existing_invites.join(', '),
|
||||||
|
])
|
||||||
|
} else {
|
||||||
|
role.value = 'Sales User'
|
||||||
|
error.value = null
|
||||||
|
}
|
||||||
|
|
||||||
invitees.value = []
|
invitees.value = []
|
||||||
role.value = 'Sales User'
|
|
||||||
error.value = null
|
|
||||||
pendingInvitations.reload()
|
pendingInvitations.reload()
|
||||||
updateOnboardingStep('invite_your_team')
|
updateOnboardingStep('invite_your_team')
|
||||||
},
|
},
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user