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

const index = async (req, res) => {
  let user = req.session?.user ?? {};
  let { baseUrl, endPoint } = getReqInformation(req);
  let settings = await getSettings();
  let feedbacks = await Feedback.findAll({
    where: {
      status: true,
    },
    order: [["id", "desc"]],
    include: [
      {
        model: User,
        attributes: ["firstName", "lastName", "image"],
      },
    ],
    limit: 5,
  });
  return res.render("about/index.ejs", {
    baseUrl,
    endPoint,
    user,
    settings,
    feedbacks,
  });
};

module.exports = {
  index,
};
