-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
47 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,51 @@ | ||
'use client'; | ||
import MainTitle from '@/components/titles/MainTitle'; | ||
import TotalItemContent from '@/components/totalItem/TotalItemContent'; | ||
import TopInfo from '@/components/wardrobe/TopInfo'; | ||
import { useState, useEffect } from 'react'; | ||
import { getClothingSales } from '@/api/request'; | ||
import { ClothingSalesStatus } from '@/interface/interface'; | ||
"use client"; | ||
import MainTitle from "@/components/titles/MainTitle"; | ||
import TotalItemContent from "@/components/totalItem/TotalItemContent"; | ||
import TopInfo from "@/components/wardrobe/TopInfo"; | ||
import { useState, useEffect } from "react"; | ||
import { getClothingSales } from "@/api/request"; | ||
import { ClothingSalesStatus } from "@/interface/interface"; | ||
|
||
function Totalitem() { | ||
const [clothing, setClothing] = useState<ClothingSalesStatus | null>(null); | ||
const [clothing, setClothing] = useState<ClothingSalesStatus | null>(null); | ||
const [page, setPage] = useState(0); // 현재 페이지 상태 | ||
const size = 10; // 페이지당 아이템 수 | ||
const [sortType, setSortType] = useState("latest"); // 정렬 기준 상태 | ||
|
||
useEffect(() => { | ||
const fetchItem = async () => { | ||
const requestPurchase = await getClothingSales('0', '10'); | ||
setClothing(requestPurchase); | ||
const fetchItem = async () => { | ||
const requestPurchase = await getClothingSales( | ||
String(page), | ||
String(size), | ||
sortType | ||
); | ||
setClothing(requestPurchase); | ||
console.log("requestPurchase", requestPurchase); | ||
}; | ||
|
||
console.log('requestPurchase', requestPurchase); | ||
}; | ||
fetchItem(); | ||
}, []); | ||
// 데이터 가져오기 함수 | ||
useEffect(() => { | ||
fetchItem(); | ||
}, [page, sortType]); | ||
|
||
console.log(clothing?.result.content.length); | ||
// 정렬 기준 변경 함수 | ||
const handleSortChange = (sort: string) => { | ||
setSortType(sort); | ||
}; | ||
|
||
return ( | ||
<div className="mt-69pxr ml-104pxr"> | ||
<div> | ||
<MainTitle mainTitleName="상품 종합 현황" /> | ||
<div> | ||
<TopInfo total={clothing?.result.totalElements} /> | ||
<TotalItemContent clothing={clothing} /> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
return ( | ||
<div className="mt-69pxr ml-104pxr"> | ||
<div> | ||
<MainTitle mainTitleName="상품 종합 현황" /> | ||
<div> | ||
<TopInfo | ||
total={clothing?.result.totalElements} | ||
onSortChange={handleSortChange} | ||
currentSort={sortType} | ||
/> | ||
<TotalItemContent clothing={clothing} /> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
} | ||
export default Totalitem; |