diff --git a/public/uploads/service/Learning.jpg b/public/uploads/service/Learning.jpg new file mode 100644 index 0000000..2da0dbd Binary files /dev/null and b/public/uploads/service/Learning.jpg differ diff --git a/services/service.service.js b/services/service.service.js index 64483a6..95eaaed 100644 --- a/services/service.service.js +++ b/services/service.service.js @@ -2,7 +2,6 @@ const Service = require("../models/service"); const getServiceData = async () => { const service = await Service.findOne().sort({ updatedAt: -1 }); - console.log("check layout", service.services.items.layout); if (!service) { return { diff --git a/views/admin/service/details.ejs b/views/admin/service/details.ejs index 52cb7bb..7ae2720 100644 --- a/views/admin/service/details.ejs +++ b/views/admin/service/details.ejs @@ -249,9 +249,9 @@
- + + value="<%= faq.id || 'faq-' + (index + 1) %>" readonly>
@@ -399,20 +399,22 @@ function removeFeature(button) { function addFAQ() { const container = document.getElementById('faqContainer'); + const newFaqId = generateFAQId(); + const faqNumber = document.querySelectorAll('.faq-item').length + 1; const faqHtml = `
-
FAQ ${faqIndex + 1}
+
FAQ ${faqNumber}
- + + value="${newFaqId}" readonly>
@@ -441,13 +443,43 @@ function addFAQ() { faqIndex++; } +function updateFAQId(questionInput) { + // Không cần update ID nữa vì đã tự động theo số thứ tự +} + function removeFAQ(button) { const faqItem = button.closest('.faq-item'); if (faqItem) { faqItem.remove(); + // Cập nhật lại số thứ tự và ID của tất cả FAQ + updateFAQNumbers(); } } +function generateFAQId() { + // Đếm số lượng FAQ hiện tại và tạo ID tiếp theo + const existingFAQs = document.querySelectorAll('.faq-item'); + const nextNumber = existingFAQs.length + 1; + return `faq-${nextNumber}`; +} + +function updateFAQNumbers() { + // Cập nhật lại tất cả FAQ ID và số thứ tự + const faqItems = document.querySelectorAll('.faq-item'); + faqItems.forEach((item, index) => { + const number = index + 1; + const idInput = item.querySelector('.faq-id'); + const titleElement = item.querySelector('h6'); + + if (idInput) { + idInput.value = `faq-${number}`; + } + if (titleElement) { + titleElement.textContent = `FAQ ${number}`; + } + }); +} + function updateAllJsonInputs(data) { // Collect basic details data const details = { diff --git a/views/admin/service/index.ejs b/views/admin/service/index.ejs index f5fbb43..d375ea9 100644 --- a/views/admin/service/index.ejs +++ b/views/admin/service/index.ejs @@ -283,6 +283,43 @@
+ + +