Skip to content

Commit

Permalink
refactor: sprint5 코멘트 반영
Browse files Browse the repository at this point in the history
  • Loading branch information
CisThard committed Dec 9, 2024
1 parent bb01351 commit c8dccb3
Show file tree
Hide file tree
Showing 23 changed files with 331 additions and 102 deletions.
11 changes: 11 additions & 0 deletions src/api/getProducts.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,32 @@
<<<<<<< HEAD
const BASE_URL = 'https://panda-market-api.vercel.app/products';
=======
const BASE_URL = "https://backend-c2ut.onrender.com";
>>>>>>> 0f1a9c4 (refactor: sprint5 코멘트 반영)


export async function getProducts(
{
offset = 0,
limit = 10,
page = 1,
<<<<<<< HEAD
pageSize = 10,
sort = 'recent',
=======
sort = "recent",
>>>>>>> 0f1a9c4 (refactor: sprint5 코멘트 반영)
keyword = "",
}
) {
const query = `offset=${offset}&limit=${limit}&page=${page}&pageSize=${pageSize}&orderBy=${sort}&keyword=${keyword}`;
const response = await fetch(`${BASE_URL}?${query}`);
const data = await response.json();
<<<<<<< HEAD

console.log("Fetched products:", data);
=======
>>>>>>> 0f1a9c4 (refactor: sprint5 코멘트 반영)

return data;
}
Expand Down
18 changes: 0 additions & 18 deletions src/components/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -78,21 +78,3 @@
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
}


:root {
--primary-color-50: #E6F2FF;
--primary-color-100: #3692FF;
--primary-color-200: #1967D6;
--primary-color-300: #1251AA;
--error-color: #F74747;
--secondary-color-gray900: #111827;
--secondary-color-gray800: #1F2937;
--secondary-color-gray700: #374151;
--secondary-color-gray600: #4B5563;
--secondary-color-gray500: #6B7280;
--secondary-color-gray400: #9CA3AF;
--secondary-color-gray200: #E5E7EB;
--secondary-color-gray100: #F3F4F6;
--secondary-color-gray50: #F9FAFB;
}
14 changes: 13 additions & 1 deletion src/components/App.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<<<<<<< HEAD:src/components/App.js
import './App.css';
import NavBar from './NavBar';
import Footer from './Footer';
Expand All @@ -7,6 +8,18 @@ import { useState } from 'react';
import SearchBar from './SearchBar';
import Pagination from './Pagination';
import DropDown from './DropDown';
=======
import "../styles/ItemPage.css";
import NavBar from "../components/NavBar";
import Footer from "../components/Footer";
import BestProducts from "../components/BestProducts";
import { OnSaleProducts } from "../components/OnSaleProducts";
import { useState } from "react";
import SearchBar from "../components/SearchBar";
import Pagination from "../components/Pagination";
import DropDown from "../components/DropDown";
import { NavLink } from "react-router-dom";
>>>>>>> 0f1a9c4 (refactor: sprint5 코멘트 반영):src/pages/ItemPage.js

function App() {

Expand All @@ -24,7 +37,6 @@ function App() {
newOption = "favorite";
setSelectedOption(newOption);
}
console.log(newOption);
}

