@@ -12,8 +12,10 @@ import { Button } from "@/components/ui/button";
1212import { Input } from "@/components/ui/input" ;
1313import type { ContentTypeOptions } from "@/constants/content" ;
1414import { useCreateConnection , useRemoveConnection } from "@/lib/tanstack/mutation/connection" ;
15+ import { useCreateContent } from "@/lib/tanstack/mutation/topic-content" ;
1516import { useGetTopicById } from "@/lib/tanstack/query/topic" ;
1617import { useMobileMenuStore } from "@/lib/zustand/mobile-menu-store" ;
18+ import type { CategoryContentDTO } from "@/models/content" ;
1719import { infoToast } from "@/utils/toast" ;
1820import {
1921 addEdge ,
@@ -67,6 +69,7 @@ export default function TopicBoardPage({ id, type }: TopicBoardPageProps) {
6769 } = useGetTopicById ( id ) ;
6870 const { mutateAsync : createConnection } = useCreateConnection ( ) ;
6971 const { mutateAsync : removeConnection } = useRemoveConnection ( ) ;
72+ const { mutateAsync : createContent } = useCreateContent ( id ) ;
7073
7174 const [ nodes , setNodes , onNodesChange ] = useNodesState < Node > ( initialNodes ) ;
7275 const [ edges , setEdges , onEdgesChange ] = useEdgesState < Edge > ( [ ] ) ;
@@ -139,6 +142,24 @@ export default function TopicBoardPage({ id, type }: TopicBoardPageProps) {
139142 }
140143 } ;
141144
145+ // 드래그 앤 드롭 핸들러
146+ const onDragOver = ( e : React . DragEvent ) => {
147+ e . preventDefault ( ) ;
148+ e . dataTransfer . dropEffect = "copy" ;
149+ } ;
150+
151+ const onDrop = async ( e : React . DragEvent ) => {
152+ e . preventDefault ( ) ;
153+
154+ const contentData : CategoryContentDTO = JSON . parse ( e . dataTransfer . getData ( "application/json" ) ) ;
155+
156+ // 서버에 콘텐츠 추가
157+ await createContent ( {
158+ topicId : id ,
159+ contentId : contentData . id ,
160+ } ) ;
161+ } ;
162+
142163 const onSearchChange = ( event : React . ChangeEvent < HTMLInputElement > ) => {
143164 setSearchQuery ( event . target . value ) ;
144165 } ;
@@ -261,7 +282,11 @@ export default function TopicBoardPage({ id, type }: TopicBoardPageProps) {
261282 </ div >
262283
263284 { /* Canvas */ }
264- < div className = "relative flex-1 overflow-hidden rounded-r-lg border border-l-0" >
285+ < div
286+ className = "relative flex-1 overflow-hidden rounded-r-lg border border-l-0"
287+ onDragOver = { onDragOver }
288+ onDrop = { onDrop }
289+ >
265290 { isLoading ? (
266291 < div className = "flex h-full flex-col items-center justify-center gap-2" >
267292 < Loader2 className = "text-muted-foreground size-16 animate-spin" />
0 commit comments