diff --git a/controllers/visaController.js b/controllers/visaController.js index ddd9029..d13d0eb 100644 --- a/controllers/visaController.js +++ b/controllers/visaController.js @@ -504,8 +504,14 @@ exports.apiCountries = async (req, res) => { // 1. Lọc bỏ 'viewDetail' khỏi từng quốc gia trong danh sách const filteredCountries = visaData.hero.summaryList.map((item) => { - // Trả về bản sao của item để giữ nguyên cấu trúc gốc bao gồm cả detailedView - return { ...item }; + // Tách detailedView ra, gom phần còn lại vào countryInfo + const { detailedView, ...countryInfo } = item; + + return { + ...countryInfo, + // Lấy mainImage từ sâu bên trong detailedView và gán vào key mới + mainImage: detailedView?.activeCountry?.mainImage || "", + }; }); // 2. Gắn baseUrl vào ảnh cho danh sách đã lọc