Skip to content

Commit 48aa3a6

Browse files
authored
Merge pull request #169 from boostcampwm-2024/feature-fe-#167
페이지 생성 시, 생성된 페이지 ID로 에디터 열기
2 parents 4985b4b + 917650a commit 48aa3a6

File tree

2 files changed

+22
-16
lines changed

2 files changed

+22
-16
lines changed

frontend/src/api/page.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ export interface PagesResponse {
3030
pages: Omit<Page, "content">[];
3131
}
3232

33+
interface CreatePageResponse {
34+
message: string;
35+
pageId: number;
36+
}
37+
3338
export const getPage = async (id: number) => {
3439
const url = `/page/${id}`;
3540

@@ -47,7 +52,7 @@ export const getPages = async () => {
4752
export const createPage = async (pageData: CreatePageRequest) => {
4853
const url = `/page`;
4954

50-
const res = await Post<null, CreatePageRequest>(url, pageData);
55+
const res = await Post<CreatePageResponse, CreatePageRequest>(url, pageData);
5156
return res.data;
5257
};
5358

frontend/src/components/sidebar/Tools.tsx

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,22 @@ export default function Tools() {
1818
<Button
1919
className="flex flex-row items-center gap-1 rounded-sm px-2 py-1 font-medium hover:bg-neutral-100"
2020
onClick={() => {
21-
createMutation.mutate({
22-
title: "제목 없음",
23-
content: {
24-
type: "doc",
25-
content: [
26-
{
27-
type: "paragraph",
28-
content: [{ type: "text", text: "" }],
29-
},
30-
],
31-
},
32-
x: 0,
33-
y: 0,
34-
});
35-
setCurrentPage(pages[pages.length - 1].id);
21+
createMutation
22+
.mutateAsync({
23+
title: "제목 없음",
24+
content: {
25+
type: "doc",
26+
content: [
27+
{
28+
type: "paragraph",
29+
content: [{ type: "text", text: "" }],
30+
},
31+
],
32+
},
33+
x: 0,
34+
y: 0,
35+
})
36+
.then((res) => setCurrentPage(res.pageId));
3637
}}
3738
>
3839
<div>

0 commit comments

Comments
 (0)