Fix vehicle click issue in My Vehicle Requests page
- Use car_id or fallback to car_data.local_car_id or car_data.id - Disable link if no valid car ID is available - Show "Vehicle unavailable" message when car ID is missing 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -211,9 +211,14 @@ export default function MyRequestPage() {
|
|||||||
{item.approved_vehicles.map((vehicle) => {
|
{item.approved_vehicles.map((vehicle) => {
|
||||||
const carData = vehicle.car_data;
|
const carData = vehicle.car_data;
|
||||||
const priceInfo = formatPrice(carData?.final_price);
|
const priceInfo = formatPrice(carData?.final_price);
|
||||||
|
const isSoldout = carData?.soldout === true;
|
||||||
|
// Use car_id from vehicle or fallback to local_car_id in car_data
|
||||||
|
const carId = vehicle.car_id || carData?.local_car_id || carData?.id;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div key={vehicle.id} className="bg-white rounded-lg shadow-sm overflow-hidden border">
|
<div key={vehicle.id} className={`bg-white rounded-lg shadow-sm overflow-hidden border transition-shadow ${isSoldout ? 'opacity-75' : 'hover:shadow-md'}`}>
|
||||||
|
{/* Clickable Vehicle Card */}
|
||||||
|
<Link href={carId ? `/cars/${carId}` : '#'} className={`block ${!carId ? 'pointer-events-none' : ''}`}>
|
||||||
{/* Vehicle Image */}
|
{/* Vehicle Image */}
|
||||||
<div className="relative h-40 bg-gray-200">
|
<div className="relative h-40 bg-gray-200">
|
||||||
{carData?.main_image ? (
|
{carData?.main_image ? (
|
||||||
@@ -221,16 +226,24 @@ export default function MyRequestPage() {
|
|||||||
src={carData.main_image}
|
src={carData.main_image}
|
||||||
alt={carData.car_name || 'Vehicle'}
|
alt={carData.car_name || 'Vehicle'}
|
||||||
fill
|
fill
|
||||||
className="object-cover"
|
className={`object-cover ${isSoldout ? 'grayscale' : ''}`}
|
||||||
unoptimized
|
unoptimized
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<div className="absolute inset-0 flex items-center justify-center text-gray-400">
|
<div className="absolute inset-0 flex items-center justify-center text-gray-400">
|
||||||
<svg className="w-12 h-12" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
<svg className="w-12 h-12" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||||
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z" />
|
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2 2v12a2 2 0 002 2z" />
|
||||||
</svg>
|
</svg>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
{/* Soldout Badge */}
|
||||||
|
{isSoldout && (
|
||||||
|
<div className="absolute inset-0 flex items-center justify-center bg-black/30">
|
||||||
|
<span className="bg-red-600 text-white px-4 py-2 rounded-lg font-bold text-lg transform -rotate-12 shadow-lg">
|
||||||
|
{language === 'ko' ? '판매완료' : 'SOLD OUT'}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Vehicle Info */}
|
{/* Vehicle Info */}
|
||||||
@@ -263,6 +276,45 @@ export default function MyRequestPage() {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</Link>
|
||||||
|
|
||||||
|
{/* Action Buttons */}
|
||||||
|
<div className="px-4 pb-4 flex gap-2">
|
||||||
|
{isSoldout ? (
|
||||||
|
<div className="flex-1 bg-gray-400 text-white text-sm py-2 px-3 rounded-lg text-center font-medium">
|
||||||
|
{language === 'ko' ? '판매완료' : 'Sold Out'}
|
||||||
|
</div>
|
||||||
|
) : carId ? (
|
||||||
|
<>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={() => router.push(`/cars/${carId}?action=purchase`)}
|
||||||
|
className="flex-1 bg-primary-600 text-white text-sm py-2 px-3 rounded-lg hover:bg-primary-700 transition font-medium"
|
||||||
|
>
|
||||||
|
{language === 'ko' ? '구매하기' : 'Purchase'}
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={() => {
|
||||||
|
if (user?.is_dealer) {
|
||||||
|
router.push(`/cars/${carId}?action=recommend`);
|
||||||
|
} else {
|
||||||
|
alert(language === 'ko'
|
||||||
|
? '딜러 회원만 지인 추천 기능을 사용할 수 있습니다. 딜러 등록을 원하시면 고객센터로 문의해주세요.'
|
||||||
|
: 'Only dealer members can use the referral feature. Please contact customer service to register as a dealer.');
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
className="flex-1 bg-green-600 text-white text-sm py-2 px-3 rounded-lg hover:bg-green-700 transition font-medium"
|
||||||
|
>
|
||||||
|
{language === 'ko' ? '지인에게 추천' : 'Recommend to friend'}
|
||||||
|
</button>
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<div className="flex-1 bg-gray-300 text-gray-500 text-sm py-2 px-3 rounded-lg text-center font-medium">
|
||||||
|
{language === 'ko' ? '차량 정보 없음' : 'Vehicle unavailable'}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
|||||||
Reference in New Issue
Block a user