|
|
@ -26,7 +26,7 @@ const validateEmail = (email: string): boolean => { |
|
|
|
// all user input emails are stored here |
|
|
|
// all user input emails are stored here |
|
|
|
const emailBadges = ref<Array<string>>([]) |
|
|
|
const emailBadges = ref<Array<string>>([]) |
|
|
|
watch(inviteData, (newVal) => { |
|
|
|
watch(inviteData, (newVal) => { |
|
|
|
if (newVal.email.includes(' ' || ',')) { |
|
|
|
if (newVal.email.includes(' ')) { |
|
|
|
if (inviteData.email.length < 1) { |
|
|
|
if (inviteData.email.length < 1) { |
|
|
|
emailValidation.isError = true |
|
|
|
emailValidation.isError = true |
|
|
|
emailValidation.message = 'email should not be empty' |
|
|
|
emailValidation.message = 'email should not be empty' |
|
|
@ -39,11 +39,11 @@ watch(inviteData, (newVal) => { |
|
|
|
} |
|
|
|
} |
|
|
|
// if email is already enterd we just ignore the input |
|
|
|
// if email is already enterd we just ignore the input |
|
|
|
// no error is thrown |
|
|
|
// no error is thrown |
|
|
|
if (emailBadges.value.includes(newVal.email.split(' ' || ',')[0])) { |
|
|
|
if (emailBadges.value.includes(newVal.email.split(' ')[0])) { |
|
|
|
inviteData.email = '' |
|
|
|
inviteData.email = '' |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
const emailToAdd = newVal.email.split(' ' || ',')[0].trim() |
|
|
|
const emailToAdd = newVal.email.split(' ')[0].trim() |
|
|
|
emailBadges.value.push(emailToAdd) |
|
|
|
emailBadges.value.push(emailToAdd) |
|
|
|
inviteData.email = '' |
|
|
|
inviteData.email = '' |
|
|
|
} |
|
|
|
} |
|
|
@ -63,7 +63,7 @@ const handleEnter = () => { |
|
|
|
emailValidation.message = 'invalid email' |
|
|
|
emailValidation.message = 'invalid email' |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
inviteData.email += ',' |
|
|
|
inviteData.email += ' ' |
|
|
|
emailValidation.isError = false |
|
|
|
emailValidation.isError = false |
|
|
|
emailValidation.message = '' |
|
|
|
emailValidation.message = '' |
|
|
|
} |
|
|
|
} |
|
|
@ -90,6 +90,14 @@ const inviteCollaborator = async () => { |
|
|
|
isInvitingCollaborators.value = true |
|
|
|
isInvitingCollaborators.value = true |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
try { |
|
|
|
|
|
|
|
emailBadges.value.forEach((el, index) => { |
|
|
|
|
|
|
|
// prevent the last email from getting the "," |
|
|
|
|
|
|
|
if (index === emailBadges.value.length - 1) { |
|
|
|
|
|
|
|
inviteData.email += el |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
inviteData.email += `${el},` |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
usersData.value = await inviteUser(inviteData) |
|
|
|
usersData.value = await inviteUser(inviteData) |
|
|
|
usersData.roles = inviteData.roles |
|
|
|
usersData.roles = inviteData.roles |
|
|
|
if (usersData.value) { |
|
|
|
if (usersData.value) { |
|
|
@ -159,7 +167,7 @@ onKeyStroke('Backspace', () => { |
|
|
|
// when bulk email is pasted |
|
|
|
// when bulk email is pasted |
|
|
|
const onPaste = (e: ClipboardEvent) => { |
|
|
|
const onPaste = (e: ClipboardEvent) => { |
|
|
|
const pastedText = e.clipboardData?.getData('text') |
|
|
|
const pastedText = e.clipboardData?.getData('text') |
|
|
|
const inputArray = pastedText?.split(' ' || ',') |
|
|
|
const inputArray = pastedText?.split(' ') |
|
|
|
inputArray?.forEach((el) => { |
|
|
|
inputArray?.forEach((el) => { |
|
|
|
if (el.length < 1) { |
|
|
|
if (el.length < 1) { |
|
|
|
emailValidation.isError = true |
|
|
|
emailValidation.isError = true |
|
|
|