Skip to content

Commit

Permalink
Feature/#228 팀페이지, 스터디 페이지 학습자료 crud (#252)
Browse files Browse the repository at this point in the history
* feat : study api 추가

* feat : api fetch 이름 삭제

* feat : 학습자료 crud api 제작

* feat : Document 타입지정

* feat : documentAccessType, documentType 형식 지정

---------

Co-authored-by: 김문경 <>
  • Loading branch information
mun-kyeong authored Jun 29, 2024
1 parent 692c92d commit 2bcc55e
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
42 changes: 42 additions & 0 deletions src/app/api/document.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { fetcher } from '@/app/api/fetcher';
import { Document, DocumentType } 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: DocumentType) => {
documentFetcher(`/${documentId}`, {
method: 'PUT',
body: {
title,
description,
accessType,
},
});
};

const deleteDocument = (documentId: number) => {
documentFetcher(`/${documentId}`, {
method: 'DELETE',
});
};

export { postDocument, getDocumentList, getDocument, putDocument, deleteDocument };
13 changes: 13 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,16 @@ export interface Curriculum {
itemOrder: number;
isCompleted?: boolean;
}

export interface Document {
title: string;
description: string;
accessType: DocumentAccessType;
type: DocumentType;
url: string;
uploaderId: number;
}

export type DocumentAccessType = 'TEAM' | 'STUDY' | 'ALL';

export type DocumentType = 'DOCUMENT' | 'IMAGE' | 'URL';

0 comments on commit 2bcc55e

Please sign in to comment.