Skip to content

Commit d723ef9

Browse files
committed
fix: fix search item
1 parent 2970588 commit d723ef9

File tree

3 files changed

+21
-16
lines changed

3 files changed

+21
-16
lines changed

src/pages/price/PriceCategorySearchPage.jsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ function PriceCategorySearchPage() {
6565

6666
const currentDate = new Date();
6767
const currentYear = currentDate.getFullYear();
68-
const currentMonth = String(currentDate.getMonth() + 1).padStart(2, "0"); // 현재 월 (0부터 시작하므로 +1)
68+
const currentMonth = String(currentDate.getMonth()).padStart(2, "0");
6969
const currentSuffix = `_${currentYear}${currentMonth}`;
7070

7171
const handleCategorySelect = (categoryId) => {
@@ -115,11 +115,11 @@ function PriceCategorySearchPage() {
115115
<PriceWrapper>
116116
{Array.isArray(searchResults.products) &&
117117
searchResults.products
118-
.filter((item) => item.product_id.endsWith(currentSuffix)) // 현재 달 데이터만 필터링
118+
.filter((item) => item.product_id.endsWith(currentSuffix))
119119
.map((item) => (
120120
<PriceItem
121121
key={item.product_id}
122-
product_id={item.product_id} // product_id 수정 불필요
122+
product_id={item.product_id}
123123
product_name={item.product_name}
124124
current_month_price={item.current_month_price}
125125
previous_month_price={item.previous_month_price}

src/pages/price/PriceMainPage.jsx

+17-12
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,11 @@ function PriceMainPage() {
6565

6666
const currentDate = new Date();
6767
const currentYear = currentDate.getFullYear();
68-
const currentMonth = String(currentDate.getMonth() + 1).padStart(2, "0"); // 현재 월 (0부터 시작하므로 +1)
68+
const currentMonth = String(currentDate.getMonth()).padStart(2, "0"); // 현재 월 (0부터 시작하므로 +1)
6969
const currentSuffix = `_${currentYear}${currentMonth}`;
7070

71+
console.log(currentSuffix);
72+
7173
useEffect(() => {
7274
const fetchPrice = async () => {
7375
if (!user) {
@@ -126,17 +128,20 @@ function PriceMainPage() {
126128
<PriceWrapper>
127129
{Array.isArray(price.products) &&
128130
price.products
129-
.filter((item) => item.product_id.endsWith(currentSuffix)) // 현재 달 데이터만 필터링
130-
.map((item) => (
131-
<PriceItem
132-
key={item.product_id}
133-
product_id={item.product_id} // product_id 수정 불필요
134-
product_name={item.product_name}
135-
current_month_price={item.current_month_price}
136-
previous_month_price={item.previous_month_price}
137-
previous_two_months_price={item.previous_two_months_price}
138-
/>
139-
))}
131+
.filter((item) => item.product_id.endsWith(currentSuffix))
132+
.map((item) => {
133+
console.log("Filtered Product:", item);
134+
return (
135+
<PriceItem
136+
key={item.product_id}
137+
product_id={item.product_id}
138+
product_name={item.product_name}
139+
current_month_price={item.current_month_price}
140+
previous_month_price={item.previous_month_price}
141+
previous_two_months_price={item.previous_two_months_price}
142+
/>
143+
);
144+
})}
140145
</PriceWrapper>
141146
</Container>
142147
);

src/pages/price/PriceNameSearchPage.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ function PriceNameSearchPage() {
6363

6464
const currentDate = new Date();
6565
const currentYear = currentDate.getFullYear();
66-
const currentMonth = String(currentDate.getMonth() + 1).padStart(2, "0"); // 현재 월 (0부터 시작하므로 +1)
66+
const currentMonth = String(currentDate.getMonth()).padStart(2, "0"); // 현재 월 (0부터 시작하므로 +1)
6767
const currentSuffix = `_${currentYear}${currentMonth}`;
6868

6969
const handleSearch = async (name) => {

0 commit comments

Comments
 (0)