diff options
Diffstat (limited to 'components/project')
| -rw-r--r-- | components/project/ProjectNav.tsx | 4 | ||||
| -rw-r--r-- | components/project/dataroom-members.ts | 74 |
2 files changed, 76 insertions, 2 deletions
diff --git a/components/project/ProjectNav.tsx b/components/project/ProjectNav.tsx index 1654c30d..0486e9b5 100644 --- a/components/project/ProjectNav.tsx +++ b/components/project/ProjectNav.tsx @@ -123,10 +123,10 @@ export function ProjectNav({ projectId }: ProjectNavProps) { <Badge variant="outline"> {projectRole || 'viewer'} </Badge> - <Button variant="outline" size="sm"> + {/* <Button variant="outline" size="sm"> <Share2 className="h-4 w-4 mr-1" /> Share - </Button> + </Button> */} </div> </div> diff --git a/components/project/dataroom-members.ts b/components/project/dataroom-members.ts new file mode 100644 index 00000000..2512a5cd --- /dev/null +++ b/components/project/dataroom-members.ts @@ -0,0 +1,74 @@ +"use server"; + +import { sendEmail } from "@/lib/mail/sendEmail"; +import { getServerSession } from "next-auth/next" +import { authOptions } from "@/app/api/auth/[...nextauth]/route" + + +interface SendDataRoomInvitationInput { + email: string; + name: string; + dataRoomName: string; + role: string; + dataRoomUrl?: string; +} + +export async function sendDataRoomInvitation(input: SendDataRoomInvitationInput) { + try { + const session = await getServerSession(authOptions) + if (!session?.user?.id) { + throw new Error("인증이 필요합니다.") + } + + const dataRoomUrl = input.dataRoomUrl || `${process.env.NEXT_PUBLIC_APP_URL}/data-rooms`; + + const subject = `You've been invited to access "${input.dataRoomName}" Data Room`; + + await sendEmail({ + to: input.email, + subject, + template: "data-room-invitation", + context: { + name: input.name, + dataRoomName: input.dataRoomName, + role: input.role, + inviterName: session.user.name || "Admin", + dataRoomUrl, + loginUrl: `${process.env.NEXT_PUBLIC_APP_URL}/login`, + }, + }); + + return { success: true, message: "Invitation email sent successfully" }; + } catch (error) { + console.error("Failed to send data room invitation:", error); + return { success: false, message: "Failed to send invitation email" }; + } +} + +// 여러 멤버에게 동시에 이메일 전송 +export async function sendBulkDataRoomInvitations( + members: SendDataRoomInvitationInput[] +) { + try { + const session = await getServerSession(authOptions) + if (!session?.user?.id) { + throw new Error("인증이 필요합니다.") + } + + const results = await Promise.allSettled( + members.map((member) => sendDataRoomInvitation(member)) + ); + + const successful = results.filter((r) => r.status === "fulfilled").length; + const failed = results.filter((r) => r.status === "rejected").length; + + return { + success: true, + message: `Sent ${successful} invitations successfully. ${failed} failed.`, + details: { successful, failed, total: members.length }, + }; + } catch (error) { + console.error("Failed to send bulk invitations:", error); + return { success: false, message: "Failed to send invitations" }; + } +}
\ No newline at end of file |
