-
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
Merged
tkyoun0421
merged 5 commits into
amicable-development-center:develop
from
czmcm5:feat/firebase/czmcm5
Jun 24, 2025
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
7448603
feat: getProjectList, insertProjectItem api 추가
czmcm5 8b9e1c8
feat: getProjectList, insertProjectItem api 추가
czmcm5 14d81dd
chore: features/projects 생성
czmcm5 0809a85
chore: projectApi 컨벤션에 맞게 수정
czmcm5 42361f8
chore: entities 하위 projectApi 컨벤션에 맞게 수정
czmcm5 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| import { collection, getDocs } from "firebase/firestore/lite"; | ||
|
|
||
| import type { ProjectListRes } from "@entities/projects/types/projects"; | ||
|
|
||
| import { db } from "@shared/firebase/firebase"; | ||
|
|
||
| /** firebase project 목록 불러오기 */ | ||
| export const getProjectList = async (): 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 []; | ||
| } | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| import { useQuery, type UseQueryResult } from "@tanstack/react-query"; | ||
|
|
||
| import { getProjectList } from "@entities/projects/api/projectsAPi"; | ||
| import type { ProjectListRes } from "@entities/projects/types/projects"; | ||
|
|
||
| const useProjectList = (): UseQueryResult<ProjectListRes[]> => { | ||
| return useQuery({ | ||
| queryKey: ["project-list"], | ||
| queryFn: getProjectList, | ||
| }); | ||
| }; | ||
|
|
||
| export default useProjectList; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| export interface ProjectItemInsertReq { | ||
| userId: string; // 작성자 id | ||
| userName: string; // 작성사 이름 | ||
| status: "모집중" | "모집완료"; | ||
| title: string; // 프로젝트 제목 | ||
| oneLineInfo: string; // 프로젝트 한줄 소개 | ||
| simpleInfo: string; // 프로젝트 간단 소개 | ||
| techStack: string[]; // 기술 스택 | ||
| teamSize: number; // 팀 규모 | ||
| expectedPeriod: string; // 예상기간 | ||
| description: string; // 상세 설명 | ||
| workflow: string; // 진행방식 | ||
| requirements: string[]; // 지원 요구사항 | ||
| preferentialTreatment: string[]; // 우대사항 | ||
| positions: Positions[]; // 모집 포지션 | ||
| } | ||
|
|
||
| interface Positions { | ||
| position: string; | ||
| count: number; | ||
| experience: string; // 경력 | ||
| } | ||
|
|
||
| export interface ProjectListRes extends ProjectItemInsertReq { | ||
| id: string; // firebase 문서 id | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| import { addDoc, collection, doc, setDoc } from "firebase/firestore/lite"; | ||
|
|
||
| import type { ProjectItemInsertReq } from "@entities/projects/types/projects"; | ||
|
|
||
| import { db } from "@shared/firebase/firebase"; | ||
|
|
||
| /** firebase projects에 item 등록 */ | ||
| export const insertProjectItem = async ( | ||
| 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: "프로젝트 등록에 실패하였습니다.", | ||
| }; | ||
| } | ||
| }; | ||
|
|
||
| /** firebase projects에 item 수정 */ | ||
| export const updateProjectItem = async (): Promise<void> => { | ||
| return; | ||
| const docRef = doc(db, "coments", "test"); | ||
| await setDoc(docRef, { title: "" }, { merge: true }); | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| import { insertProjectItem } from "@features/projects/api/projdectsApi"; | ||
|
|
||
| import type { ProjectItemInsertReq } from "@entities/projects/types/projects"; | ||
|
|
||
| const useProjectInsert = (): { submit: () => Promise<void> } => { | ||
| const submit = async (): Promise<void> => { | ||
| const res = await insertProjectItem(TestData); | ||
|
|
||
| if (res.success) { | ||
| alert(res.message); | ||
| } else { | ||
| alert(res.message); | ||
| } | ||
| }; | ||
|
|
||
| return { submit }; | ||
| }; | ||
|
|
||
| export default useProjectInsert; | ||
|
|
||
| // 테스트용 form 입니다. | ||
| const TestData: ProjectItemInsertReq = { | ||
| userId: "user1234", | ||
| userName: "홍길동", | ||
| status: "모집중", | ||
| title: "AI 기반 음악 추천 서비스 개발", | ||
| oneLineInfo: "AI로 사용자 취향을 분석하는 음악 추천 프로젝트입니다.", | ||
| simpleInfo: "음악 취향 데이터를 기반으로 개인화 추천 시스템을 구현합니다.", | ||
| techStack: ["React", "Node.js", "Python", "TensorFlow", "MongoDB"], | ||
| teamSize: 5, | ||
| expectedPeriod: "3개월", | ||
| description: | ||
| "이 프로젝트는 사용자의 음악 청취 데이터를 수집하여, AI 알고리즘을 통해 개인화된 추천 서비스를 제공하는 웹 앱을 개발하는 것이 목표입니다.", | ||
| workflow: "온라인 협업 (Zoom, GitHub, Notion 사용)", | ||
| requirements: [ | ||
| "주 2회 이상 정기 미팅 참석 가능", | ||
| "기본적인 Git 사용 경험", | ||
| "성실한 커뮤니케이션", | ||
| ], | ||
| preferentialTreatment: [ | ||
| "음악 도메인에 관심 있는 분", | ||
| "TensorFlow 사용 경험", | ||
| "UX/UI에 관심 있는 프론트엔드 개발자", | ||
| ], | ||
| positions: [ | ||
| { | ||
| position: "Frontend Developer", | ||
| count: 2, | ||
| experience: "1년 이상", | ||
| }, | ||
| { | ||
| position: "Backend Developer", | ||
| count: 1, | ||
| experience: "3년 이상", | ||
| }, | ||
| { | ||
| position: "AI Engineer", | ||
| count: 1, | ||
| experience: "1년 이상", | ||
| }, | ||
| ], | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,16 @@ | ||
| import type { JSX } from "react"; | ||
| import { type JSX } from "react"; | ||
|
|
||
| import useProjectInsert from "@features/projects/hook/useProjectInsert"; | ||
|
|
||
| const ProjectInsertPage = (): JSX.Element => { | ||
| return <div>ProjectInsertPage</div>; | ||
| const { submit } = useProjectInsert(); | ||
|
|
||
| return ( | ||
| <div> | ||
| ProjectInsertPage | ||
| <button onClick={submit}>Firebase 임시 등록버튼</button> | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| export default ProjectInsertPage; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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.
넵 답변 감사합니다 다빈님 👍👍👍