const { error, success } = require("../../handlers");
const { Setting } = require("../../models");
const { Op } = require("sequelize");
const settingKeysArr = [
  "aboutUs",
  "privacyPolicy",
  "termsAndConditions",
  "phoneNo",
  "email",
  "address",
  "facebook",
  "twitter",
  "instagram",
  "contactInfoEmail",
  "contactInfoMobileNo",
  "appLink"
];

const index = async (req, res) => {
  try {
    let settings = await Setting.findAll({
      where: {
        key: {
          [Op.in]: settingKeysArr,
        },
      },
      attributes: ["key", "value"],
    });
    return success(res, {
      msg: "Settings details listed successfully!!",
      data: settings,
    });
  } catch (err) {
    return error(res, {
      msg: "Something went wrong!!",
    });
  }
};

module.exports = {
  index,
};
