Fix loadLocalCars error handling for banner API failure
- Wrap banner API call in try-catch to prevent entire function failure - Fall back to car.is_banner field if banner API returns error - Local Cars tab now loads even if banner API fails 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -407,9 +407,16 @@ export default function CarsAdminPage() {
|
|||||||
const { data } = await api.get('/cars', { params: { page, page_size: 100, admin: true } });
|
const { data } = await api.get('/cars', { params: { page, page_size: 100, admin: true } });
|
||||||
const cars: LocalCar[] = data.cars || [];
|
const cars: LocalCar[] = data.cars || [];
|
||||||
|
|
||||||
// 배너 목록도 함께 로드 (순서 정보 포함)
|
// 배너 목록도 함께 로드 (순서 정보 포함) - 실패해도 차량 목록은 표시
|
||||||
|
let orderedBannerIds: number[] = [];
|
||||||
|
try {
|
||||||
const bannerResult = await heroBannersApi.adminGetBannerCars();
|
const bannerResult = await heroBannersApi.adminGetBannerCars();
|
||||||
const orderedBannerIds: number[] = bannerResult.car_ids || [];
|
orderedBannerIds = bannerResult.car_ids || [];
|
||||||
|
} catch (bannerErr) {
|
||||||
|
console.error('Failed to load banner cars:', bannerErr);
|
||||||
|
// 배너 로드 실패 시 car.is_banner 필드 사용
|
||||||
|
orderedBannerIds = cars.filter(c => c.is_banner).map(c => c.id);
|
||||||
|
}
|
||||||
setBannerCarIds(orderedBannerIds);
|
setBannerCarIds(orderedBannerIds);
|
||||||
|
|
||||||
// 배너 차량과 비배너 차량 분리
|
// 배너 차량과 비배너 차량 분리
|
||||||
|
|||||||
Reference in New Issue
Block a user