feat: member invitation and activation (#535)
Co-authored-by: John Wang <takatost@gmail.com>
This commit is contained in:
parent
004b3caa43
commit
cd51d3323b
51 changed files with 1235 additions and 329 deletions
|
|
@ -3,16 +3,16 @@ import { useState } from 'react'
|
|||
import { useContext } from 'use-context-selector'
|
||||
import { XMarkIcon } from '@heroicons/react/24/outline'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import s from './index.module.css'
|
||||
import Modal from '@/app/components/base/modal'
|
||||
import Button from '@/app/components/base/button'
|
||||
import s from './index.module.css'
|
||||
import { inviteMember } from '@/service/common'
|
||||
import { emailRegex } from '@/config'
|
||||
import { ToastContext } from '@/app/components/base/toast'
|
||||
|
||||
interface IInviteModalProps {
|
||||
onCancel: () => void,
|
||||
onSend: () => void,
|
||||
type IInviteModalProps = {
|
||||
onCancel: () => void
|
||||
onSend: (url: string) => void
|
||||
}
|
||||
const InviteModal = ({
|
||||
onCancel,
|
||||
|
|
@ -25,16 +25,16 @@ const InviteModal = ({
|
|||
const handleSend = async () => {
|
||||
if (emailRegex.test(email)) {
|
||||
try {
|
||||
const res = await inviteMember({ url: '/workspaces/current/members/invite-email', body: { email, role: 'admin'} })
|
||||
const res = await inviteMember({ url: '/workspaces/current/members/invite-email', body: { email, role: 'admin' } })
|
||||
|
||||
if (res.result === 'success') {
|
||||
onCancel()
|
||||
onSend()
|
||||
onSend(res.invite_url)
|
||||
}
|
||||
} catch (e) {
|
||||
|
||||
}
|
||||
} else {
|
||||
catch (e) {}
|
||||
}
|
||||
else {
|
||||
notify({ type: 'error', message: t('common.members.emailInvalid') })
|
||||
}
|
||||
}
|
||||
|
|
@ -51,15 +51,15 @@ const InviteModal = ({
|
|||
<div className='mb-2 text-sm font-medium text-gray-900'>{t('common.members.email')}</div>
|
||||
<input
|
||||
className='
|
||||
block w-full py-2 mb-9 px-3 bg-gray-50 outline-none border-none
|
||||
block w-full py-2 mb-9 px-3 bg-gray-50 outline-none border-none
|
||||
appearance-none text-sm text-gray-900 rounded-lg
|
||||
'
|
||||
value={email}
|
||||
onChange={e => setEmail(e.target.value)}
|
||||
placeholder={t('common.members.emailPlaceholder') || ''}
|
||||
/>
|
||||
<Button
|
||||
className='w-full text-sm font-medium'
|
||||
<Button
|
||||
className='w-full text-sm font-medium'
|
||||
onClick={handleSend}
|
||||
type='primary'
|
||||
>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue