diff --git a/packages/service/support/user/team/invitationLink/schema.ts b/packages/service/support/user/team/invitationLink/schema.ts index 7ad5259d2..efdb660c3 100644 --- a/packages/service/support/user/team/invitationLink/schema.ts +++ b/packages/service/support/user/team/invitationLink/schema.ts @@ -1,15 +1,18 @@ -import { - TeamCollectionName, - TeamMemberCollectionName -} from '@fastgpt/global/support/user/team/constant'; +import { TeamCollectionName } from '@fastgpt/global/support/user/team/constant'; import { connectionMongo, getMongoModel } from '../../../../common/mongo'; import { InvitationSchemaType } from './type'; -import addDays from 'date-fns/esm/fp/addDays/index.js'; +import { randomUUID } from 'crypto'; const { Schema } = connectionMongo; export const InvitationCollectionName = 'team_invitation_links'; const InvitationSchema = new Schema({ + linkId: { + type: String, + required: true, + unique: true, + default: () => randomUUID() + }, teamId: { type: Schema.Types.ObjectId, ref: TeamCollectionName, diff --git a/packages/service/support/user/team/invitationLink/type.ts b/packages/service/support/user/team/invitationLink/type.ts index 59873f958..a36245fa0 100644 --- a/packages/service/support/user/team/invitationLink/type.ts +++ b/packages/service/support/user/team/invitationLink/type.ts @@ -2,6 +2,7 @@ import { TeamMemberSchema } from '@fastgpt/global/support/user/team/type'; export type InvitationSchemaType = { _id: string; + linkId: string; teamId: string; usedTimesLimit?: number; forbidden?: boolean; @@ -25,11 +26,10 @@ export type InvitationLinkCreateType = { expires: InvitationLinkExpiresType; usedTimesLimit: 1 | -1; }; -export type InvitationLinkUpdateType = Partial< - Omit -> & { - linkId: string; -}; + +// export type InvitationLinkUpdateType = Partial< +// Omit +// >; export type InvitationInfoType = InvitationSchemaType & { teamAvatar: string; diff --git a/projects/app/src/pageComponents/account/team/Invite/CreateInvitationModal.tsx b/projects/app/src/pageComponents/account/team/Invite/CreateInvitationModal.tsx index 8f1d43a3c..302df2877 100644 --- a/projects/app/src/pageComponents/account/team/Invite/CreateInvitationModal.tsx +++ b/projects/app/src/pageComponents/account/team/Invite/CreateInvitationModal.tsx @@ -22,7 +22,7 @@ import { useRequest2 } from '@fastgpt/web/hooks/useRequest'; import { useTranslation } from 'next-i18next'; import { useForm } from 'react-hook-form'; -function CreateInvitationModal({ onClose }: { onClose: () => void }) { +function CreateInvitationModal({ onClose }: { onClose: (linkId?: string) => void }) { const { t } = useTranslation(); const expiresOptions: Array<{ label: string; value: InvitationLinkExpiresType }> = [ { label: t('account_team:30mins'), value: '30m' }, // 30 mins @@ -45,6 +45,9 @@ function CreateInvitationModal({ onClose }: { onClose: () => void }) { manual: true, successToast: t('common:common.Create Success'), errorToast: t('common:common.Create Failed'), + onSuccess: (data) => { + onClose(data); + }, onFinally: () => onClose() }); @@ -55,7 +58,7 @@ function CreateInvitationModal({ onClose }: { onClose: () => void }) { iconColor="primary.500" title={{t('account_team:create_invitation_link')}} > - + onClose()} /> <> @@ -91,7 +94,7 @@ function CreateInvitationModal({ onClose }: { onClose: () => void }) { -