const HistoryPage = require("../models/historyPage"); const AUDIT_ACTIONS = require("../constants/auditAction"); const historyConfig = require("../utils/contentEditors/historyConfig"); const createPageContentController = require("./_createPageContentController"); const createRenderSingletonPageView = require("./_renderSingletonPageView"); const controller = createPageContentController({ model: HistoryPage, modelName: "HistoryPage", auditAction: AUDIT_ACTIONS.UPDATE_HISTORY, editorConfig: historyConfig, }); controller.index = async function index(req, res) { try { return await createRenderSingletonPageView({ model: HistoryPage, editorConfig: historyConfig, view: "admin/history/index", })(req, res); } catch (error) { console.error("history index error:", error); req.flash("error_msg", "Error loading History Management"); return req.session.save(() => res.redirect("/admin/dashboard")); } }; module.exports = controller;