|
|
@ -15,12 +15,13 @@ import { isEmail } from '~~/utils/validation' |
|
|
|
const { show, selectedUser } = defineProps<Props>() |
|
|
|
const { show, selectedUser } = defineProps<Props>() |
|
|
|
const emits = defineEmits(['closed']) |
|
|
|
const emits = defineEmits(['closed']) |
|
|
|
const toast = useToast() |
|
|
|
const toast = useToast() |
|
|
|
|
|
|
|
|
|
|
|
interface Props { |
|
|
|
interface Props { |
|
|
|
show: boolean |
|
|
|
show: boolean |
|
|
|
selectedUser?: User |
|
|
|
selectedUser?: User |
|
|
|
} |
|
|
|
} |
|
|
|
interface Users { |
|
|
|
interface Users { |
|
|
|
emails: string |
|
|
|
emails?: string |
|
|
|
role: ProjectRole |
|
|
|
role: ProjectRole |
|
|
|
invitationToken?: string |
|
|
|
invitationToken?: string |
|
|
|
} |
|
|
|
} |
|
|
@ -28,8 +29,7 @@ interface Users { |
|
|
|
const { project } = useProject() |
|
|
|
const { project } = useProject() |
|
|
|
const { $api, $e } = useNuxtApp() |
|
|
|
const { $api, $e } = useNuxtApp() |
|
|
|
|
|
|
|
|
|
|
|
const usersData = $ref<Users>({ emails: '', role: ProjectRole.Guest, invitationToken: undefined }) |
|
|
|
const usersData = $ref<Users>({ emails: undefined, role: ProjectRole.Guest, invitationToken: undefined }) |
|
|
|
let isFirstRender = $ref(true) |
|
|
|
|
|
|
|
const inviteToken = $ref(null) |
|
|
|
const inviteToken = $ref(null) |
|
|
|
const formRef = ref() |
|
|
|
const formRef = ref() |
|
|
|
|
|
|
|
|
|
|
@ -58,11 +58,10 @@ const validators = computed(() => { |
|
|
|
const { validateInfos } = useForm(usersData, validators) |
|
|
|
const { validateInfos } = useForm(usersData, validators) |
|
|
|
|
|
|
|
|
|
|
|
onMounted(() => { |
|
|
|
onMounted(() => { |
|
|
|
if (isFirstRender && selectedUser) { |
|
|
|
if (!usersData.emails && selectedUser?.email) { |
|
|
|
usersData.emails = selectedUser.email |
|
|
|
usersData.emails = selectedUser.email |
|
|
|
usersData.role = selectedUser.roles |
|
|
|
usersData.role = selectedUser.roles |
|
|
|
} |
|
|
|
} |
|
|
|
if (isFirstRender) isFirstRender = false |
|
|
|
|
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
const saveUser = async () => { |
|
|
|
const saveUser = async () => { |
|
|
@ -112,7 +111,7 @@ const clickInviteMore = () => { |
|
|
|
$e('c:user:invite-more') |
|
|
|
$e('c:user:invite-more') |
|
|
|
usersData.invitationToken = undefined |
|
|
|
usersData.invitationToken = undefined |
|
|
|
usersData.role = ProjectRole.Guest |
|
|
|
usersData.role = ProjectRole.Guest |
|
|
|
usersData.emails = '' |
|
|
|
usersData.emails = undefined |
|
|
|
} |
|
|
|
} |
|
|
|
</script> |
|
|
|
</script> |
|
|
|
|
|
|
|
|
|
|
|