Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 1 addition & 2 deletions components/Footer.module.css
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
.footerBanner {
background-color: #111827;
width: 100%;
margin-top: 100px;
height: 160px;
padding: 32px 200px 32px 200px;
width: auto;
}

.footerBannerContent {
Expand Down
17 changes: 12 additions & 5 deletions components/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@ import styles from "./Header.module.css";
import Link from "next/link";
import { useRouter } from "next/router";
import Image from "next/image";
import { useState, useEffect } from "react";
import { useAuth } from "@/contexts/AuthProvider";

function Header() {
const router = useRouter();
const pathname = router;
const pathname = router.pathname;
const isItemPage = pathname === "/items";
const isFreePage = pathname === "/free";

const { user, logout } = useAuth();

return (
<section className={styles.topNav}>
<div className={styles.navCon}>
Expand Down Expand Up @@ -38,10 +42,13 @@ function Header() {
</Link>
</div>

{/* 글씨 만이 아닌 여백을 클릭해도 링크 이동하기 위함 */}
<Link href="/login" className={styles.topNavLoginBt}>
로그인
</Link>
{user ? (
<div onClick={logout}>{user?.nickname}</div>
) : (
<Link href="/login" className={styles.topNavLoginBt}>
로그인
</Link>
)}
</div>
</section>
);
Expand Down
2 changes: 1 addition & 1 deletion components/Header.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,6 @@
font-weight: bold;
text-decoration: none;
}
.navLinkBt.active {
.active {
color: #3692ff;
}
15 changes: 15 additions & 0 deletions components/LikeButton.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import styles from "./LikeButton.module.css";
import Image from "next/image";

export default function LikeButton({ favoriteCount }) {
return (
<button className={styles.likeBt}>
<div className={styles.btContents}>
<div className={styles.likeImgBox}>
<Image fill alt="heart" src="/imgs/ic_heart.png" />
</div>
<div className={styles.likeCount}>{favoriteCount}</div>
</div>
</button>
);
}
25 changes: 25 additions & 0 deletions components/LikeButton.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
.likeBt {
height: 40px;
background-color: #ffffff;
border: 1px solid #e5e7eb;
border-radius: 35px;
padding: 4px 12px 4px 12px;
}

.btContents {
display: flex;
gap: 4px;
align-items: center;
}

.likeImgBox {
position: relative;
width: 32px;
height: 32px;
}
.likeCount {
font-size: 16px;
line-height: 26px;
font-weight: 500;
color: #6b7280;
}
16 changes: 0 additions & 16 deletions components/NoComment.js

This file was deleted.

8 changes: 4 additions & 4 deletions components/OrderDropDown.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useState, useRef, useEffect } from "react";
import styles from "./OrderDropDown.module.css";

function Dropdown({ options, order, orderChange }) {
function OrderDropdown({ options, order, orderChange }) {
// 드롭다운 열려있는지 상태
const [isOpen, setIsOpen] = useState(false);
// 외부 클릭 감지를 위한 ref 사용(기본값 null 랜더링 되면 해당 요소 할당)
Expand Down Expand Up @@ -39,7 +39,7 @@ function Dropdown({ options, order, orderChange }) {
return (
<div className={styles.dropdown} ref={dropdownRef}>
<button className={styles.dropdownButton} onClick={toggleDropdown}>
{order}
{order.label}
<span className="arrow">▼</span>
</button>
{/* 열린 상태(isOpen = true)이면 보이게 */}
Expand All @@ -52,7 +52,7 @@ function Dropdown({ options, order, orderChange }) {
className={styles.dropdownItem}
onClick={() => handleSelect(option)}
>
{option}
{option.label}
</div>
))}
</div>
Expand All @@ -61,4 +61,4 @@ function Dropdown({ options, order, orderChange }) {
);
}

export default Dropdown;
export default OrderDropdown;
2 changes: 1 addition & 1 deletion components/UpdateDropDown.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export default function UpdateDropDown() {

// 드롭다운 옵션 삭제하기 눌렀을 때 이벤트
const handleSelectDelete = () => {

// 드롭다운 닫기
setIsOpen(false);
};
Expand All @@ -40,7 +41,6 @@ export default function UpdateDropDown() {
};
}, [isOpen]);

const handleClick = () => {};
return (
<div className={styles.dropdown} ref={dropdownRef}>
<button className={styles.articleChangeBt} onClick={toggleDropdown}>
Expand Down
2 changes: 1 addition & 1 deletion components/UpdateDropDown.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
border: 1px solid #e5e7eb;
border-radius: 12px;
background-color: white;
right: 220px;

width: 139px;
z-index: 1;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import styles from "./ArticleDetail.module.css";
import Image from "next/image";
import UpdateDropDown from "./UpdateDropDown";
import UpdateDropDown from "../UpdateDropDown";

export default function ArticleDetail({ article }) {
return (
Expand Down Expand Up @@ -28,7 +28,7 @@ export default function ArticleDetail({ article }) {
<div className={styles.likeImgBox}>
<Image fill alt="heart" src="/imgs/ic_heart.png" />
</div>
<div>123</div>
<div className={styles.likeCount}>123</div>
</div>
</button>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,10 @@
width: 32px;
height: 32px;
}

.likeCount {
font-size: 16px;
line-height: 26px;
font-weight: 500;
color: #6b7280;
}
25 changes: 17 additions & 8 deletions components/Comment.js → components/comment/Comment.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,21 @@ import InputComment from "./InputComment";
import CommentList from "./CommentList";
import NoComment from "./NoComment";
import { useState, useEffect } from "react";
import axios from "@/lib/axios";
// import axios from "@/lib/axios";
import codeitAxios from "@/lib/codeitAxios";

export default function Comment({ id }) {
export default function Comment({ id, isArticle }) {
const [value, setValue] = useState("");
const [comments, setComments] = useState([]);
const [isSubmitting, setIsSubmitting] = useState(false);

async function getComments() {
const response = await axios.get(`/article/${id}/comments`);
const comments = response.data ?? [];
const response = await codeitAxios.get(
isArticle
? `/articles/${id}/comments?limit=5`
: `/products/${id}/comments?limit=5`
);
const comments = response.data.list ?? [];
setComments(comments);
return response.data;
}
Expand All @@ -27,9 +32,12 @@ export default function Comment({ id }) {
async function createComment() {
try {
setIsSubmitting(true);
const response = await axios.post(`/article/${id}/comment`, {
content: value,
});
const response = await codeitAxios.post(
isArticle ? `/articles/${id}/comments` : `/products/${id}/comments`,
{
content: value,
}
);
return response.data;
} catch (err) {
console.log(err);
Expand All @@ -53,11 +61,12 @@ export default function Comment({ id }) {
setValue={setValue}
getComments={getComments}
isSubmitting={isSubmitting}
isArticle={isArticle}
/>
{comments.length > 0 ? (
<CommentList comments={comments} />
) : (
<NoComment />
<NoComment isArticle />
)}
</div>
);
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
import styles from "./CommentLayout.module.css";
import Image from "next/image";
import UpdateDropDown from "./UpdateDropDown";
import UpdateDropDown from "../UpdateDropDown";
import formatUpdatedTime from "@/lib/formatDate";

export default function Comment({ comment }) {
const username = comment.writer.nickname;
const updatedAt = comment.updatedAt;

const updatedTime = formatUpdatedTime(updatedAt); // 하루 지나면 날짜 안지나면 ?시간 전 리턴

return (
<div className={styles.commentBox}>
<div className={styles.contents}>
Expand All @@ -12,8 +18,8 @@ export default function Comment({ comment }) {
<Image fill alt="userProfileImg" src="/imgs/userProfileImg.png" />
</div>
<div className={styles.nameAndDate}>
<div>똑똑한 판다</div>
<div>1시간 전</div>
<div>{username}</div>
<div>{updatedTime}</div>
</div>
</div>
</div>
Expand Down
File renamed without changes.
12 changes: 10 additions & 2 deletions components/InputComment.js → components/comment/InputComment.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,28 @@
import { useRouter } from "next/router";
import styles from "./InputComment.module.css";

export default function InputComment({
handleClick,
value,
setValue,
isSubmitting,
isArticle,
}) {
const isBtDisabled = !value.trim();

return (
<div className={styles.container}>
<div className={styles.inputBox}>
<div className={styles.mediumText}>댓글달기</div>
<div className={styles.mediumText}>
{isArticle ? "댓글달기" : "문의하기"}
</div>
<textarea
className={styles.textArea}
placeholder="댓글 입력해주세요"
placeholder={
isArticle
? "댓글 입력해주세요"
: "개인정보를 공유 및 요청하거나, 명예 훼손, 무단 광고, 불법 정보 유포시 모니터링 후 삭제될 수 있으며, 이에 대한 민형사상 책임은 게시자에게 있습니다."
}
value={value}
onChange={(e) => setValue(e.target.value)}
/>
Expand Down
30 changes: 30 additions & 0 deletions components/comment/NoComment.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import Image from "next/image";
import styles from "./NoComment.module.css";

export default function NoComment({ isArticle }) {
return (
<div className={styles.noComment}>
<div className={styles.imgBox}>
<Image
fill
src={
isArticle
? "/imgs/img_reply_empty.png"
: "/imgs/img_inquiry_empty.png"
}
alt="emptyImg"
/>
</div>
<div className={styles.textCenter}>
{isArticle ? (
<>
<span> 아직 댓글이 없어요,</span>
<span> 지금 댓글을 달아보세요!</span>
</>
) : (
<span>아직 문의가 없어요</span>
)}
</div>
</div>
);
}
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default function ArticleList({ articles }) {
{articles.map((article) => (
<Link
key={article.id}
href={`/article/${article.id}`}
href={`/articles/${article.id}`}
style={{ textDecoration: "none" }}
>
<Article article={article} />
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ function BestArticleList({ bestArticles }) {
<div className={styles.bestArticleList}>
{bestArticles.map((article) => (
<Link
href={`/article/${article.id}`}
href={`/articles/${article.id}`}
style={{ textDecoration: "none" }}
key={article.id}
>
Expand Down
Loading
Loading