Skip to content
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

학습자료 crud api 연결 #297

Merged
merged 30 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
1df53bd
feat : 버튼 클릭시 모달 오픈 연결
mun-kyeong Jun 29, 2024
a3b437c
feat : 파일 받아오는거까지 확인
mun-kyeong Jun 29, 2024
183f18b
Merge branch 'develop' of https://github.com/BDD-CLUB/01-doo-re-front…
mun-kyeong Jun 29, 2024
ac6d9fb
feat : api 전송 확인
mun-kyeong Jul 10, 2024
ffe9028
Merge branch 'develop' of https://github.com/BDD-CLUB/01-doo-re-front…
mun-kyeong Jul 10, 2024
6c7679b
feat : 팀 페이지에서 카테고리 변경시 데이터 받아와지지 않는 문제 해결
mun-kyeong Jul 10, 2024
6ed6019
feat : 주석처리
mun-kyeong Jul 10, 2024
4feb2e7
feat : img, url 전송 확인, 근데 file 전송 실패 이유는 잘 모르겠음...
mun-kyeong Jul 10, 2024
5e72b74
feat : 학습자료카드 bookmark정보 삭제 / mocks와 DTO 형식 통일
mun-kyeong Jul 11, 2024
840cdb6
feat : getDocumentList 성공
mun-kyeong Jul 11, 2024
d02802a
feat : 학습자료 post teamId 적용
mun-kyeong Jul 11, 2024
de259a3
feat : 팀페이지 + 버튼 누르면 모달창 오픈
mun-kyeong Jul 11, 2024
2f7c960
feat : 학습자료 상세 페이지 get 완료
mun-kyeong Jul 16, 2024
0dd5395
Merge branch 'develop' of https://github.com/BDD-CLUB/01-doo-re-front…
mun-kyeong Jul 16, 2024
eb2f30e
refactor : 주석정리
mun-kyeong Jul 16, 2024
8875c1e
feat : 스터디 / 팀별 학습자료 post, get 확인
mun-kyeong Jul 17, 2024
c9df590
feat : 미리보기 img 준비
mun-kyeong Jul 17, 2024
1b3b0c2
feat : 팀 페이지 학습자료 페이지 생성 + delete api 전송 확인
mun-kyeong Jul 17, 2024
7547fc3
api : getDocumentList api 수정 반영 완료 + page navigator 작동 확인
mun-kyeong Jul 18, 2024
e3a892c
feat : put Document api 정리
mun-kyeong Jul 18, 2024
08bdc27
Merge branch 'develop' of https://github.com/BDD-CLUB/01-doo-re-front…
mun-kyeong Jul 20, 2024
488f10c
feat : 수정 버튼 클릭시 수정 모달 open
mun-kyeong Jul 20, 2024
db139dd
feat : 학습자료 api 무한요청 => useEffect 수정
mun-kyeong Jul 20, 2024
011b39c
feat : console 정리
mun-kyeong Jul 20, 2024
4a9f7c5
feat : put 수정 확인 : 화면 update 필요
mun-kyeong Jul 20, 2024
8078b03
feat : 미리보기 이미지 적용
mun-kyeong Jul 21, 2024
82794bf
feat : mocks 수정
mun-kyeong Jul 21, 2024
5d59823
refactor : 미리보기 이미지 변경 및 디자인 수정
mun-kyeong Aug 15, 2024
129ff17
refactor : 수정시 이전 기록 가져오기
mun-kyeong Aug 15, 2024
c2563e3
Merge branch 'develop' of https://github.com/BDD-CLUB/01-doo-re-front…
mun-kyeong Aug 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified public/png/file.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/png/folder.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/png/link.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/components/DocumentCard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const DocumentCard = ({ id, title, description, date, setReload, files, type }:
return S3_URL(files[0].url);
}
if (type === 'URL') {
return files[0]?.url;
return '/png/link.png';
}
if (type === 'DOCUMENT') {
if (files.length === 1) {
Expand Down
50 changes: 48 additions & 2 deletions src/containers/study/CreateDocumentModal/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use client';

import { Divider, Flex, Input, Text, Textarea, Button } from '@chakra-ui/react';
import { ChangeEvent, useRef, useState } from 'react';
import { ChangeEvent, useEffect, useRef, useState } from 'react';
import { BiFile, BiImage, BiTrash } from 'react-icons/bi';
import { BsLink45Deg } from 'react-icons/bs';

Expand All @@ -14,6 +14,7 @@ import color from '@/constants/color';
import { DocumentModalProps, DocumentList, CreateDocument } from '@/containers/study/CreateDocumentModal/type';
import { useMutateWithToken } from '@/hooks/useFetchWithToken';
import useGetUser from '@/hooks/useGetUser';
import textStyles from '@/theme/foundations/textStyles';
import { Document, DocumentAccessType, DocumentDetail, DocumentType } from '@/types';

const DocumentBoxIcon = {
Expand Down Expand Up @@ -165,6 +166,14 @@ const CreateDocumentModal = ({ isOpen, onClose, categoryData, category }: Docume
});
};

useEffect(() => {
if (isOpen && category === 'update') {
setTitle((categoryData as DocumentDetail).title);
setDescription((categoryData as DocumentDetail).description);
setSelectedValue((categoryData as DocumentDetail).accessType);
}
}, [isOpen, category, categoryData]);

return (
<ActionModal
isOpen={isOpen}
Expand All @@ -179,12 +188,28 @@ const CreateDocumentModal = ({ isOpen, onClose, categoryData, category }: Docume
<Flex direction="column" gap="4">
<Text textStyle="bold_xl">학습자료 제목</Text>
<Input
sx={{
color: 'white',
...textStyles.bold_md,
'::placeholder': {
color: 'white',
...textStyles.bold_md,
},
}}
onChange={handleTitleChange}
placeholder={category === 'create' ? '학습자료 제목을 입력해주세요.' : (categoryData as DocumentDetail).title}
value={title}
/>
<Text textStyle="bold_xl">학습자료 소개</Text>
<Textarea
sx={{
color: 'white',
...textStyles.bold_md,
'::placeholder': {
color: 'white',
...textStyles.bold_md,
},
}}
onChange={handleDescriptionChange}
placeholder={
category === 'create' ? '학습자료 소개를 입력해주세요.' : (categoryData as DocumentDetail).description
Expand Down Expand Up @@ -228,7 +253,28 @@ const CreateDocumentModal = ({ isOpen, onClose, categoryData, category }: Docume
ref={imgInputRef}
onChange={handleGetDoc.IMAGE}
/>
<input hidden type="file" multiple ref={fileInputRef} onChange={handleGetDoc.DOCUMENT} />
<input
hidden
type="file"
multiple
ref={fileInputRef}
accept="text/plain,
application/zip,
application/pdf,
application/vnd.ms-powerpoint,
application/vnd.openxmlformats-officedocument.presentationml.presentation,
video/mp4,
video/x-msvideo,
video/webm,
audio/mpeg,
audio/wav,
audio/webm,
image/jpeg,
image/png,
image/gif,
image/webp"
onChange={handleGetDoc.DOCUMENT}
/>
<Flex direction="column" gap="4" overflow="scroll" maxH="52" shrink="0">
{docList[doctype] &&
docList[doctype].map((doc, index) => (
Expand Down
6 changes: 3 additions & 3 deletions src/containers/study/DocumentModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ const DocumentModal = ({ id, isOpen, setIsDocsModalOpen, setReload }: DocumentMo
<Flex direction="column" gap="2">
{document?.type === 'IMAGE' &&
document?.files.map((data) => (
<Link key={data.url} href={data.url} download>
<Link key={data.url} href={S3_URL(data.url)} download>
<Image alt={data.id.toString()} id={data.id.toString()} rounded="2xl" src={S3_URL(data.url)} />
</Link>
))}
Expand All @@ -77,13 +77,13 @@ const DocumentModal = ({ id, isOpen, setIsDocsModalOpen, setReload }: DocumentMo
<IconBox
// leftIcon={data.type === 'pdf' ? <BiFile size={30} /> : <BsFolder2Open size={30} />}
leftIcon={<BiFile size={30} />}
content={data.id.toString()}
content={data.url.toString()}
/>
</Link>
))}
{document?.type === 'URL' &&
document.files.map((data) => (
<Link key={data.url} href={S3_URL(data.url)}>
<Link key={data.url} href={data.url}>
<IconBox leftIcon={<BiLink size="30" />} content={data.url} />
</Link>
))}
Expand Down