-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into Feature/#271-스터디원API
- Loading branch information
Showing
22 changed files
with
665 additions
and
309 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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,42 +1,46 @@ | ||
import { fetcher } from '@/app/api/fetcher'; | ||
import { Document, DocumentType } from '@/types'; | ||
import { UpdateDocument } from '@/containers/study/CreateDocumentModal/type'; | ||
|
||
const documentFetcher = fetcher(); | ||
|
||
const postDocument = (groupType: number, groupId: number, document: Document, files: FormData) => { | ||
const postDocument = (token: string, groupType: string, groupId: number, request: FormData) => | ||
documentFetcher(`/${groupType}/${groupId}/documents`, { | ||
method: 'POST', | ||
body: { document, files }, | ||
body: request, | ||
headers: { | ||
Authorization: `Bearer ${token}`, | ||
}, | ||
}); | ||
}; | ||
|
||
const getDocumentList = (groupType: number, groupId: number, page: number = 0, size: number = 4) => { | ||
documentFetcher(`/${groupType}/${groupId}/documents?page=${page}&size=${size}`, { | ||
method: 'GET', | ||
}); | ||
}; | ||
const getDocumentList = (category: string, teamId: number, page: number, size: number) => | ||
documentFetcher(`/${category}/${teamId}/documents?page=${page}&size=${size}`); | ||
|
||
const getDocument = (documentId: number) => { | ||
const getDocument = (token: string, documentId: number) => | ||
documentFetcher(`/${documentId}`, { | ||
method: 'GET', | ||
headers: { | ||
Authorization: `Bearer ${token}`, | ||
}, | ||
}); | ||
}; | ||
|
||
const putDocument = (documentId: number, title: string, description: string, accessType: DocumentType) => { | ||
const putDocument = ( | ||
token: string, | ||
documentId: number, | ||
request: Pick<UpdateDocument, 'title' | 'description' | 'accessType'>, | ||
) => | ||
documentFetcher(`/${documentId}`, { | ||
method: 'PUT', | ||
body: { | ||
title, | ||
description, | ||
accessType, | ||
body: request, | ||
headers: { | ||
Authorization: `Bearer ${token}`, | ||
}, | ||
}); | ||
}; | ||
|
||
const deleteDocument = (documentId: number) => { | ||
const deleteDocument = (token: string, documentId: number) => | ||
documentFetcher(`/${documentId}`, { | ||
method: 'DELETE', | ||
headers: { | ||
Authorization: `Bearer ${token}`, | ||
}, | ||
}); | ||
}; | ||
|
||
export { postDocument, getDocumentList, getDocument, putDocument, deleteDocument }; |
This file contains 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,36 @@ | ||
'use client'; | ||
|
||
import { Button, Flex, Text } from '@chakra-ui/react'; | ||
import { useState } from 'react'; | ||
|
||
import Documents from '@/containers/document/Documents'; | ||
import CreateDocumentModal from '@/containers/study/CreateDocumentModal'; | ||
import { CreateDocument } from '@/containers/study/CreateDocumentModal/type'; | ||
|
||
const Page = ({ params }: { params: { teamId: number } }) => { | ||
const [openCreateModal, setOpenCreateModal] = useState(false); | ||
const categoryData: CreateDocument = { groupId: params.teamId, groupType: 'teams' }; | ||
return ( | ||
<Flex align="center" direction="column" gap="9" w="100%" p="8"> | ||
<Flex justify="space-between" w="100%"> | ||
<Flex direction="row" gap="2"> | ||
<Text textStyle="bold_2xl">학습자료 갤러리</Text> | ||
</Flex> | ||
<Button color="white" bg="orange_dark" onClick={() => setOpenCreateModal(true)} rounded="full"> | ||
자료 등록 | ||
</Button> | ||
</Flex> | ||
<Documents groupId={params.teamId} category="teams" /> | ||
<CreateDocumentModal | ||
isOpen={openCreateModal} | ||
onClose={() => setOpenCreateModal(false)} | ||
categoryData={categoryData} | ||
// groupId={params.teamId} | ||
// groupType="teams" | ||
category="create" | ||
/> | ||
</Flex> | ||
); | ||
}; | ||
|
||
export default Page; |
This file contains 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 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 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
Oops, something went wrong.