Skip to content

Commit

Permalink
Merge pull request #81 from LikeLionHGU/hwan_#78/자잘한-에러-잡기
Browse files Browse the repository at this point in the history
Hwan #78/자잘한 에러 잡기
  • Loading branch information
hwan129 authored Aug 3, 2024
2 parents e4e1c81 + 9c1f1b5 commit 3acb34a
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 34 deletions.
43 changes: 22 additions & 21 deletions src/components/Header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,31 +146,32 @@ export default function Header({ mode }) {
</div>
</div>
{/* 프로젝트 이외에 경우에는 카테고리를 안보여줘도 됨 */}
{mode === 3 ? (
{/* detail 페이지도 */}
{mode === 3 || mode === 2 ? (
<></>
) : (
<div className="header-categoryContainer">
<div className="header-category" id="upper-category">
{Object.keys(categories).map((category) => (
<button
key={category}
onClick={() => handleCategoryClick(category)}
>
{category}
</button>
))}
</div>
{/* 프로젝트 전체 페이지일 경우 보여줌 */}
{mode === 1 ? (
<div className="header-category">
{categories[selectedCategory].map((option, index) => (
<button key={index}>{option}</button>
<div className="header-categoryContainer">
<div className="header-category" id="upper-category">
{Object.keys(categories).map((category) => (
<button
key={category}
onClick={() => handleCategoryClick(category)}
>
{category}
</button>
))}
</div>
) : (
<></>
)}
</div>
{/* 프로젝트 전체 페이지일 경우 보여줌 */}
{mode === 1 ? (
<div className="header-category">
{categories[selectedCategory].map((option, index) => (
<button key={index}>{option}</button>
))}
</div>
) : (
<></>
)}
</div>
)}
</div>
);
Expand Down
29 changes: 16 additions & 13 deletions src/pages/project/Detail.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ export default function Detail() {
);
};

const BookmarkList = ({ bookmark = []}) => {
const BookmarkList = ({ bookmark = [] }) => {
if (!bookmark || bookmark.length === 0) {
return null;
}

return (
<div id="detail-galpi-list">
{bookmark.map((item, index) => (
Expand Down Expand Up @@ -98,6 +98,7 @@ export default function Detail() {
console.log("Post uploaded successfully");
// alert("게시물 업로드 성공");
navigate("/"); // 성공적으로 업로드 후 메인 페이지로 이동
setComment("");
} else {
console.error("Error uploading post");
}
Expand All @@ -114,7 +115,6 @@ export default function Detail() {
localStorage.removeItem("token");
navigate("/", { replace: true });
}
setComment("");
}
};

Expand Down Expand Up @@ -206,20 +206,23 @@ export default function Detail() {
navigate("/update");
}

// 글 작성하는 페이지로 이동
const toWrite = (id) => { // 넘겨주는 id는 갈피의 id
if(project.isOwner) { // owner인 경우
navigate("/update", { state: { id: id, user: 2, mode: 0, bookmarkList: bookmarkList} });
// 글 작성하는 페이지로 이동
const toWrite = (id) => {
// 넘겨주는 id는 갈피의 id
if (project.isOwner) {
// owner인 경우
navigate("/update", {
state: { id: id, user: 2, mode: 0, bookmarkList: bookmarkList },
});
}

if(project.isOwner === false && project.isParticipate === true) {
if (project.isOwner === false && project.isParticipate === true) {
navigate("/update", { state: { id, user: 1, mode: 0, bookmarkList } }); // 참여자인 경우
}
if(project.isOwner === false && project.isParticipate === false) {
navigate("/update", { state: { id, user: 0, mode: 0, bookmarkList } }); // 그냥 사람

if (project.isOwner === false && project.isParticipate === false) {
navigate("/update", { state: { id, user: 0, mode: 0, bookmarkList } }); // 그냥 사람
}

};

const handleGoCommunity = (id) => {
Expand Down Expand Up @@ -331,7 +334,7 @@ export default function Detail() {
id="detail-write-container"
value={comment}
onChange={(e) => setComment(e.target.value)}
onKeyDown={(e) => (e.key === "Enter" ? addComment() : null)}
onKeyDown={(e) => (e.key === "Enter" ? handleSubmit() : null)}
/>
<img
src={CommentArrowImg}
Expand Down

0 comments on commit 3acb34a

Please sign in to comment.