import { postCreateInvitationLink } from '@/web/support/user/team/api'; import { Box, Button, Grid, Radio, RadioGroup, Input, ModalBody, ModalCloseButton, ModalFooter, HStack } from '@chakra-ui/react'; import { InvitationLinkCreateType, InvitationLinkExpiresType } from '@fastgpt/service/support/user/team/invitationLink/type'; import FormLabel from '@fastgpt/web/components/common/MyBox/FormLabel'; import MyModal from '@fastgpt/web/components/common/MyModal'; import MySelect from '@fastgpt/web/components/common/MySelect'; import { useRequest2 } from '@fastgpt/web/hooks/useRequest'; import { useTranslation } from 'next-i18next'; import { useForm } from 'react-hook-form'; function CreateInvitationModal({ onSuccess, onClose }: { onSuccess: (linkId: string) => void; onClose: () => void; }) { const { t } = useTranslation(); const expiresOptions: Array<{ label: string; value: InvitationLinkExpiresType }> = [ { label: t('account_team:30mins'), value: '30m' }, // 30 mins { label: t('account_team:7days'), value: '7d' }, // 7 days { label: t('account_team:1year'), value: '1y' } // 1 year ]; const { register, handleSubmit, watch, setValue } = useForm({ defaultValues: { description: '', expires: expiresOptions[1].value, usedTimesLimit: 1 } }); const expires = watch('expires'); const usedTimesLimit = watch('usedTimesLimit'); const { runAsync: createInvitationLink, loading } = useRequest2(postCreateInvitationLink, { manual: true, errorToast: t('common:common.Create Failed'), onSuccess: (data) => { onSuccess(data); onClose(); } }); return ( {t('account_team:create_invitation_link')}} > onClose()} /> <> {t('account_team:invitation_link_description')} <> {t('account_team:expires')} setValue('expires', val)} minW="120px" /> <> {t('account_team:used_times_limit')} setValue('usedTimesLimit', Number(val) as 1 | -1)} value={String(usedTimesLimit)} > {t('account_team:1person')} {t('account_team:unlimited')} ); } export default CreateInvitationModal;