From b3156528432d39345ad86cb67ca0f39b164ea0ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=80=E1=85=B5=E1=86=B7=E1=84=86=E1=85=AE=E1=86=AB?= =?UTF-8?q?=E1=84=80=E1=85=A7=E1=86=BC?= <> Date: Thu, 30 May 2024 18:57:05 +0900 Subject: [PATCH 1/6] =?UTF-8?q?feat=20:=20study=20api=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package-lock.json | 20 ++++++++++---------- src/app/api/study.ts | 2 ++ 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/package-lock.json b/package-lock.json index 52fa07ec..80b16fcd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -28,8 +28,8 @@ "@swc-jotai/react-refresh": "^0.1.0", "@types/node": "^20", "@types/react": "^18", - "@types/react-datepicker": "^6.2.0", "@types/react-beautiful-dnd": "^13.1.8", + "@types/react-datepicker": "^6.2.0", "@types/react-dom": "^18", "eslint": "^8.56.0", "eslint-config-airbnb": "^19.0.4", @@ -1992,6 +1992,15 @@ "csstype": "^3.0.2" } }, + "node_modules/@types/react-beautiful-dnd": { + "version": "13.1.8", + "resolved": "https://registry.npmjs.org/@types/react-beautiful-dnd/-/react-beautiful-dnd-13.1.8.tgz", + "integrity": "sha512-E3TyFsro9pQuK4r8S/OL6G99eq7p8v29sX0PM7oT8Z+PJfZvSQTx4zTQbUJ+QZXioAF0e7TGBEcA1XhYhCweyQ==", + "dev": true, + "dependencies": { + "@types/react": "*" + } + }, "node_modules/@types/react-datepicker": { "version": "6.2.0", "resolved": "https://registry.npmjs.org/@types/react-datepicker/-/react-datepicker-6.2.0.tgz", @@ -2003,15 +2012,6 @@ "date-fns": "^3.3.1" } }, - "node_modules/@types/react-beautiful-dnd": { - "version": "13.1.8", - "resolved": "https://registry.npmjs.org/@types/react-beautiful-dnd/-/react-beautiful-dnd-13.1.8.tgz", - "integrity": "sha512-E3TyFsro9pQuK4r8S/OL6G99eq7p8v29sX0PM7oT8Z+PJfZvSQTx4zTQbUJ+QZXioAF0e7TGBEcA1XhYhCweyQ==", - "dev": true, - "dependencies": { - "@types/react": "*" - } - }, "node_modules/@types/react-dom": { "version": "18.2.18", "resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-18.2.18.tgz", diff --git a/src/app/api/study.ts b/src/app/api/study.ts index a588d2fd..0cd30cf5 100644 --- a/src/app/api/study.ts +++ b/src/app/api/study.ts @@ -8,6 +8,7 @@ const postStudyFetch = (teamId: number, study: CreateStudyDto) => method: 'POST', body: study, }); +const getStudyAllFetch = (studyId: number) => studyFetcher(`/studies/${studyId}/all`); const getStudyFetch = (studyId: number) => studyFetcher(`/studies/${studyId}`); @@ -49,6 +50,7 @@ const getStudyMembersFetch = (studyId: number) => studyFetcher(`/studies/${study export { postStudyFetch, getStudyFetch, + getStudyAllFetch, deleteStudyFetch, putEditStudyFetch, patchTerminateStudyFetch, From 02855c953f8fc354bd9bf1656639643ecbf73393 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=80=E1=85=B5=E1=86=B7=E1=84=86=E1=85=AE=E1=86=AB?= =?UTF-8?q?=E1=84=80=E1=85=A7=E1=86=BC?= <> Date: Thu, 30 May 2024 20:00:37 +0900 Subject: [PATCH 2/6] =?UTF-8?q?feat=20:=20api=20fetch=20=EC=9D=B4=EB=A6=84?= =?UTF-8?q?=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/api/study.ts | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/src/app/api/study.ts b/src/app/api/study.ts index 0cd30cf5..f3d999fa 100644 --- a/src/app/api/study.ts +++ b/src/app/api/study.ts @@ -3,60 +3,60 @@ import { CreateStudyDto, EditStudyDto } from '@/types'; const studyFetcher = fetcher(); -const postStudyFetch = (teamId: number, study: CreateStudyDto) => +const postStudy = (teamId: number, study: CreateStudyDto) => studyFetcher(`/teams/${teamId}/studies`, { method: 'POST', body: study, }); -const getStudyAllFetch = (studyId: number) => studyFetcher(`/studies/${studyId}/all`); +const getStudyAll = (studyId: number) => studyFetcher(`/studies/${studyId}/all`); -const getStudyFetch = (studyId: number) => studyFetcher(`/studies/${studyId}`); +const getStudy = (studyId: number) => studyFetcher(`/studies/${studyId}`); -const deleteStudyFetch = (studyId: number) => studyFetcher(`/studies/${studyId}`, { method: 'DELETE' }); +const deleteStudy = (studyId: number) => studyFetcher(`/studies/${studyId}`, { method: 'DELETE' }); -const putEditStudyFetch = (studyId: number, study: EditStudyDto) => +const putEditStudy = (studyId: number, study: EditStudyDto) => studyFetcher(`/studies/${studyId}`, { method: 'PUT', body: study, }); -const patchTerminateStudyFetch = (studyId: number) => +const patchTerminateStudy = (studyId: number) => studyFetcher(`/studies/${studyId}/termination`, { method: 'PATCH', }); -const patchStudyStatusFetch = (studyId: number, status: string) => +const patchStudyStatus = (studyId: number, status: string) => studyFetcher(`/studies/${studyId}/status?status=${status}`, { method: 'PATCH', }); -const postStudyMemberFetch = (studyId: number, userId: number) => +const postStudyMember = (studyId: number, userId: number) => studyFetcher(`/studies/${studyId}/members/${userId}`, { method: 'POST', }); -const deleteStudyMemberFetch = (studyId: number, userId: number) => +const deleteStudyMember = (studyId: number, userId: number) => studyFetcher(`/studies/${studyId}/members/${userId}`, { method: 'DELETE', }); -const leaveStudyFetch = (studyId: number) => +const leaveStudy = (studyId: number) => studyFetcher(`/studies/${studyId}/members`, { method: 'DELETE', }); -const getStudyMembersFetch = (studyId: number) => studyFetcher(`/studies/${studyId}/members`); +const getStudyMembers = (studyId: number) => studyFetcher(`/studies/${studyId}/members`); export { - postStudyFetch, - getStudyFetch, - getStudyAllFetch, - deleteStudyFetch, - putEditStudyFetch, - patchTerminateStudyFetch, - patchStudyStatusFetch, - postStudyMemberFetch, - deleteStudyMemberFetch, - leaveStudyFetch, - getStudyMembersFetch, + postStudy, + getStudy, + getStudyAll, + deleteStudy, + putEditStudy, + patchTerminateStudy, + patchStudyStatus, + postStudyMember, + deleteStudyMember, + leaveStudy, + getStudyMembers, }; From aec82f5fdb7e78817470cec001f41d7f53bb08a5 Mon Sep 17 00:00:00 2001 From: munkyeong Date: Sat, 29 Jun 2024 20:52:13 +0900 Subject: [PATCH 3/6] =?UTF-8?q?feat=20:=20=ED=95=99=EC=8A=B5=EC=9E=90?= =?UTF-8?q?=EB=A3=8C=20crud=20api=20=EC=A0=9C=EC=9E=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/api/document.ts | 42 +++++++++++++++++++++++++++++++++++++++++ src/app/api/study.ts | 8 -------- src/types.ts | 9 +++++++++ 3 files changed, 51 insertions(+), 8 deletions(-) create mode 100644 src/app/api/document.ts diff --git a/src/app/api/document.ts b/src/app/api/document.ts new file mode 100644 index 00000000..249852f2 --- /dev/null +++ b/src/app/api/document.ts @@ -0,0 +1,42 @@ +import { fetcher } from '@/app/api/fetcher'; +import { Document } from '@/types'; + +const documentFetcher = fetcher(); + +const postDocument = (groupType: number, groupId: number, document: Document, files: FormData) => { + documentFetcher(`/${groupType}/${groupId}/documents`, { + method: 'POST', + body: { document, files }, + }); +}; + +const getDocumentList = (groupType: number, groupId: number, page: number = 0, size: number = 4) => { + documentFetcher(`/${groupType}/${groupId}/documents?page=${page}&size=${size}`, { + method: 'GET', + }); +}; + +const getDocument = (documentId: number) => { + documentFetcher(`/${documentId}`, { + method: 'GET', + }); +}; + +const putDocument = (documentId: number, title: string, description: string, accessType: string) => { + documentFetcher(`/${documentId}`, { + method: 'PUT', + body: { + title, + description, + accessType, + }, + }); +}; + +const deleteDocument = (documentId: number) => { + documentFetcher(`/${documentId}`, { + method: 'DELETE', + }); +}; + +export { postDocument, getDocumentList, getDocument, putDocument, deleteDocument }; diff --git a/src/app/api/study.ts b/src/app/api/study.ts index 790c07bb..a495844d 100644 --- a/src/app/api/study.ts +++ b/src/app/api/study.ts @@ -3,41 +3,33 @@ import { CreateStudyDto, Curriculum, EditStudyDto } from '@/types'; const studyFetcher = fetcher(); -const postStudy = (teamId: number, study: CreateStudyDto) => const postStudy = (teamId: number, study: CreateStudyDto) => studyFetcher(`/teams/${teamId}/studies`, { method: 'POST', body: study, }); const getStudyAll = (studyId: number) => studyFetcher(`/studies/${studyId}/all`); -const getStudyAll = (studyId: number) => studyFetcher(`/studies/${studyId}/all`); -const getStudy = (studyId: number) => studyFetcher(`/studies/${studyId}`); const getStudy = (studyId: number) => studyFetcher(`/studies/${studyId}`); -const deleteStudy = (studyId: number) => studyFetcher(`/studies/${studyId}`, { method: 'DELETE' }); const deleteStudy = (studyId: number) => studyFetcher(`/studies/${studyId}`, { method: 'DELETE' }); -const putEditStudy = (studyId: number, study: EditStudyDto) => const putEditStudy = (studyId: number, study: EditStudyDto) => studyFetcher(`/studies/${studyId}`, { method: 'PUT', body: study, }); -const patchTerminateStudy = (studyId: number) => const patchTerminateStudy = (studyId: number) => studyFetcher(`/studies/${studyId}/termination`, { method: 'PATCH', }); -const patchStudyStatus = (studyId: number, status: string) => const patchStudyStatus = (studyId: number, status: string) => studyFetcher(`/studies/${studyId}/status?status=${status}`, { method: 'PATCH', }); -const postStudyMember = (studyId: number, userId: number) => const postStudyMember = (studyId: number, userId: number) => studyFetcher(`/studies/${studyId}/members/${userId}`, { method: 'POST', diff --git a/src/types.ts b/src/types.ts index efc7d89d..f6cba0a3 100644 --- a/src/types.ts +++ b/src/types.ts @@ -77,3 +77,12 @@ export interface Curriculum { itemOrder: number; isCompleted?: boolean; } + +export interface Document { + title: string; + description: string; + accessType: string; + type: string; + url: string; + uploaderId: number; +} From f90315f573f53d6e611bdd7a73a2b4ef3b26daf0 Mon Sep 17 00:00:00 2001 From: mun-kyeong <96461334+mun-kyeong@users.noreply.github.com> Date: Sat, 29 Jun 2024 21:34:13 +0900 Subject: [PATCH 4/6] =?UTF-8?q?feat=20:=20Document=20=ED=83=80=EC=9E=85?= =?UTF-8?q?=EC=A7=80=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/api/document.ts | 4 ++-- src/types.ts | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/app/api/document.ts b/src/app/api/document.ts index 249852f2..c1968ec5 100644 --- a/src/app/api/document.ts +++ b/src/app/api/document.ts @@ -1,5 +1,5 @@ import { fetcher } from '@/app/api/fetcher'; -import { Document } from '@/types'; +import { Document, DocumentType } from '@/types'; const documentFetcher = fetcher(); @@ -22,7 +22,7 @@ const getDocument = (documentId: number) => { }); }; -const putDocument = (documentId: number, title: string, description: string, accessType: string) => { +const putDocument = (documentId: number, title: string, description: string, accessType: DocumentType) => { documentFetcher(`/${documentId}`, { method: 'PUT', body: { diff --git a/src/types.ts b/src/types.ts index f6cba0a3..fa11a1ca 100644 --- a/src/types.ts +++ b/src/types.ts @@ -86,3 +86,5 @@ export interface Document { url: string; uploaderId: number; } + +export type DocumentType = 'TEAM' | 'STUDY' | 'ALL'; From 5c42593c890b1d551541fc8ceee571ec123bd1e6 Mon Sep 17 00:00:00 2001 From: mun-kyeong <96461334+mun-kyeong@users.noreply.github.com> Date: Sat, 29 Jun 2024 21:38:26 +0900 Subject: [PATCH 5/6] =?UTF-8?q?feat=20:=20documentAccessType,=20documentTy?= =?UTF-8?q?pe=20=ED=98=95=EC=8B=9D=20=EC=A7=80=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/types.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/types.ts b/src/types.ts index fa11a1ca..863f4410 100644 --- a/src/types.ts +++ b/src/types.ts @@ -81,10 +81,12 @@ export interface Curriculum { export interface Document { title: string; description: string; - accessType: string; - type: string; + accessType: DocumentAccessType; + type: DocumentType; url: string; uploaderId: number; } -export type DocumentType = 'TEAM' | 'STUDY' | 'ALL'; +export type DocumentAccessType = 'TEAM' | 'STUDY' | 'ALL'; + +export type DocumentType = 'FILE' | 'IMAGE' | 'URL'; From 163f3180dc996677be9e9b244a6b94364a29ba46 Mon Sep 17 00:00:00 2001 From: mun-kyeong <96461334+mun-kyeong@users.noreply.github.com> Date: Sat, 29 Jun 2024 21:52:43 +0900 Subject: [PATCH 6/6] =?UTF-8?q?feat=20:=20type=20=EC=88=98=EC=A0=95=20(DOC?= =?UTF-8?q?UMENT)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/types.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/types.ts b/src/types.ts index 863f4410..d09b7190 100644 --- a/src/types.ts +++ b/src/types.ts @@ -89,4 +89,4 @@ export interface Document { export type DocumentAccessType = 'TEAM' | 'STUDY' | 'ALL'; -export type DocumentType = 'FILE' | 'IMAGE' | 'URL'; +export type DocumentType = 'DOCUMENT' | 'IMAGE' | 'URL';