-
Notifications
You must be signed in to change notification settings - Fork 31
[홍승원] sprint10 #142
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
The head ref may contain hidden characters: "Next-\uD64D\uC2B9\uC6D0-sprint10"
[홍승원] sprint10 #142
Changes from all commits
8b8dbc4
3f2ccb1
60af583
8dcefd9
13fd76e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| "use client"; | ||
| import AddImage from "@/components/AddImage"; | ||
| import InputText from "@/components/InputText"; | ||
| import TextArea from "@/components/TextArea"; | ||
| import React, { useEffect, useState } from "react"; | ||
|
|
||
| const Page = () => { | ||
| const [title, setTitle] = useState(""); | ||
| const [content, setContent] = useState(""); | ||
| const [disable, setDisable] = useState(true); | ||
| const [buttonColor, setButtonColor] = useState("#9CA3AF"); | ||
|
|
||
| useEffect(() => { | ||
| if (title && content !== "") { | ||
| setButtonColor("#3692FF"); | ||
| setDisable(false); | ||
| } else { | ||
| setButtonColor("#9CA3AF"); | ||
| setDisable(true); | ||
| } | ||
| }, [title, content]); | ||
|
|
||
| return ( | ||
| <div className="flex flex-col justify-center lg:px-[360px] md:px-[24px] px-[15px] pb-[130px]"> | ||
| <div className="flex flex-row items-center justify-between lg:mt-[94px] mt-[86px]"> | ||
| <span className="text-[20px] font-bold">게시글 쓰기</span> | ||
| <button | ||
| className={`w-[74px] h-[42px] rounded-lg bg-[${buttonColor}] text-[#F3F4F6] text-[16px] font-semibold`} | ||
| disabled={disable} | ||
| > | ||
| 등록 | ||
| </button> | ||
| </div> | ||
|
|
||
| <div className="mt-[32px]"> | ||
| <InputText setTitle={setTitle} /> | ||
| </div> | ||
|
|
||
| <div className="mt-[24px]"> | ||
| <TextArea setContent={setContent} /> | ||
| </div> | ||
|
|
||
| <div className="mt-[24px]"> | ||
| <AddImage /> | ||
| </div> | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| export default Page; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,101 @@ | ||
| "use client"; | ||
| import AddComment from "@/components/AddComment"; | ||
| import Comment from "@/components/Comment"; | ||
| import useArticleDetails from "@/hooks/useArticleDetails"; | ||
| import useComment from "@/hooks/useComment"; | ||
| import Image from "next/image"; | ||
| import { useParams } from "next/navigation"; | ||
| import React from "react"; | ||
| import { BsThreeDotsVertical } from "react-icons/bs"; | ||
| import { GoHeart } from "react-icons/go"; | ||
| import { TbArrowBack } from "react-icons/tb"; | ||
| import Link from "next/link"; | ||
| import useScroll from "@/hooks/useScroll"; | ||
| import Loading from "@/components/Loading"; | ||
|
|
||
| const Page = () => { | ||
|
Collaborator
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. next를 사용하시는 김에 다양한 렌더링을 써보시면 좋을 거 같습니다 :) 특히 상세 페이지의 경우 보통 SEO와 직결되므로 특히 더 고려해 볼 수 있겠죠! |
||
| const { id } = useParams(); | ||
| const { articleDetails } = useArticleDetails(id as string); | ||
| const { comments, nextCursor, setComment, setNextCursor } = useComment({ | ||
| id: id as string, | ||
| }); | ||
| const { loading } = useScroll({ | ||
| nextCursor, | ||
| setComment, | ||
| setNextCursor, | ||
| id: id as string, | ||
| }); | ||
|
|
||
| const formattedDate = articleDetails?.createdAt | ||
| ? new Date(articleDetails.createdAt) | ||
| .toLocaleDateString("ko-KR", { | ||
| year: "numeric", | ||
| month: "2-digit", | ||
| day: "2-digit", | ||
| }) | ||
| .replace(/\.$/, "") | ||
| : ""; | ||
|
|
||
| return ( | ||
| <div className="flex flex-col lg:px-[360px] md:px-[24px] px-[16px] "> | ||
| <div className="flex flex-row justify-between items-center mt-[95px]"> | ||
| <span className="text-[20px] font-bold">{articleDetails?.title}</span> | ||
| <BsThreeDotsVertical size={24} color="#9CA3AF" /> | ||
| </div> | ||
|
|
||
| <div className="flex flex-row items-center mt-[16px]"> | ||
| <div className=" relative w-[40px] h-[40px] rounded-full bg-gray-400"> | ||
| <Image fill src="/profile.svg" alt="profile" /> | ||
| </div> | ||
| <span className="text-[14px] font-medium ml-[16px]"> | ||
| {articleDetails?.writer.nickname} | ||
| </span> | ||
| <span className="text-[14px] text-[#9CA3AF] font-normal ml-[8px]"> | ||
| {formattedDate} | ||
| </span> | ||
|
|
||
| <div className="w-[1px] h-[40px] bg-[#D1D5DB] mx-[32px]" /> | ||
|
|
||
| <div className="flex flex-row items-center justify-center w-[87px] h-[40px] rounded-4xl border-[1px] border-[#E5E7EB]"> | ||
| <GoHeart size={32} color="#6B7280" /> | ||
| <span className="text-[16px] font-medium ml-[4px]"> | ||
| {articleDetails?.likeCount} | ||
| </span> | ||
| </div> | ||
| </div> | ||
|
|
||
| <div className="border-[0.5px] border-[#E5E7EB] mt-[16px] mb-[24px]"></div> | ||
|
|
||
| <span className="text-[18px] font-normal">{articleDetails?.content}</span> | ||
|
|
||
| <AddComment /> | ||
|
|
||
| {comments.length > 0 ? ( | ||
| comments.map((comment, index) => ( | ||
| <Comment comment={comment} key={index} /> | ||
| )) | ||
| ) : ( | ||
| <div className="flex flex-col items-center justify-center mt-[40px]"> | ||
| <Image width={140} height={140} alt="Empty" src="/empty_Icon.svg" /> | ||
| <span className="text-[16px] text-[#9CA3AF] font-normal mt-[16px]"> | ||
| 아직 댓글이 없어요, 지금 댓글을 달아보세요! | ||
| </span> | ||
| </div> | ||
| )} | ||
|
|
||
| {loading && <Loading />} | ||
|
|
||
| <div className="mt-[64px] mb-[95px] flex flex-row justify-center"> | ||
| <Link | ||
| href="/boards" | ||
| className="flex flex-row items-center justify-center bg-[#3692FF] w-[240px] h-[48px] rounded-[40px] text-[#F3F4F6] text-[18px] font-semibold" | ||
| > | ||
| 목록으로 돌아가기 | ||
| <TbArrowBack className="ml-[8px]" size={24} color="#FFFFFF" /> | ||
| </Link> | ||
| </div> | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| export default Page; | ||
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.
title, content로 결정 되는 값들이라면 굳이 useEffect를 쓸 필요 없습니다!
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.
그리고 버튼을 컴포넌트화 해서 활용했다면 상태 값을 내부에서 좀 더 깔끔하게 다룰 수 있었을 거 같네요 :)