-
Notifications
You must be signed in to change notification settings - Fork 3
feat: getProjectList, insertProjectItem api 추가 #22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: getProjectList, insertProjectItem api 추가 #22
Conversation
getProjectList: 메인홈에서 프로젝트 목록을 불러옵니다. insertProjectItem: 등록 페이지에서 프로젝트를 등록합니다.
getProjectList: 메인홈에서 프로젝트 목록을 불러옵니다. insertProjectItem: 등록 페이지에서 프로젝트를 등록합니다.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
고생하셨습니다 :) 컨벤션 관련해서 수정 한번 부탁드리겠습니다!
| export async function getProjectList(): Promise<ProjectListRes[]> { | ||
| try { | ||
| const listRef = collection(db, "projects"); | ||
| const querySnapshot = await getDocs(listRef); | ||
|
|
||
| const posts = querySnapshot.docs.map((doc) => ({ | ||
| id: doc.id, | ||
| ...doc.data(), | ||
| })); | ||
|
|
||
| return posts as ProjectListRes[]; | ||
| } catch (err) { | ||
| console.log(err); | ||
| return []; | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
요고 컨벤션에 맞게 export const getProjectList = async() => {};
방식으로 부탁드리겠습니다 🙇
| export async function insertProjectItem( | ||
| projectItem: ProjectItemInsertReq | ||
| ): Promise<{ success: boolean; message: string; id?: string }> { | ||
| try { | ||
| const postsRef = collection(db, "projects"); | ||
| const docRef = await addDoc(postsRef, projectItem); | ||
|
|
||
| return { | ||
| success: true, | ||
| message: "프로젝트가 성공적으로 등록되었습니다.", | ||
| id: docRef.id, | ||
| }; | ||
| } catch (err) { | ||
| console.log(err); | ||
| return { | ||
| success: false, | ||
| message: "프로젝트 등록에 실패하였습니다.", | ||
| }; | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
요기도 마찬가지로 부탁드리겠습니다 🙇
| if (res.success) { | ||
| alert(res.message); | ||
| } else { | ||
| alert(res.message); | ||
| } | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
성공하거나 안하거나 같은 로직인걸로 보이는데 혹시 어떤 이유가 있으실까요??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
저는 이 훅에 대해 더이상 건들지 않고 민영님께 인계 할 생각이었으므로
이후에 성공 실패에 따라 다른 처리가 들어갈 수 도 있으니 그저 가시성을 위해 나눠놓았습니다.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
넵 답변 감사합니다 다빈님 👍👍👍
|
수고하셨어용 !! |
80a17c1
into
amicable-development-center:develop
개요
firebase의 projects 데이터를 조회, 저장 함수를 간단하게 추가하였습니다.
변경 사항
구현 내용
개발 후기 및 개선사항
이번 작업에서 배운 점
어려웠던 점 / 에로사항
다음에 개선하고 싶은 점
팀원들과 공유하고 싶은 팁