Skip to content

Commit

Permalink
Merge pull request #148 from TRIP-Side-Project/dev
Browse files Browse the repository at this point in the history
Merge : 7.6차 dev-> main merge 코드 수정 작업
  • Loading branch information
Emma-Hyejin authored Jan 4, 2024
2 parents 971ffb2 + 616437b commit 1eb474c
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 28 deletions.
5 changes: 4 additions & 1 deletion src/pages/Forum.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import FindList from "@/assets/svg/FindList";
import { useState } from "react";
import Loading from "@/components/Loading/Loading";
import ErrState from "@/components/Loading/ErrState";
import { loginState } from "@/store/loginState";
import { useRecoilValue } from "recoil";

const Forum = () => {
const BASE_URL = import.meta.env.VITE_BASE_URL;
Expand All @@ -20,6 +22,7 @@ const Forum = () => {
const [isTitleSearch, setIsTitleSearch] = useState("title=");
const [filter, setFilter] = useState("");
const [category, setCategory] = useState("");
const isLoginState = useRecoilValue(loginState);

const navigateNewForum = () => {
navigate("/forum/edit");
Expand All @@ -30,7 +33,7 @@ const Forum = () => {
position: "right",
text: "새 글 등록하기",
type: "square",
isLogin: window.localStorage.getItem("access_token") ? true : false,
isLogin: isLoginState,
loginBtnType: true,
onClick: () => navigateNewForum(),
};
Expand Down
58 changes: 31 additions & 27 deletions src/pages/ProductList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import Loading from "@/components/Loading/Loading";
import ErrState from "@/components/Loading/ErrState";

export interface ProductInfo {
id: number | null;
maxPrice: number | null;
minPrice: number | null;
productId: number | null;
shopName: string | null;
title: string | null;
buyUrl: string | null;
imageUrl: string | undefined;
id: number | null;
maxPrice: number | null;
minPrice: number | null;
productId: number | null;
shopName: string | null;
title: string | null;
buyUrl: string | null;
imageUrl: string | undefined;
}

const ProductList = () => {
Expand All @@ -25,6 +25,7 @@ const ProductList = () => {
const [isSort, setIsSort] = useState(false);
const [currentPage, setCurrentPage] = useState<number>(1);
const [sort, setSort] = useState("");
const [, setIsTitleSearch] = useState("title=");

useEffect(() => {
const resizeListener = () => {
Expand All @@ -39,24 +40,25 @@ const ProductList = () => {
setSort("");
};

const viewSortClass = "cursor-pointer px-2 text-BASIC_BLACK dark:text-BASIC_WHITE";
const viewSortClass =
"cursor-pointer px-2 text-BASIC_BLACK dark:text-BASIC_WHITE";
const nonViewSortClass = "cursor-pointer px-2 text-LIGHT_GRAY_COLOR";

// 상품 가져오기
const BASE_URL = import.meta.env.VITE_BASE_URL;
const BASE_URL = import.meta.env.VITE_BASE_URL;
const [productItem, setProductItem] = useState([]);

const getProduct = async () => {
try{
const response = await axios.get(`${BASE_URL}/api/items?page=${currentPage}&size=5`)
setProductItem(
response.data.itemList
);
const getProduct = async () => {
try {
const response = await axios.get(
`${BASE_URL}/api/items?page=${currentPage}&size=5`,
);
setProductItem(response.data.itemList);
return response.data;
} catch (error) {
console.log("Error: " + error)
}
}
} catch (error) {
console.log("Error: " + error);
}
};

const { isPending, isError, data, error } = useQuery({
queryKey: ["productLists", currentPage, search, sort],
Expand All @@ -74,7 +76,7 @@ const ProductList = () => {
</h1>
{innerWidth > 768 && (
<>
<Search setSearch={setSearch} />
<Search setSearch={setSearch} setIsTitleSearch={setIsTitleSearch} />
<div className="flex gap-2 px-3 pb-1 text-base border-b border-DARK_GRAY_COLOR">
<span
className={isSort ? viewSortClass : nonViewSortClass}
Expand All @@ -93,7 +95,7 @@ const ProductList = () => {
)}
{innerWidth <= 768 && (
<div className="flex items-center justify-between">
<Search setSearch={setSearch} />
<Search setSearch={setSearch} setIsTitleSearch={setIsTitleSearch} />
<div className="flex pb-1 text-sm border-b border-DARK_GRAY_COLOR">
<span
className={isSort ? viewSortClass : nonViewSortClass}
Expand All @@ -111,12 +113,14 @@ const ProductList = () => {
</div>
)}
</div>
{productItem.map(item => <ProductListItems item={item} /> )}
{productItem.map((item) => (
<ProductListItems item={item} />
))}
<Pagination
pageInfo={data.pagination}
activeBtn={currentPage}
setActiveBtn={setCurrentPage}
/>
pageInfo={data.pagination}
activeBtn={currentPage}
setActiveBtn={setCurrentPage}
/>
</div>
);
};
Expand Down

0 comments on commit 1eb474c

Please sign in to comment.