const { FAQ } = require("../../models");
const { getReqInformation, getSettings } = require("../../utils/Common");

const index = async (req, res) => {
  try {
    let user = req.session?.user ?? {};
    let { baseUrl, endPoint } = getReqInformation(req);
    let settings = await getSettings();
    let faqs = await FAQ.findAll({
      order: [["id", "desc"]],
      raw: true,
    });
    return res.render("faq/index.ejs", {
      user,
      baseUrl,
      endPoint,
      settings,
      faqs,
    });
  } catch (err) {
    return res.redirect("/");
  }
};

module.exports = {
  index,
};
