Skip to content

Commit 5984352

Browse files
committed
fix: merge 충돌 해결
1 parent 10f78c0 commit 5984352

File tree

4 files changed

+16
-49
lines changed

4 files changed

+16
-49
lines changed

frontend/src/api/page.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ export const deletePage = async (id: number) => {
4848
return res.data;
4949
};
5050

51-
export const updatePage = async (id: number, pageData: JSONContent) => {
51+
export const updatePage = async (id: number, pageData: PageRequest) => {
5252
const url = `/page/${id}`;
5353

54-
const res = await Patch<null, JSONContent>(url, pageData);
54+
const res = await Patch<null, PageRequest>(url, pageData);
5555
return res.data;
5656
};

frontend/src/components/canvas/index.tsx

Lines changed: 6 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -13,46 +13,13 @@ import {
1313
ConnectionMode,
1414
type OnConnect,
1515
type Node,
16-
type Edge,
1716
} from "@xyflow/react";
1817

1918
import "@xyflow/react/dist/style.css";
2019

2120
import { useEffect } from "react";
2221
import { usePages } from "@/hooks/usePages";
23-
import { type NoteNodeType, NoteNode } from "./NoteNode";
24-
25-
// 테스트용 초기값
26-
const initialNodes: NoteNodeType[] = [
27-
{
28-
id: "1",
29-
position: { x: 100, y: 100 },
30-
type: "note",
31-
data: {
32-
id: 0,
33-
title: "Node 1",
34-
},
35-
},
36-
{
37-
id: "2",
38-
position: { x: 400, y: 200 },
39-
type: "note",
40-
data: {
41-
id: 1,
42-
title: "Node 2",
43-
},
44-
},
45-
];
46-
47-
const initialEdges: Edge[] = [
48-
{
49-
id: "e1-2",
50-
source: "1",
51-
target: "2",
52-
sourceHandle: "top",
53-
targetHandle: "left",
54-
},
55-
];
22+
import { NoteNode } from "./NoteNode";
5623

5724
const proOptions = { hideAttribution: true };
5825

@@ -61,11 +28,10 @@ interface CanvasProps {
6128
}
6229

6330
export default function Canvas({ className }: CanvasProps) {
64-
const [nodes, setNodes, onNodesChange] = useNodesState<Node>(initialNodes);
65-
const [edges, setEdges, onEdgesChange] = useEdgesState(initialEdges);
31+
const [nodes, setNodes, onNodesChange] = useNodesState<Node>([]);
32+
const [edges, setEdges, onEdgesChange] = useEdgesState([]);
6633

67-
const { data } = usePages();
68-
const pages = data?.data;
34+
const { data: pages } = usePages();
6935

7036
useEffect(() => {
7137
if (!pages) {
@@ -75,7 +41,8 @@ export default function Canvas({ className }: CanvasProps) {
7541
const newNodes = pages.map((page, index) => ({
7642
id: page.id.toString(),
7743
position: { x: 100 * index, y: 100 },
78-
data: { label: page.title, id: page.id },
44+
data: { title: page.title, id: page.id },
45+
type: "note",
7946
}));
8047
setNodes(newNodes);
8148
}, [pages, setNodes]);

frontend/src/components/editor/index.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ import { ColorSelector } from "./selectors/color-selector";
2525
import { useDebouncedCallback } from "use-debounce";
2626
import { useUpdatePage } from "@/hooks/usePages";
2727

28-
import { useUpdatePage } from "@/hooks/usePages";
29-
3028
const extensions = [...defaultExtensions, slashCommand];
3129

3230
interface EditorProp {
@@ -40,23 +38,26 @@ const Editor = ({ pageId, initialValue }: EditorProp) => {
4038
const [initialContent, setInitialContent] = useState<null | JSONContent>(
4139
initialValue === undefined ? null : initialValue,
4240
);
43-
const updateMutation = useUpdatePage(pageId);
41+
42+
const updatePageMutation = useUpdatePage(pageId);
4443

4544
const [openNode, setOpenNode] = useState(false);
4645
const [openColor, setOpenColor] = useState(false);
4746
const [openLink, setOpenLink] = useState(false);
4847
const [saveStatus, setSaveStatus] = useState("Saved");
4948

50-
const updatePageMutation = useUpdatePage();
51-
5249
const debouncedUpdates = useDebouncedCallback(
5350
async (editor: EditorInstance) => {
5451
if (pageId === undefined) return;
5552

5653
const json = editor.getJSON();
54+
5755
const response = await updatePageMutation.mutateAsync({
5856
id: pageId,
59-
pageData: json,
57+
pageData: {
58+
title: "제목 없음",
59+
content: json,
60+
},
6061
});
6162
if (response) {
6263
setSaveStatus("Saved");

frontend/src/hooks/usePages.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import {
1414
getPage,
1515
CreatePageRequest,
1616
} from "@/api/page";
17-
import { JSONContent } from "novel";
1817

1918
export const usePage = (currentPage: number | null) => {
2019
const { data, isError } = useQuery({
@@ -61,7 +60,7 @@ export const useUpdatePage = (pageId: number) => {
6160
const queryClient = useQueryClient();
6261

6362
return useMutation({
64-
mutationFn: ({ id, pageData }: { id: number; pageData: JSONContent }) =>
63+
mutationFn: ({ id, pageData }: { id: number; pageData: PageRequest }) =>
6564
updatePage(id, pageData),
6665
onSuccess: () => {
6766
queryClient.invalidateQueries({ queryKey: ["page", pageId] });

0 commit comments

Comments
 (0)