Skip to content

Commit

Permalink
Merge branch 'develop' into feat/#8
Browse files Browse the repository at this point in the history
  • Loading branch information
ckdwns1221 authored Oct 28, 2024
2 parents 323574d + b87bd0a commit c9d0c1a
Show file tree
Hide file tree
Showing 7 changed files with 700 additions and 10 deletions.
6 changes: 6 additions & 0 deletions src/Router.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import Nav from './components/common/Nav.jsx';
import Footer from './components/common/Footer';
import ScrollTop from './components/common/ScrollTop.jsx';
import LoginPage from './pages/LoginPage/LoginPage.jsx';
import PetItemPage from './pages/PetItemPage/PetItemPage.jsx';
import PetItemListPage from './pages/PetItemPage/PetItemListPage.jsx';
import PetItemDetailPage from './pages/PetItemPage/PetItemDetailPage.jsx';

function Router() {
return (
Expand All @@ -13,6 +16,9 @@ function Router() {
<Routes>
<Route path="/" element={<MainPage />} />
<Route path="/Login" element={<LoginPage />} />
<Route path="/petitem" element={<PetItemPage />} />
<Route path="/petitemList" element={<PetItemListPage />} />
<Route path="/petitemDetail/:no" element={<PetItemDetailPage/>} />
</Routes>
<Footer />
<ScrollTop />
Expand Down
13 changes: 7 additions & 6 deletions src/components/common/Footer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,22 @@ import styled from 'styled-components';
import { FiGift } from 'react-icons/fi';
import { LuCalendarHeart } from 'react-icons/lu';
import { images } from '../Images';
import { Link } from 'react-router-dom';
import { Link, useLocation } from 'react-router-dom';

const Footer = () => {
const location = useLocation();
const [activeTab, setActiveTab] = useState(null);

const tabs = [
{
key: 'gift',
icon: <FiGift size={20} color={activeTab === 'gift' ? '#FF6E00' : '#000'} />,
icon: <FiGift size={20} color={location.pathname === '/#' ? '#FF6E00' : '#000'} />,
text: '나눔',
link: '/#',
link: '/petitemList',
},
{
key: 'health',
icon: <LuCalendarHeart size={20} color={activeTab === 'health' ? '#FF6E00' : '#000'} />,
icon: <LuCalendarHeart size={20} color={location.pathname === '/#' ? '#FF6E00' : '#000'} />,
text: '건강관리',
link: '/#',
},
Expand All @@ -41,7 +42,7 @@ const Footer = () => {
<Link to={link} key={key}>
<FooterTap onClick={() => handleTabClick(key)}>
{icon ? icon : <FooterImage src={image} alt={text} />}
<FooterText active={activeTab === key}>{text}</FooterText>
<FooterText $active={location.pathname === link}>{text}</FooterText>
</FooterTap>
</Link>
))}
Expand Down Expand Up @@ -93,5 +94,5 @@ const FooterText = styled.div`
}
font-family: 'TTLaundryGothicB';
font-size: 12px;
color: ${({ active }) => (active ? '#FF6E00' : '#000000')};
color: ${({ $active }) => ($active ? '#FF6E00' : '#000000')};
`;
6 changes: 3 additions & 3 deletions src/components/common/Nav.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const Nav = () => {
];

return (
<Navbar isScrolled={isScrolled}>
<Navbar $isScrolled={isScrolled}>
<AnimalWrap>
<PiDogBold color="#FF6E00" />
<AnimalName>반려동물 이름</AnimalName>
Expand Down Expand Up @@ -58,8 +58,8 @@ const Navbar = styled.div`
display: flex;
align-items: center;
justify-content: space-between;
background-color: ${({ isScrolled }) => (isScrolled ? 'rgba(255, 255, 255, 0.7)' : '#ffffff')};
backdrop-filter: ${({ isScrolled }) => (isScrolled ? 'blur(4px)' : 'none')};
background-color: ${({ $isScrolled }) => ($isScrolled ? 'rgba(255, 255, 255, 0.7)' : '#ffffff')};
backdrop-filter: ${({ $isScrolled }) => ($isScrolled ? 'blur(4px)' : 'none')};
transition: background-color 0.3s ease, backdrop-filter 0.3s ease;
@media (min-width: 375px) {
Expand Down
205 changes: 205 additions & 0 deletions src/pages/PetItemPage/PetItemDetailPage.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,205 @@
import { useEffect, useState } from "react";
import { HiArrowLeft } from "react-icons/hi";
import { useNavigate, useParams } from "react-router-dom";
import styled from "styled-components";
import { VscAccount } from "react-icons/vsc";
import { IoChatbubbleEllipsesOutline } from "react-icons/io5";
import { FiHeart } from "react-icons/fi";

const PetItemDetailPage = () => {
const navigate = useNavigate();
const {no} = useParams();// %% URL에서 글 번호(no)를 가져옴 %%
const [itemDetail, setItemDetail] = useState([]);
const [comments, setComments] = useState([]);
const [counter,setCounter] =useState(0);
useEffect(()=>{
fetch(`http://localhost:8080/api/petItems/${no}`)
.then((response) => response.json())
.then((json) => {
console.log("item 내용 :", json);
setItemDetail(json);
});
},[no])

useEffect(()=>{
fetch(`http://localhost:8080/api/comments`)
.then((response) => response.json())
.then((json) => {
console.log("댓글 :", json);
setComments(json);
});
},[no])

function good () {
setCounter(counter+1);
console.log("좋아요 :", counter)
}

return (
<ItemTitle>
<RowTi>
<button onClick={() => {navigate("/petitemList");}}>
<HiArrowLeft1 />
</button>
<H1>나눔</H1>
</RowTi>

<ListImg>{itemDetail.imageUrl}</ListImg>
<ImgBt>
<ImgNo>1 / 5</ImgNo>
</ImgBt>
<User1><VscAccount1/>작성자: {itemDetail.user}</User1>
<Title>제목: {itemDetail.name}</Title>
<Icons>
<div>
<Like1 onClick={()=>{good()}}/>{counter}
<Comment1/>2
</div>
<div>
<ListPrice> {(itemDetail.price ? `${itemDetail.price.toLocaleString()}원` : <나눔>나눔</나눔>)}</ListPrice>
</div>
</Icons>
<Contents>작성글: {itemDetail.description}</Contents>
<Line />
{comments.map((item)=>(
<div key={item.commentId}>
<User2><VscAccount1/>작성자: {item.length > 0 && item[0].user}
<ListDate key={item.commentId}>
{new Date(item.createdAt).toLocaleDateString('ko-KR', {
timeZone: 'Asia/Seoul'
})}
</ListDate>
</User2>
<Comment>{item.comment}</Comment>
</div>
))}
</ItemTitle>
);
};

export default PetItemDetailPage;


const ItemTitle = styled.div`
margin: 64px 25px 64px 25px;
`;
const RowTi = styled.div`
display: flex;
margin-bottom: 10px;
align-items: center;
`;
const HiArrowLeft1 = styled(HiArrowLeft)`
font-size: 20px;
font-weight: bold;
`;
const H1 = styled.h1`
font-size: 18px;
font-weight: bold;
width: 100%;
display: flex;
align-items: center;
justify-content: center;
margin-right :20px ;
`;
const ListImg = styled.div`
width: 100%;
height: 300px;
background-color: #D9D9D9;
border-radius: 10px;
flex-shrink: 0; /* 이미지 크기를 고정 */
background-image: url(${(props) => props.src}); /* 이미지 URL 설정 */
background-size: cover; /* 이미지를 채우도록 설정 */
background-position: center; /* 이미지 중앙 정렬 */
`;
const ImgBt = styled.div`
display: flex;
position: relative;
justify-content: flex-end;
`;
const ImgNo = styled.button`
background-color: #8D8D8D;
border-radius: 30px;
font-size: 8px;
color: white;
border: 1px solid #8D8D8D;
width: 35px;
height: 20px;
position: absolute;
bottom: 10px;
right: 10px;
`;
const User1 = styled.div`
display: flex;
align-items: center;
font-size: 16px;
margin-top:10px;
`;

const VscAccount1 = styled(VscAccount)`
font-size: 12px;
margin-right: 3px;
align-items: center;
justify-content:center ;
`;
const Title = styled.div`
font-size: 20px;
font-weight: bold;
display: flex;
margin: 10px 0px 10px 0px;
`;
const ListPrice = styled.div`
font-size: 20px;
font-weight: bold;
display: flex;
width: 100%;
`;
const 나눔 = styled.p`
font-size: 15px;
font-weight: bold;
display: flex;
width: 100%;
color: #FF6E00;
justify-content: end;
`;
const Icons = styled.div`
font-size: 16px;
color: #8D8D8D;
display: flex;
justify-content: space-between;
`;
const Like1 = styled(FiHeart)`
font-size: 16px;
color: red;
`;
const Comment1 = styled(IoChatbubbleEllipsesOutline)`
margin-left:10px;
`;
const Contents = styled.div`
font-size: 16px;
margin-bottom: 20px;
margin-top: 10px;
`;
const Line = styled.hr`
border: none;
border-top: 1px solid #FF6E00;
margin-bottom: 20px;
`;
const User2 = styled.div`
display: flex;
align-items: center;
font-size: 12px;
margin-top:10px;
`;
const ListDate = styled.div`
font-size: 8px;
color: #8D8D8D;
display: flex;
margin-left: 5px;
margin-top: 2px;
`;
const Comment = styled.div`
font-size: 12px;
display: flex;
`;
Loading

0 comments on commit c9d0c1a

Please sign in to comment.