const handlePageChange = (newPage) => {
Expand Down
22 changes: 22 additions & 0 deletions src/components/Banner.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import "../styles/Banner.css";

export function Banner(children) {
return (
<div class="banner_container">
<div class="banner_info">
<p class="banner_text">{children.toptext}</p>
<p class="banner_text">{children.bottomtext}</p>
{children.link && (
<a href="items.html">
<button className="look_around_button">구경하러 가기</button>
{children.link.label}
</a>
)}

</div>
<img class="banner_image" src={children.image}/>
</div>
);
}

export default Banner;
14 changes: 10 additions & 4 deletions src/components/BestProducts.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
import { useEffect, useState } from "react";
import "./BestProducts.css";
import { getProducts } from "../api/getProducts";
<<<<<<< HEAD
import "./BestProducts.css";
import "../images/empty_heart.png";
import IsImage from "./IsImage";
import "../images/no-image-available.png";
=======
import "../images/emptyHeart.png";
import IsImage from "../utils/image.helper";
import "../images/noImageAvailable.png";
>>>>>>> 0f1a9c4 (refactor: sprint5 코멘트 반영)

export function BestProducts() {

const empty_heart = require("../images/empty_heart.png");
const no_image_available = require("../images/no-image-available.png");
const emptyHeart = require("../images/emptyHeart.png");
const noImageAvailable = require("../images/noImageAvailable.png");


const [bestProducts, setBestProducts] = useState([]);
Expand All @@ -22,7 +28,7 @@ export function BestProducts() {
setBestProducts(data.list);
data.list.forEach(product => {
if (!IsImage(String(product.images))) {
product.images = no_image_available;
product.images = noImageAvailable;
}
});
})
Expand All @@ -40,7 +46,7 @@ export function BestProducts() {
<p>{product.price.toLocaleString()}</p>
<div className="best-product-favorite">
<button className="best-favorite-button">
<img src={empty_heart} alt="favorite"></img>
<img src={emptyHeart} alt="favorite"></img>
</button>
<h5>{product.favoriteCount}</h5>
</div>
Expand Down
42 changes: 42 additions & 0 deletions src/components/Content.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import "../styles/Content.css";
import "../images/Img_home_01.png";
import "../images/Img_home_02.png";
import "../images/Img_home_03.png";

export function Content() {

const content_image_01 = require("../images/Img_home_01.png");
const content_image_02 = require("../images/Img_home_02.png");
const content_image_03 = require("../images/Img_home_03.png");

return (
<div className="content-container">
<div className="content_container">
<img className="images" src={content_image_01}/>
<div className="content_01">
<b className="content_badge">Hot Item</b>
<p className="content_title">인기 상품을 <br/> 확인해 보세요</p>
<p className="content_desc">가장 HOT한 중고거래 물품을 <br/> 판다 마켓에서 확인해 보세요</p>
</div>
</div>
<div className="content_container">
<div className="content_02">
<b className="content_badge">Search</b>
<p className="content_title">구매를 원하는 <br/> 상품을 검색하세요</p>
<p className="content_desc">구매하고 싶은 물품은 검색해서 <br/> 쉽게 찾아보세요</p>
</div>
<img className="images" src={content_image_02}/>
</div>
<div className="content_container">
<img className="images" src={content_image_03}/>
<div className="content_03">
<b className="content_badge">Register</b>
<p className="content_title">판매를 원하는 <br/> 상품을 등록하세요</p>
<p className="content_desc">어떤 물건이든 판매하고 싶은 상품을 <br/> 쉽게 등록하세요</p>
</div>
</div>
</div>
);
}

export default Content;
38 changes: 18 additions & 20 deletions src/components/DropDown.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
<<<<<<< HEAD
import React, { useState } from 'react';
import './DropDown.css';
=======
import React, { useState } from "react";
import "../styles/DropDown.css";
import DropdownToggle from "./DropdownToggle";
import DropdownContent from "./DropdownContent";
>>>>>>> 0f1a9c4 (refactor: sprint5 코멘트 반영)

function DropDown({ options = [], onSelect }) {
function DropDown({ options = [], onSelect }) {
const [isOpen, setIsOpen] = useState(false);
const [selectedOption, setSelectedOption] = useState(null);

const toggleDropdown = () => {
setIsOpen((prev) => !prev);
setIsOpen(!isOpen);
};

const handleOptionClick = (option) => {
Expand All @@ -17,24 +24,15 @@ function DropDown({ options = [], onSelect }) {

return (
<div className="dropdown">
<button className="dropdown-button" onClick={toggleDropdown}>
{selectedOption || "최신순"}
</button>
{isOpen && options.length > 0 ? (
<ul className="dropdown-menu">
{options.map((option, index) => (
<li
key={index}
className="dropdown-item"
onClick={() => handleOptionClick(option)}
>
{option}
</li>
))}
</ul>
) : (
isOpen && <p className="dropdown-no-options">옵션이 없습니다.</p>
)}
<DropdownToggle
onToggle={toggleDropdown}
selectedOption={selectedOption}
/>
<DropdownContent
isOpen={isOpen}
options={options}
handleOptionClick={handleOptionClick}
/>
</div>
);
}
Expand Down
27 changes: 27 additions & 0 deletions src/components/DropdownContent.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import React from "react";

function DropdownContent({ isOpen, options, handleOptionClick }) {
if (!isOpen) {
return null;
}

if (options.length > 0) {
return (
<ul className="dropdown-menu">
{options.map((option, index) => (
<li
key={index}
className="dropdown-item"
onClick={() => handleOptionClick(option)}
>
{option}
</li>
))}
</ul>
);
}

return <p className="dropdown-no-options">옵션이 없습니다.</p>;
}

export default DropdownContent;
11 changes: 11 additions & 0 deletions src/components/DropdownToggle.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import React from "react";

function DropdownToggle({ onToggle, selectedOption }) {
return (
<button className="dropdown-button" onClick={onToggle}>
{selectedOption || "최신순"}
</button>
);
}

export default DropdownToggle;
18 changes: 0 additions & 18 deletions src/components/Footer.css
Original file line number Diff line number Diff line change
@@ -1,21 +1,3 @@
:root {
--primary-color-50: #E6F2FF;
--primary-color-100: #3692FF;
--primary-color-200: #1967D6;
--primary-color-300: #1251AA;
--error-color: #F74747;
--secondary-color-gray900: #111827;
--secondary-color-gray800: #1F2937;
--secondary-color-gray700: #374151;
--secondary-color-gray600: #4B5563;
--secondary-color-gray500: #6B7280;
--secondary-color-gray400: #9CA3AF;
--secondary-color-gray200: #E5E7EB;
--secondary-color-gray100: #F3F4F6;
--secondary-color-gray50: #F9FAFB;
}


.footer_container {
margin: 0;
padding: 0;
Expand Down
8 changes: 8 additions & 0 deletions src/components/Footer.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
<<<<<<< HEAD
import instagram from '../images/ic_instagram.png';
import facebook from '../images/ic_facebook.png';
import twitter from '../images/ic_twitter.png';
import youtube from '../images/ic_youtube.png';
import './Footer.css';
=======
import instagram from "../images/ic_instagram.png";
import facebook from "../images/ic_facebook.png";
import twitter from "../images/ic_twitter.png";
import youtube from "../images/ic_youtube.png";
import "../styles/Footer.css";
>>>>>>> 0f1a9c4 (refactor: sprint5 코멘트 반영)

export function Footer() {
return (
Expand Down
8 changes: 0 additions & 8 deletions src/components/IsImage.js

This file was deleted.

18 changes: 0 additions & 18 deletions src/components/NavBar.css
Original file line number Diff line number Diff line change
@@ -1,21 +1,3 @@
:root {
--primary-color-50: #E6F2FF;
--primary-color-100: #3692FF;
--primary-color-200: #1967D6;
--primary-color-300: #1251AA;
--error-color: #F74747;
--secondary-color-gray900: #111827;
--secondary-color-gray800: #1F2937;
--secondary-color-gray700: #374151;
--secondary-color-gray600: #4B5563;
--secondary-color-gray500: #6B7280;
--secondary-color-gray400: #9CA3AF;
--secondary-color-gray200: #E5E7EB;
--secondary-color-gray100: #F3F4F6;
--secondary-color-gray50: #F9FAFB;
}


nav {
background-color: white;
color: black;
Expand Down
Loading

0 comments on commit c8dccb3

Please sign in to comment.