youmaylike 로직 수정
This commit is contained in:
@@ -25,6 +25,7 @@ export default function ItemDetail() {
|
||||
const [selectedPatnrId, setSelectedPatnrId] = useState("");
|
||||
const [selectedPrdtId, setSelectedPrtdId] = useState("");
|
||||
const [selectedCurationId, setSelectedCurationId] = useState("");
|
||||
const [categoryId, setCategoryId] = useState("");
|
||||
const [themeType, setThemeType] = useState("");
|
||||
const [selectedIndex, setSelectedIndex] = useState(0);
|
||||
|
||||
@@ -32,7 +33,9 @@ export default function ItemDetail() {
|
||||
const themeData = useSelector((state) => state.home.productData);
|
||||
const panels = useSelector((state) => state.panels.panels);
|
||||
const hotelData = useSelector((state) => state.home.hotelData);
|
||||
|
||||
const themeProductInfos = useSelector(
|
||||
(state) => state.home.themeCurationDetailInfoData
|
||||
);
|
||||
const { httpHeader } = useSelector((state) => state.common);
|
||||
|
||||
const dispatch = useDispatch();
|
||||
@@ -88,6 +91,7 @@ export default function ItemDetail() {
|
||||
setSelectedPrtdId("");
|
||||
setSelectedPatnrId("");
|
||||
setSelectedCurationId("");
|
||||
setCategoryId("");
|
||||
dispatch(popPanel());
|
||||
}, [dispatch]);
|
||||
|
||||
@@ -126,6 +130,25 @@ export default function ItemDetail() {
|
||||
}
|
||||
}, [panels, selectedPatnrId, selectedPatnrId, httpHeader]);
|
||||
|
||||
const getCategoryId = useCallback(() => {
|
||||
setCategoryId("");
|
||||
|
||||
if (productData && !selectedCurationId) {
|
||||
return setCategoryId(productData.catCd);
|
||||
}
|
||||
if (
|
||||
themeProductInfos[selectedIndex]?.pmtSuptYn === "N" &&
|
||||
selectedCurationId
|
||||
) {
|
||||
return setCategoryId(themeProductInfos[selectedIndex]?.catCd);
|
||||
}
|
||||
}, [productData, themeProductInfos, selectedIndex]);
|
||||
|
||||
console.log("#themeProductInfos", themeProductInfos);
|
||||
useEffect(() => {
|
||||
getCategoryId();
|
||||
}, [themeProductInfos, productData, selectedIndex]);
|
||||
|
||||
useEffect(() => {
|
||||
if (panels && selectedPatnrId && selectedPrdtId) {
|
||||
saveToLocalStorage();
|
||||
@@ -189,8 +212,11 @@ export default function ItemDetail() {
|
||||
</TBody>
|
||||
{(selectedPrdtId || themeType === "theme") && (
|
||||
<YouMayLike
|
||||
isUnable={productData?.pmtSuptYn === "N"}
|
||||
lgCatCd={productData.catCd}
|
||||
isUnable={
|
||||
productData?.pmtSuptYn === "N" ||
|
||||
themeProductInfos[selectedIndex]?.pmtSuptYn === "N"
|
||||
}
|
||||
lgCatCd={categoryId}
|
||||
/>
|
||||
)}
|
||||
</TPanel>
|
||||
|
||||
Reference in New Issue
Block a user