Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,834 changes: 1,742 additions & 92 deletions my-app/package-lock.json

Large diffs are not rendered by default.

12 changes: 10 additions & 2 deletions my-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,16 @@
"lint": "next lint"
},
"dependencies": {
"next": "15.3.3",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"next": "15.3.3"
"react-dom": "^19.0.0"
},
"devDependencies": {
"@types/node": "^24.9.1",
"@types/react": "^19.2.2",
"autoprefixer": "^10.4.21",
"postcss": "^8.5.6",
"tailwindcss": "^3.4.14",
"typescript": "^5.9.3"
}
}
5 changes: 0 additions & 5 deletions my-app/pages/_app.js

This file was deleted.

5 changes: 0 additions & 5 deletions my-app/pages/api/hello.js

This file was deleted.

117 changes: 0 additions & 117 deletions my-app/pages/index.js

This file was deleted.

6 changes: 6 additions & 0 deletions my-app/postcss.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
}
Binary file removed my-app/public/favicon.ico
Binary file not shown.
1 change: 0 additions & 1 deletion my-app/public/file.svg

This file was deleted.

1 change: 0 additions & 1 deletion my-app/public/globe.svg

This file was deleted.

1 change: 0 additions & 1 deletion my-app/public/next.svg

This file was deleted.

1 change: 0 additions & 1 deletion my-app/public/vercel.svg

This file was deleted.

1 change: 0 additions & 1 deletion my-app/public/window.svg

This file was deleted.

56 changes: 56 additions & 0 deletions my-app/src/api/api.tsx
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

해당 파일은 index.tsx보다 index.ts 확장자가 더 낫겠군요 !

해당 파일은 jsx 문법을 사용하고 있지 않기에 .ts로 변경하셔도 무방합니다 😉
그럼 확장자만 봐도 JSX 파일인지 아닌지 구분할 수 있겠죠? 😆

Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
const BASE_URL = `${process.env.NEXT_PUBLIC_BASE_URL}/items`;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

items를 지워도 될 것 같아요 !

현재 itmes 외에도 이미지 업로드에 필요한 images API도 있는 것으로 보이는군요 😉

Suggested change
const BASE_URL = `${process.env.NEXT_PUBLIC_BASE_URL}/items`;
const BASE_URL = `${process.env.NEXT_PUBLIC_BASE_URL}`;

위와 같이 사용해볼 수 있습니다 😆


export async function getData() {
try {
const response = await fetch(BASE_URL);
if (!response.ok) {
throw new Error("서버 요청 실패" + response.status);
}

const data = await response.json();
return data;
} catch (error) {
console.log("에러 발생", error);
}
}

export async function postData(todoData: string) {
try {
const response = await fetch(BASE_URL, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ name: todoData }),
});
if (!response.ok) {
throw new Error("서버 요청 실패" + response.status);
}
const data = response.json();
return data;
} catch (error) {
console.log("에러 발생", error);
}
}

export async function patchData(
itemId: number,
updateData: Partial<{ name: string; isCompleted: boolean }>
) {
try {
const response = await fetch(`${BASE_URL}/${itemId}`, {
method: "PATCH",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(updateData),
});
if (!response.ok) {
throw new Error("서버 요청 실패" + response.status);
}
const data = response.json();
return data;
} catch (error) {
console.log("에러 발생", error);
}
}
Comment on lines +36 to +56
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Swagger 문서를 보면 다음과 같이 스키마의 타입을 알 수 있습니다:

image

해당 타입으로 다음과 같은 타입을 정의해볼 수 있겠군요 !

interface Item {
  id: number;
  tenantId: string
  name: string;
  memo: string;
  imageUrl: string;
  isCompleted?: boolean;
}

그리고 요청 타입과 응답 타입을 정의해볼 수 있습니다 !

interface PatchTodoRequest extends Partial<Omit<TodoItem, 'id'>> {}

interface PatchTodoResponse extends TodoItem {}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(이어서) 그리고 API 함수에 다음에 요청과 응답 타입을 정의해볼 수 있습니다 😉

Suggested change
export async function patchData(
itemId: number,
updateData: Partial<{ name: string; isCompleted: boolean }>
) {
try {
const response = await fetch(`${BASE_URL}/${itemId}`, {
method: "PATCH",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(updateData),
});
if (!response.ok) {
throw new Error("서버 요청 실패" + response.status);
}
const data = response.json();
return data;
} catch (error) {
console.log("에러 발생", error);
}
}
export async function patchData(
itemId: number,
updateData: PatchTodoRequest
): Promise<ApiResponse<PatchTodoResponse>> {
try {
const response = await fetch(`${BASE_URL}/${itemId}`, {
method: "PATCH",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(updateData),
});
if (!response.ok) {
throw new Error(`서버 요청 실패: ${response.status}`);
}
const data: PatchTodoResponse = await response.json();
return { data };
} catch (error) {
console.log("에러 발생", error);
return {
error: error instanceof Error ? error.message : "알 수 없는 오류가 발생했습니다"
};
}
}

이렇게 정의해두면 요청 타입과 응답 타입이 필요할 때 export 해볼 수 있으며 타입에 별칭이 있어 가독성도 향상될 수 있겠군요 !

4 changes: 4 additions & 0 deletions my-app/src/assets/done.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions my-app/src/assets/donecheck.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions my-app/src/assets/doneempty.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading