[DetailPanel]

- cntryCd 적용
- saveToLocalStorage 로직 변경 : 중복 상품일 경우 삭제 후 최신 업데이트
This commit is contained in:
jiwon93.son
2024-04-11 11:23:28 +09:00
parent a925458ae2
commit 029ef78c1e

View File

@@ -33,6 +33,7 @@ export default function ItemDetail() {
const productInfo = useSelector(
(state) => state.home.themeCurationDetailInfoData
);
const { httpHeader } = useSelector((state) => state.common);
console.log("#panels", panels);
const dispatch = useDispatch();
@@ -107,17 +108,28 @@ export default function ItemDetail() {
JSON.parse(window.localStorage.getItem("recentItems")) || [];
const currentDate = new Date();
const formattedDate = `${
currentDate.getMonth() + 1
}/${currentDate.getDate()}`;
const existingProductIndex = recentItmes.findIndex((item) => {
return item.prdtId === selectedPrdtId;
});
if (existingProductIndex !== -1) {
recentItmes.splice(existingProductIndex, 1);
}
recentItmes.push({
prdtId: selectedPrdtId,
patnrId: selectedPatnrId,
date: formattedDate,
cntryCd: "US",
cntryCd: httpHeader["X-Device-Country"],
});
window.localStorage.setItem("recentItems", JSON.stringify(recentItmes));
}, [panels, selectedPatnrId, selectedPatnrId]);
}, [panels, selectedPatnrId, selectedPatnrId, httpHeader]);
return (
<TPanel isTabActivated={false}>