[DetailPanel]
- cntryCd 적용 - saveToLocalStorage 로직 변경 : 중복 상품일 경우 삭제 후 최신 업데이트
This commit is contained in:
@@ -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}>
|
||||
|
||||
Reference in New Issue
Block a user