forked from UKSOURCE/cms.hailearning.edu.vn
UI Visa-VisaDetail
This commit is contained in:
184
routes/admin.js
184
routes/admin.js
@@ -16,7 +16,7 @@ const settingController = require("../controllers/settingController");
|
||||
const faqController = require("../controllers/faqController"); // Thêm import này
|
||||
const termsController = require("../controllers/termsController");
|
||||
const travelController = require("../controllers/travelController");
|
||||
|
||||
const visaController = require("../controllers/visaController");
|
||||
const { upload, uploadVideo, convertToWebp } = require("../middleware/upload");
|
||||
const safetyController = require("../controllers/safetyController");
|
||||
const insuranceController = require("../controllers/insuranceController");
|
||||
@@ -46,28 +46,28 @@ router.get("/about-us", ensureAuthenticated, aboutUsController.index);
|
||||
router.get(
|
||||
"/about-us/create",
|
||||
ensureAuthenticated,
|
||||
aboutUsController.createForm
|
||||
aboutUsController.createForm,
|
||||
);
|
||||
router.post("/about-us/create", ensureAuthenticated, aboutUsController.create);
|
||||
router.get(
|
||||
"/about-us/:id/edit",
|
||||
ensureAuthenticated,
|
||||
aboutUsController.editForm
|
||||
aboutUsController.editForm,
|
||||
);
|
||||
router.post(
|
||||
"/about-us/:id/update",
|
||||
ensureAuthenticated,
|
||||
aboutUsController.update
|
||||
aboutUsController.update,
|
||||
);
|
||||
router.post(
|
||||
"/about-us/:id/delete",
|
||||
ensureAuthenticated,
|
||||
aboutUsController.delete
|
||||
aboutUsController.delete,
|
||||
);
|
||||
router.get(
|
||||
"/about-us/:id/preview",
|
||||
ensureAuthenticated,
|
||||
aboutUsController.preview
|
||||
aboutUsController.preview,
|
||||
);
|
||||
|
||||
// Booking admin CRUD removed
|
||||
@@ -77,7 +77,7 @@ router.get("/form", ensureAuthenticated, formController.index);
|
||||
router.post(
|
||||
"/form/update",
|
||||
ensureAuthenticated,
|
||||
formController.updateDefaultForm
|
||||
formController.updateDefaultForm,
|
||||
);
|
||||
|
||||
// Upload routes
|
||||
@@ -93,23 +93,23 @@ router.post(
|
||||
ensureAuthenticated,
|
||||
upload.single("image"),
|
||||
// convertToWebp, // Disabled to keep original image format (JPG/PNG)
|
||||
uploadController.uploadImage
|
||||
uploadController.uploadImage,
|
||||
);
|
||||
router.post(
|
||||
"/upload/video",
|
||||
ensureAuthenticated,
|
||||
uploadVideo.single("video"),
|
||||
uploadController.uploadVideo
|
||||
uploadController.uploadVideo,
|
||||
);
|
||||
router.post(
|
||||
"/upload/update-path",
|
||||
ensureAuthenticated,
|
||||
uploadController.updateImagePath
|
||||
uploadController.updateImagePath,
|
||||
);
|
||||
router.post(
|
||||
"/upload/delete",
|
||||
ensureAuthenticated,
|
||||
uploadController.deleteImage
|
||||
uploadController.deleteImage,
|
||||
);
|
||||
|
||||
// Header routes
|
||||
@@ -118,22 +118,22 @@ router.post("/header/update", ensureAuthenticated, headerController.update);
|
||||
router.post(
|
||||
"/header/update-menu",
|
||||
ensureAuthenticated,
|
||||
headerController.updateMenu
|
||||
headerController.updateMenu,
|
||||
);
|
||||
router.get(
|
||||
"/header/menu-tree",
|
||||
ensureAuthenticated,
|
||||
headerController.getMenuTree
|
||||
headerController.getMenuTree,
|
||||
);
|
||||
router.get(
|
||||
"/header/programmes/:menuId",
|
||||
ensureAuthenticated,
|
||||
headerController.getProgrammesByMenuId
|
||||
headerController.getProgrammesByMenuId,
|
||||
);
|
||||
router.get(
|
||||
"/header/menu-item/:menuId",
|
||||
ensureAuthenticated,
|
||||
headerController.getMenuItem
|
||||
headerController.getMenuItem,
|
||||
);
|
||||
router.get("/header/data", ensureAuthenticated, headerController.getHeaderData);
|
||||
|
||||
@@ -148,7 +148,7 @@ router.post("/contact/update", ensureAuthenticated, contactController.update);
|
||||
router.get(
|
||||
"/contact/data",
|
||||
ensureAuthenticated,
|
||||
contactController.getContactData
|
||||
contactController.getContactData,
|
||||
);
|
||||
|
||||
// Activity CRUD routes
|
||||
@@ -156,81 +156,81 @@ router.get("/activity", ensureAuthenticated, activityController.index);
|
||||
router.get(
|
||||
"/activity/create",
|
||||
ensureAuthenticated,
|
||||
activityController.createForm
|
||||
activityController.createForm,
|
||||
);
|
||||
router.post("/activity/create", ensureAuthenticated, activityController.create);
|
||||
// Update filters (place before any parameterized /activity/:id routes to avoid route collision)
|
||||
router.post(
|
||||
"/activity/filters/update",
|
||||
ensureAuthenticated,
|
||||
activityController.updateFilters
|
||||
activityController.updateFilters,
|
||||
);
|
||||
// Update hero (global hero section for activities)
|
||||
router.post(
|
||||
"/activity/hero/update",
|
||||
ensureAuthenticated,
|
||||
activityController.updateHero
|
||||
activityController.updateHero,
|
||||
);
|
||||
router.get(
|
||||
"/activity/:id/edit",
|
||||
ensureAuthenticated,
|
||||
activityController.editForm
|
||||
activityController.editForm,
|
||||
);
|
||||
router.post(
|
||||
"/activity/:id/update",
|
||||
ensureAuthenticated,
|
||||
activityController.update
|
||||
activityController.update,
|
||||
);
|
||||
router.post(
|
||||
"/activity/:id/delete",
|
||||
ensureAuthenticated,
|
||||
activityController.delete
|
||||
activityController.delete,
|
||||
);
|
||||
router.post(
|
||||
"/activity/:id/toggle-status",
|
||||
ensureAuthenticated,
|
||||
activityController.toggleStatus
|
||||
activityController.toggleStatus,
|
||||
);
|
||||
// Update display order
|
||||
router.post(
|
||||
"/activity/update-order",
|
||||
ensureAuthenticated,
|
||||
activityController.updateOrder
|
||||
activityController.updateOrder,
|
||||
);
|
||||
|
||||
// Booking submissions routes
|
||||
router.get(
|
||||
"/activity/:id/bookings/count",
|
||||
ensureAuthenticated,
|
||||
activityController.getBookingCount
|
||||
activityController.getBookingCount,
|
||||
);
|
||||
router.get(
|
||||
"/activity/:id/bookings",
|
||||
ensureAuthenticated,
|
||||
activityController.getBookingSubmissions
|
||||
activityController.getBookingSubmissions,
|
||||
);
|
||||
router.get(
|
||||
"/activity/:id/bookings/export",
|
||||
ensureAuthenticated,
|
||||
activityController.exportBookingData
|
||||
activityController.exportBookingData,
|
||||
);
|
||||
// Export all bookings (across all activities)
|
||||
router.get(
|
||||
"/bookings/export-all",
|
||||
ensureAuthenticated,
|
||||
activityController.exportAllBookingsData
|
||||
activityController.exportAllBookingsData,
|
||||
);
|
||||
// Update booking submission
|
||||
router.put(
|
||||
"/bookings/:bookingId",
|
||||
ensureAuthenticated,
|
||||
bookingSubmissionController.updateBookingSubmission
|
||||
bookingSubmissionController.updateBookingSubmission,
|
||||
);
|
||||
// Delete booking submission
|
||||
router.delete(
|
||||
"/bookings/:bookingId",
|
||||
ensureAuthenticated,
|
||||
bookingSubmissionController.deleteBookingSubmission
|
||||
bookingSubmissionController.deleteBookingSubmission,
|
||||
);
|
||||
|
||||
// Update filters
|
||||
@@ -239,7 +239,7 @@ router.delete(
|
||||
router.get(
|
||||
"/activity/:id/preview",
|
||||
ensureAuthenticated,
|
||||
activityController.preview
|
||||
activityController.preview,
|
||||
);
|
||||
|
||||
// FAQ routes - Thêm vào đây
|
||||
@@ -250,8 +250,16 @@ router.get("/faq/api", faqController.api);
|
||||
|
||||
// API routes cho quản lý FAQ items (AJAX calls)
|
||||
router.post("/faq/api/add-faq", ensureAuthenticated, faqController.addFAQ);
|
||||
router.put("/faq/api/update-faq-item/:sectionId/:faqId", ensureAuthenticated, faqController.updateFAQItem);
|
||||
router.delete("/faq/api/delete-faq-item/:sectionId/:faqId", ensureAuthenticated, faqController.deleteFAQItem);
|
||||
router.put(
|
||||
"/faq/api/update-faq-item/:sectionId/:faqId",
|
||||
ensureAuthenticated,
|
||||
faqController.updateFAQItem,
|
||||
);
|
||||
router.delete(
|
||||
"/faq/api/delete-faq-item/:sectionId/:faqId",
|
||||
ensureAuthenticated,
|
||||
faqController.deleteFAQItem,
|
||||
);
|
||||
router.get("/terms-conditions", ensureAuthenticated, termsController.index);
|
||||
router.post("/terms/update", ensureAuthenticated, termsController.update);
|
||||
router.get("/terms/data", ensureAuthenticated, termsController.getTermsData);
|
||||
@@ -267,81 +275,135 @@ router.get("/travel/api", travelController.api);
|
||||
router.get("/travel/seed", ensureAuthenticated, travelController.seed);
|
||||
|
||||
// API routes cho quản lý FAQ sections (AJAX calls)
|
||||
router.post("/faq/api/add-section", ensureAuthenticated, faqController.addFAQSection);
|
||||
router.put("/faq/api/update-section/:sectionId", ensureAuthenticated, faqController.updateFAQSection);
|
||||
router.delete("/faq/api/delete-section/:sectionId", ensureAuthenticated, faqController.deleteFAQSection);
|
||||
router.post("/faq/api/reorder-sections", ensureAuthenticated, faqController.reorderFAQSection);
|
||||
router.post(
|
||||
"/faq/api/add-section",
|
||||
ensureAuthenticated,
|
||||
faqController.addFAQSection,
|
||||
);
|
||||
router.put(
|
||||
"/faq/api/update-section/:sectionId",
|
||||
ensureAuthenticated,
|
||||
faqController.updateFAQSection,
|
||||
);
|
||||
router.delete(
|
||||
"/faq/api/delete-section/:sectionId",
|
||||
ensureAuthenticated,
|
||||
faqController.deleteFAQSection,
|
||||
);
|
||||
router.post(
|
||||
"/faq/api/reorder-sections",
|
||||
ensureAuthenticated,
|
||||
faqController.reorderFAQSection,
|
||||
);
|
||||
|
||||
// API routes cho sidebar navigation (AJAX calls)
|
||||
router.put("/faq/api/update-sidebar", ensureAuthenticated, faqController.updateSidebarNav);
|
||||
router.put(
|
||||
"/faq/api/update-sidebar",
|
||||
ensureAuthenticated,
|
||||
faqController.updateSidebarNav,
|
||||
);
|
||||
|
||||
// Safety routes
|
||||
router.get("/safety", ensureAuthenticated, safetyController.index);
|
||||
router.post("/safety/update", ensureAuthenticated, safetyController.update);
|
||||
// Camp Location routes
|
||||
router.get("/camp-location", ensureAuthenticated, campLocationController.index);
|
||||
router.post("/camp-location/update", ensureAuthenticated, campLocationController.update);
|
||||
router.post(
|
||||
"/camp-location/update",
|
||||
ensureAuthenticated,
|
||||
campLocationController.update,
|
||||
);
|
||||
|
||||
//Insurance routes
|
||||
router.get("/insurance", ensureAuthenticated, insuranceController.index);
|
||||
router.post("/insurance/update", ensureAuthenticated, insuranceController.update);
|
||||
router.post(
|
||||
"/insurance/update",
|
||||
ensureAuthenticated,
|
||||
insuranceController.update,
|
||||
);
|
||||
// Test Image Paths route
|
||||
router.get("/test-images", ensureAuthenticated, (req, res) => {
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const campLocationData = require('../data/camp-location.json');
|
||||
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
const campLocationData = require("../data/camp-location.json");
|
||||
|
||||
// Collect all image paths
|
||||
const imagePaths = [];
|
||||
|
||||
|
||||
// Camps images
|
||||
if (campLocationData.camps) {
|
||||
campLocationData.camps.forEach(camp => {
|
||||
campLocationData.camps.forEach((camp) => {
|
||||
if (camp.image) {
|
||||
imagePaths.push({
|
||||
type: 'Camp',
|
||||
type: "Camp",
|
||||
name: camp.title,
|
||||
path: camp.image,
|
||||
exists: fs.existsSync(path.join(__dirname, '../public', camp.image))
|
||||
exists: fs.existsSync(path.join(__dirname, "../public", camp.image)),
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// Locations images
|
||||
if (campLocationData.locations) {
|
||||
campLocationData.locations.forEach(location => {
|
||||
campLocationData.locations.forEach((location) => {
|
||||
if (location.imageSrc) {
|
||||
imagePaths.push({
|
||||
type: 'Location',
|
||||
type: "Location",
|
||||
name: location.title,
|
||||
path: location.imageSrc,
|
||||
exists: fs.existsSync(path.join(__dirname, '../public', location.imageSrc))
|
||||
exists: fs.existsSync(
|
||||
path.join(__dirname, "../public", location.imageSrc),
|
||||
),
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// Program images
|
||||
if (location.programOptions) {
|
||||
location.programOptions.forEach(program => {
|
||||
location.programOptions.forEach((program) => {
|
||||
if (program.imageSrc) {
|
||||
imagePaths.push({
|
||||
type: 'Program',
|
||||
type: "Program",
|
||||
name: program.title,
|
||||
path: program.imageSrc,
|
||||
exists: fs.existsSync(path.join(__dirname, '../public', program.imageSrc))
|
||||
exists: fs.existsSync(
|
||||
path.join(__dirname, "../public", program.imageSrc),
|
||||
),
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
res.render('admin/test-images', {
|
||||
layout: 'layouts/admin',
|
||||
title: 'Test Image Paths',
|
||||
|
||||
res.render("admin/test-images", {
|
||||
layout: "layouts/admin",
|
||||
title: "Test Image Paths",
|
||||
images: imagePaths,
|
||||
user: req.session.user
|
||||
user: req.session.user,
|
||||
});
|
||||
});
|
||||
|
||||
// Display visa management page
|
||||
router.get("/visa", visaController.index);
|
||||
|
||||
// Update hero title
|
||||
router.post("/visa/update", ensureAuthenticated, visaController.update);
|
||||
|
||||
// Add new country
|
||||
router.post("/visa/add", ensureAuthenticated, visaController.addCountry);
|
||||
|
||||
// Update single country
|
||||
router.put(
|
||||
"/visa/update/:slug",
|
||||
ensureAuthenticated,
|
||||
visaController.updateCountry,
|
||||
);
|
||||
|
||||
// Delete country
|
||||
router.delete(
|
||||
"/delete/:slug",
|
||||
ensureAuthenticated,
|
||||
visaController.deleteCountry,
|
||||
);
|
||||
module.exports = router;
|
||||
|
||||
@@ -8,12 +8,12 @@ const headerController = require("../controllers/headerController");
|
||||
const footerController = require("../controllers/footerController");
|
||||
const contactController = require("../controllers/contactController");
|
||||
const faqController = require("../controllers/faqController");
|
||||
|
||||
const visaController = require("../controllers/visaController");
|
||||
const safetyController = require("../controllers/safetyController");
|
||||
const campLocationController = require("../controllers/campLocationController");
|
||||
// Booking flow removed
|
||||
|
||||
const insuranceController= require("../controllers/insuranceController");
|
||||
const insuranceController = require("../controllers/insuranceController");
|
||||
const termsController = require("../controllers/termsController"); // <-- IMPORT ĐÃ CÓ
|
||||
const activityController = require("../controllers/activityController");
|
||||
const travelController = require("../controllers/travelController");
|
||||
@@ -61,8 +61,7 @@ router.get("/api/activities/:id", activityController.apiDetail);
|
||||
router.get("/api/camp-location", campLocationController.api);
|
||||
// Booking routes removed
|
||||
// Insurance APi route
|
||||
router.get("/api/insurance", insuranceController.api)
|
||||
|
||||
router.get("/api/insurance", insuranceController.api);
|
||||
|
||||
router.get("/api/terms", termsController.api);
|
||||
|
||||
@@ -71,14 +70,14 @@ router.get("/travel", async (req, res) => {
|
||||
try {
|
||||
const Travel = require("../models/travel");
|
||||
const travel = await Travel.findOne();
|
||||
|
||||
|
||||
if (!travel) {
|
||||
return res.status(404).render("errors/404", {
|
||||
title: "Page Not Found",
|
||||
message: "Travel information not found",
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
res.render("page/travel", {
|
||||
title: travel.page.title,
|
||||
data: travel.toObject(),
|
||||
@@ -95,33 +94,55 @@ router.get("/api/travel", travelController.api);
|
||||
|
||||
// Booking submission APIs (public endpoints)
|
||||
router.post("/api/booking/submit", bookingSubmissionController.submitBooking);
|
||||
router.get("/api/activity/:activityId/sessions", bookingSubmissionController.getAvailableSessions);
|
||||
router.get("/api/activity/:activityId/session/:sessionId/availability", bookingSubmissionController.getSessionAvailability);
|
||||
router.get(
|
||||
"/api/activity/:activityId/sessions",
|
||||
bookingSubmissionController.getAvailableSessions,
|
||||
);
|
||||
router.get(
|
||||
"/api/activity/:activityId/session/:sessionId/availability",
|
||||
bookingSubmissionController.getSessionAvailability,
|
||||
);
|
||||
|
||||
// New API for creating bookings directly into camp sessions (by program)
|
||||
router.post(
|
||||
"/api/camps/:program/sessions/:sessionId/bookings",
|
||||
activityController.createSessionBookingByProgram
|
||||
activityController.createSessionBookingByProgram,
|
||||
);
|
||||
router.get(
|
||||
"/api/camps/:program/sessions/:sessionId/bookings",
|
||||
activityController.getSessionBookingsByProgram
|
||||
activityController.getSessionBookingsByProgram,
|
||||
);
|
||||
// Keep admin-style update/delete by activityId (protected) if needed
|
||||
router.put("/api/camps/:activityId/sessions/:sessionId/bookings/:bookingId", activityController.updateSessionBooking);
|
||||
router.delete("/api/camps/:activityId/sessions/:sessionId/bookings/:bookingId", activityController.deleteSessionBooking);
|
||||
router.put(
|
||||
"/api/camps/:activityId/sessions/:sessionId/bookings/:bookingId",
|
||||
activityController.updateSessionBooking,
|
||||
);
|
||||
router.delete(
|
||||
"/api/camps/:activityId/sessions/:sessionId/bookings/:bookingId",
|
||||
activityController.deleteSessionBooking,
|
||||
);
|
||||
|
||||
// Demo booking form
|
||||
router.get("/demo/booking-form", (req, res) => {
|
||||
res.sendFile(path.join(__dirname, '../views/demo/booking-form.html'));
|
||||
res.sendFile(path.join(__dirname, "../views/demo/booking-form.html"));
|
||||
});
|
||||
|
||||
// Demo session booking API
|
||||
router.get("/demo/session-booking-api", (req, res) => {
|
||||
res.sendFile(path.join(__dirname, '../views/demo/session-booking-api.html'));
|
||||
res.sendFile(path.join(__dirname, "../views/demo/session-booking-api.html"));
|
||||
});
|
||||
|
||||
// // API route cho blog detail
|
||||
// router.get('/api/blog-detail', blogDetailController.api);
|
||||
|
||||
// ==================== PUBLIC API ROUTES ====================
|
||||
|
||||
// 1. Đưa các route cụ thể (chi tiết nhất) lên đầu tiên
|
||||
// 2. Route lấy TOÀN BỘ dữ liệu (phải nằm trên route :slug)
|
||||
router.get("/api/visa", visaController.api);
|
||||
router.get("/api/visa/hero", visaController.apiHero);
|
||||
router.get("/api/visa/countries", visaController.apiCountries);
|
||||
|
||||
// 3. Route lấy chi tiết theo slug (luôn để dưới cùng của nhóm này)
|
||||
router.get("/api/visa/:slug", visaController.apiCountry);
|
||||
module.exports = router;
|
||||
|
||||
Reference in New Issue
Block a user