const Beautician = require("../../models/beautician");

exports.add = async (req, res) => {
  try {
    const addbeauticianData = req.body;
    console.log(addbeauticianData);
    await Beautician.create({
      name: addbeauticianData.name,
      email: addbeauticianData.email,
      address: addbeauticianData.address,
      tel: addbeauticianData.tel,
      shopID: addbeauticianData.shopID
    });
    res.send("create");
  } catch (err) {
    console.log(err);
    res.sendStatus(401);
  }
};

exports.getbeauticianShopId  = async (req, res) => {
  try {
    const id  = req.params.shopID;
    let beautician = await Beautician.findAll({
      where: {
        shopID: id
      }
    });
    console.log('beautician', beautician)
    res.status(200).send(beautician);
  } catch (err) {
    res.send({
      error: err.message
    });
  }
};

exports.deletelist = async (req, res) => {
  try {
    const listId = req.params.listId;
    await List.destroy({
      where: {
        id: listId
      }
    });
    res.status(200).send("success");
  } catch (err) {
    console.log(err);
    res.sendStatus(401);
  }
};