-
Notifications
You must be signed in to change notification settings - Fork 79
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
[신승헌] sprint10 #632
Merged
kich555
merged 26 commits into
codeit-bootcamp-frontend:Next.js-신승헌
from
AdamSeungheonShin:Next.js-신승헌-sprint10
Jun 10, 2024
The head ref may contain hidden characters: "Next.js-\uC2E0\uC2B9\uD5CC-sprint10"
Merged
[신승헌] sprint10 #632
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
14ab44a
refactor: api 호출 함수 부분 useEffect 내부로 이동
AdamSeungheonShin c68a248
refactor: 검색 input 핸들러 함수에 불필요한 함수 호출 제거
AdamSeungheonShin a9c3fe8
refactor: 드롭다운 클릭 범위 수정, 포인터 옵션 수정
AdamSeungheonShin 287eaaa
refactor: 인기게시물 조건부 렌더링 부분 수정
AdamSeungheonShin d35d413
refactor: 추상적인 타입명 구체적으로 수정
AdamSeungheonShin fedc2ae
refactor[pages/boards/index.tsx]: 불필요한 재할당 부분 삭제
AdamSeungheonShin e65364d
feat: SSG -> SSR 변경
AdamSeungheonShin 096204e
feat: 초기 데이터 로딩 SSR로 변경
AdamSeungheonShin 8ce5d26
feat: 게시글 작성 기본 ui 제작
AdamSeungheonShin cdd40ad
feat: 제목, 내용 작성 인풋 제작
AdamSeungheonShin e9e552d
feat: 파일인풋 제작, 새게시물 작성 폼 일부 수정, 타입선언 빠트린 부분 수정
AdamSeungheonShin 1230632
feat: 파일인풋 이미지 미리보기, 이미지 삭제하기 기능 추가
AdamSeungheonShin ba764dd
feat: 파일인풋, 이미지인풋 css 작성
AdamSeungheonShin 0a764eb
feat: 페이지 라우팅 Link 경로 수정
AdamSeungheonShin 5137cb2
feat: 게시글 상세 페이지 기본 ui 작성
AdamSeungheonShin 9941c08
feat: 게시글 상세 데이터 호출부 작성
AdamSeungheonShin f818ee2
feat: 게시글 상세 페이지 이미지 박스, 디폴트 이미지 추가
AdamSeungheonShin 7826d77
refactor: 파일명 수정, 임포트한 파일 변수명 수정
AdamSeungheonShin e1211cc
refactor: 게시물 상세 이미지 잘림 오류 css 수정
AdamSeungheonShin 369410b
feat: 댓글 리스트 컴포넌트 기본 ui 작성
AdamSeungheonShin 1bfe187
feat: 댓글 api 호출 부분 작성, Type추가, props 지정
AdamSeungheonShin 24601a3
feat: 지난 시간 카운트 유틸함수 작성
AdamSeungheonShin 1e00784
feat: 댓글 등록버튼 추가, form태그로 수정 및 이벤트 함수 추가
AdamSeungheonShin 9ebe7c8
feat: 댓글 등록 버튼 유효성 검사 옵션 추가
AdamSeungheonShin c3e8b44
feat: 게시글 작성 버튼 유효성 검사 옵션 추가
AdamSeungheonShin 12a4711
feat: 게시글 작성 submit 함수 수정, post 함수 작성
AdamSeungheonShin 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import ProfileDefault from "@/public/images/profile_default.png"; | ||
import EmptyComments from "@/public/images/Img_reply_empty.png"; | ||
import { Comment } from "@/types"; | ||
|
||
import Image from "next/image"; | ||
import formatTimeAgo from "@/utils/formatTimeAgo"; | ||
|
||
export default function CommentList({ comments }: { comments: Comment[] }) { | ||
return ( | ||
<> | ||
{comments && | ||
comments.map((comment) => { | ||
return ( | ||
<div className="flex flex-col gap-6 mb-6" key={comment.id}> | ||
<div>{comment.content}</div> | ||
<div className="flex items-center gap-2"> | ||
<Image | ||
src={ProfileDefault} | ||
width={32} | ||
height={32} | ||
alt="댓글프로필이미지" | ||
/> | ||
<div> | ||
<p className="text-gray-600">{comment.writer.nickname}</p> | ||
<p className="text-gray-400"> | ||
{formatTimeAgo(comment.updatedAt)} | ||
</p> | ||
</div> | ||
</div> | ||
<hr className="h-[1px] bg-gray-200" /> | ||
</div> | ||
); | ||
})} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. { comments?.map((comment) => (
<div className="flex flex-col gap-6 mb-6" key={comment.id}>
<div>{comment.content}</div>
<div className="flex items-center gap-2">
<Image
src={ProfileDefault}
width={32}
height={32}
alt="댓글프로필이미지"
/>
<div>
<p className="text-gray-600">{comment.writer.nickname}</p>
<p className="text-gray-400">
{formatDate(comment.updatedAt)}
</p>
</div>
</div>
<hr className="h-[1px] bg-gray-200" />
</div>
);
)} |
||
</> | ||
); | ||
} |
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,71 @@ | ||
import Image from "next/image"; | ||
import { ChangeEvent, useEffect, useRef, useState } from "react"; | ||
import IconPlus from "@/public/icons/icon_plus.svg"; | ||
import IconDelete from "@/public/icons/icon_delete.svg"; | ||
|
||
interface ImageInputProps { | ||
name: string; | ||
value: File | undefined; | ||
onChange: (name: string, value: File | undefined) => void; | ||
} | ||
|
||
export default function ImageInput({ name, value, onChange }: ImageInputProps) { | ||
const [preview, setPreview] = useState<string>(""); | ||
|
||
const inputRef = useRef<HTMLInputElement>(null); | ||
|
||
const handleChange = (e: ChangeEvent<HTMLInputElement>) => { | ||
const nextValue = e.target.files ? e.target.files[0] : undefined; | ||
onChange(name, nextValue); | ||
}; | ||
|
||
const handleClearImage = () => { | ||
const inputNode = inputRef.current; | ||
if (!inputNode) return; | ||
|
||
inputNode.value = ""; | ||
onChange(name, undefined); | ||
}; | ||
|
||
useEffect(() => { | ||
if (!value) return; | ||
|
||
const nextPreview = URL.createObjectURL(value); | ||
setPreview(nextPreview); | ||
}, [value]); | ||
|
||
return ( | ||
<div> | ||
{value ? ( | ||
<div className="w-72 h-72 mb-3 bg-gray-100 rounded-box relative"> | ||
<button className="absolute top-2 right-2" onClick={handleClearImage}> | ||
<Image width={24} height={24} src={IconDelete} alt="이미지삭제" /> | ||
</button> | ||
<Image | ||
className="object-cover w-72 h-72 rounded-box" | ||
width={288} | ||
height={288} | ||
src={preview} | ||
alt="이미지미리보기" | ||
/> | ||
</div> | ||
) : ( | ||
<label | ||
className="w-72 h-72 mb-3 bg-gray-100 rounded-box flex flex-col justify-center items-center cursor-pointer" | ||
htmlFor={name} | ||
> | ||
<Image src={IconPlus} width={48} height={48} alt="이미지 등록" /> | ||
<p className="text-base text-gray-400 font-normal">이미지 등록</p> | ||
</label> | ||
)} | ||
<input | ||
className="absolute opacity-0" | ||
type="file" | ||
id={name} | ||
name={name} | ||
onChange={handleChange} | ||
ref={inputRef} | ||
/> | ||
</div> | ||
); | ||
} |
Oops, something went wrong.
Oops, something went wrong.
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.
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.
만약 모종의 이유로 api에서 에러가 발생한다면 data 는 'undefined'가 될거에요
data.list 대신 data?.list 로 바꾸는게 좋을것 같아요 !
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.
안그러면 런타임에서 해당 api가 에러를 throw할 경우 앱 자체가 뻗어버릴거에요..!