diff --git a/com.twin.app.shoptime/src/views/DetailPanel/ProductInfoSection/QRCode/QRCode.jsx b/com.twin.app.shoptime/src/views/DetailPanel/ProductInfoSection/QRCode/QRCode.jsx index 9da15d9d..49009bbe 100644 --- a/com.twin.app.shoptime/src/views/DetailPanel/ProductInfoSection/QRCode/QRCode.jsx +++ b/com.twin.app.shoptime/src/views/DetailPanel/ProductInfoSection/QRCode/QRCode.jsx @@ -5,6 +5,7 @@ import { useSelector } from 'react-redux'; import TQRCode from '../../../../components/TQRCode/TQRCode'; import TQRCodeNew from '../../../../components/TQRCode/TQRCodeNew'; +import QRCodePatnr21 from './QRCodePatnr21'; import { getQRCodeUrl } from '../../../../utils/helperMethods'; import css from './QRCode.module.less'; @@ -57,22 +58,33 @@ export default function QRCode({ return detailUrl; }, [productInfo, isShopByMobile, detailUrl]); - // patnrId === 21인 경우 TQRCodeNew 사용 (원형 QR코드) + // patnrId === 21인 경우 qrImgUrl 처리 const isPatnrId21 = productInfo?.patnrId === 21 || productInfo?.patnrId === "21"; + const qrImgUrl = isPatnrId21 ? productInfo?.qrImgUrl : null; return (
{/* {qrCodeUrl && } */} {kind === "detail" ? ( isPatnrId21 ? ( - + ) : ( ) ) : ( qrCodeUrl && ( isPatnrId21 ? ( - + ) : ( ) diff --git a/com.twin.app.shoptime/src/views/DetailPanel/ProductInfoSection/QRCode/QRCodePatnr21.jsx b/com.twin.app.shoptime/src/views/DetailPanel/ProductInfoSection/QRCode/QRCodePatnr21.jsx new file mode 100644 index 00000000..6eee80fe --- /dev/null +++ b/com.twin.app.shoptime/src/views/DetailPanel/ProductInfoSection/QRCode/QRCodePatnr21.jsx @@ -0,0 +1,78 @@ +import React, { useState } from 'react'; + +import TQRCode from '../../../../components/TQRCode/TQRCode'; + +/** + * patnrId=21 전용 QR 이미지 처리 컴포넌트 + * 서버에서 제공하는 qrImgUrl을 우선 표시하고, + * 로드 실패 시 TQRCode(QR 코드 생성)로 폴백합니다. + * + * @param {string} qrImgUrl - 서버 제공 QR 이미지 URL (productData.qrImgUrl) + * @param {string} fallbackText - TQRCode 생성 시 사용할 QR 텍스트 (qrCodeUrl) + * @param {string} width - 너비 ("190" 또는 "240") + * @param {string} height - 높이 ("190" 또는 "240") + */ +export default function QRCodePatnr21({ + qrImgUrl, + fallbackText, + width = '190', + height = '190', +}) { + const [imageError, setImageError] = useState(false); + const [imageLoaded, setImageLoaded] = useState(false); + + // 1. qrImgUrl이 없으면 TQRCode 폴백 + if (!qrImgUrl) { + return ; + } + + // 2. 이미지 로드 실패 → TQRCode 폴백 + if (imageError) { + return ; + } + + // 3. 이미지 로드 성공 → 이미지 표시 (기존 QRCode와 동일한 레이아웃) + const sizeInPx = `${width}px`; + + return ( +
+ QR Code setImageLoaded(true)} + onError={() => setImageError(true)} + style={{ + display: imageLoaded ? 'block' : 'none', + width: '100%', + height: '100%', + objectFit: 'contain', + }} + /> + {!imageLoaded && ( +
+ Loading... +
+ )} +
+ ); +}