diff --git a/src/pages/spaceDetail.js b/src/pages/spaceDetail.js
index d992f47..eff740d 100644
--- a/src/pages/spaceDetail.js
+++ b/src/pages/spaceDetail.js
@@ -17,7 +17,7 @@ export default function SpaceDetail({type: propType}) {
const [showContact, setShowContact] = useState(false);
const [isLoading, setIsLoading] = useState(true);
const [coordinates, setCoordinates] = useState(null);
- const URL = process.env.REACT_APP_SPACE_API;
+ const URL = process.env.REACT_APP_SPACE_API;
const convertAddressToCoords = (address) => {
return new Promise((resolve, reject) => {
@@ -40,8 +40,6 @@ export default function SpaceDetail({type: propType}) {
});
};
-
-
useEffect(() => {
const fetchSpaceDetail = async () => {
try {
@@ -75,7 +73,6 @@ export default function SpaceDetail({type: propType}) {
} catch (error) {
console.error("Error fetching space detail:", error);
setIsLoading(false);
- // 에러 처리 추가
alert(error.response?.data?.message || error.message || '공간 정보를 불러오는데 실패했습니다.');
}
};
@@ -85,10 +82,8 @@ export default function SpaceDetail({type: propType}) {
}
}, [id, propType, URL]);
-
-
if(isLoading){
- return
로딩중...
}
if(!spaceData){
@@ -100,7 +95,7 @@ export default function SpaceDetail({type: propType}) {
state: {
spacetype: spaceData.space_type,
spaceId: spaceData.space_id,
- name: spaceData.space_name, // name -> space_name으로 수정
+ name: spaceData.space_name,
price: `${spaceData.unit_price.toLocaleString()}원 / ${spaceData.usage_unit}`
}
});
@@ -138,17 +133,17 @@ export default function SpaceDetail({type: propType}) {
);
- };
+ };
- const renderImage = (src, alt) => (
+ const renderImage = (imageUrl, alt) => (
-
{spaceData.space_name}
+
{spaceData.name || spaceData.space_name}
{spaceData.location.sido}
@@ -181,8 +176,8 @@ export default function SpaceDetail({type: propType}) {
{({ isActive }) => (
{renderImage(
- img.url || img.filename,
- `${spaceData.space_name} 이미지 ${index + 1}`
+ img.thumbnail || img.url || '/images/default-image.png',
+ `${spaceData.name || spaceData.space_name} 이미지 ${index + 1}`
)}
)}
@@ -190,11 +185,10 @@ export default function SpaceDetail({type: propType}) {
))}
) : (
- // 이미지가 없을 경우 기본 이미지 표시
{renderImage(
- "/default-image.png",
- `${spaceData.space_name} 기본 이미지`
+ "/images/default-image.png",
+ `${spaceData.name || spaceData.space_name} 기본 이미지`
)}
)}
@@ -222,7 +216,7 @@ export default function SpaceDetail({type: propType}) {
-
{spaceData.space_name} 소개
+
{spaceData.name || spaceData.space_name} 소개
{spaceData.content}
{spaceData.amenities && (
@@ -244,7 +238,7 @@ export default function SpaceDetail({type: propType}) {
>
)}
diff --git a/src/pages/spaceList.js b/src/pages/spaceList.js
index 4c0c547..2d9842c 100644
--- a/src/pages/spaceList.js
+++ b/src/pages/spaceList.js
@@ -16,39 +16,13 @@ export default function SpaceList({ type: propType }) {
const itemsPerPage = 10;
const URL = process.env.REACT_APP_SPACE_API;
- const S3_BUCKET_URL = process.env.REACT_APP_S3_BUCKET_URL || "https://space-place-bucket.s3.amazonaws.com";
- const getFileExtension = (originalFilename) => {
- if(!originalFilename) return '';
- const match = originalFilename.match(/\.([^.]+)$/);
- return match ? match[1].toLowerCase() : '';
- };
-
- const constructImageUrl = (vendorId, spaceId, image) => {
- if (!vendorId || !spaceId || !image?.filename) {
- return "/images/default-image.png";
- }
-
- const extension = getFileExtension(image.original_filename);
- const fullFilename = image.filename.includes('.') ?
- image.filename :
- `${image.filename}.${extension}`;
-
- return `${S3_BUCKET_URL}/${vendorId}/${spaceId}/${fullFilename}`;
- };
-
const getImageUrl = (space) => {
try {
- if (!space?.images || !Array.isArray(space.images) || space.images.length === 0) {
+ if (!space?.thumbnail) {
return '/images/default-image.png';
}
-
- const firstImage = space.images[0];
- if (!firstImage?.filename) {
- return '/images/default-image.png';
- }
-
- return constructImageUrl(space.vendor_id, space.space_id, firstImage);
+ return space.thumbnail;
} catch (error) {
console.error('Error in getImageUrl:', error);
return '/images/default-image.png';
@@ -81,7 +55,6 @@ export default function SpaceList({ type: propType }) {
}
};
-
const handleItemClick = (spaceId) => {
navigate(`/space/${type}/${spaceId}`);
};
@@ -104,15 +77,15 @@ export default function SpaceList({ type: propType }) {
{space.name}
-
{
- console.log('Image load failed, falling back to default');
- e.target.onerror = null;
- e.target.src = '/images/default-image.png';
- }}
- className="space-image"
+
{
+ console.log('Image load failed, falling back to default');
+ e.target.onerror = null;
+ e.target.src = '/images/default-image.png';
+ }}
+ className="space-image"
/>