<commit_before>import db from '../db';
import moment from 'moment';
import helpers from '../config/helpers';

export default {
  signUp: (req, res) => {

    db.Client.create({
      client_ID: req.body.client_ID,
      client_PW: req.body.client_PW,
      client_Name: req.body.client_Name,
      client_Email: req.body.client_Email,
      billingInfo: req.body.billingInfo,
      member: 1
    })
    .then((client) => {
      console.log('client signup: ', client.dataValues);
      res.status(201).send({
        id_token: helpers.createToken(client.dataValues),
      });
    })
    .catch((error) => {
      console.log("fail to register to the DB:", error);
      res.status(400).send("fail to register");
    })
  },

  signIn: (req, res) => {

    db.Client.findAll({ where: {
      client_ID: req.body.client_ID,
      client_PW: req.body.client_PW
    }})
    .then((client) => {
      console.log('successfully loged in');
      console.log(client[0].dataValues);
      res.status(200).send({
        id_token: helpers.createToken(client[0].dataValues),
      });
    })
    .catch((error) => {
      console.log("cannot log in:", error);
      res.send(error);
    })

  },

  getAllContracts: (req, res) => {

    db.Client.findOne({ client_Email: req.params.client_Email })
    .then((client) => {
      console.log(client.dataValues.client_Index);
      return client.dataValues.client_Index;
    })
    .then((client_Index) => {
      return db.Deal.findAll({
        where: {
          client_Index: client_Index,
          bid_Transaction: true
        }
      })
    })
    .then((deals) => {
      console.log('>>>> deals');
      let results = [];
      for (let i = 0; i < deals.length; i++) {
        console.log(deals[i].dataValues);
        results.push(deals[i].dataValues);
      }
      res.send(results);
    })
    .catch((error) => {
      console.log("cannot get contract information: ", error);
      res.send(error);
    })

  },

  getContract: (req, res) => {

    db.Client.findOne({ client_Email: req.params.client_Email })
    .then((client) => {
      console.log(client.dataValues.client_Index);
      return client.dataValues.client_Index;
    })
    .then((client_Index) => {
      return db.Deal.findAll({
        where: {
          client_Index: client_Index,
          bid_Transaction: true,
          booking_Num: req.params.booking_Num
        }
      })
    })
    .then((deal) => {
      console.log(deal[0].dataValues);
      res.send(deal[0].dataValues);
    })
    .catch((error) => {
      console.log("cannot get contract information:", error);
      res.send(error);
    })

  },

  makeContract: (req, res) => {

    db.Client.findOne({ client_Email: req.params.client_Email })
    .then((client) => {
      console.log(client.dataValues.client_Index);
      return client.dataValues.client_Index;
    })
    .then((client_Index) => {
      let now = new Date();
      let tomorrow = moment(now).add(1, 'day');

      let makeTime(date) => {
        let yyyymmdd = date.toISOString().split('T')[0];<commit_msg>(fix) Fixed syntax error<commit_after>import db from '../db';
import moment from 'moment';
import helpers from '../config/helpers';

export default {
  signUp: (req, res) => {

    db.Client.create({
      client_ID: req.body.client_ID,
      client_PW: req.body.client_PW,
      client_Name: req.body.client_Name,
      client_Email: req.body.client_Email,
      billingInfo: req.body.billingInfo,
      member: 1
    })
    .then((client) => {
      console.log('client signup: ', client.dataValues);
      res.status(201).send({
        id_token: helpers.createToken(client.dataValues),
      });
    })
    .catch((error) => {
      console.log("fail to register to the DB:", error);
      res.status(400).send("fail to register");
    })
  },

  signIn: (req, res) => {

    db.Client.findAll({ where: {
      client_ID: req.body.client_ID,
      client_PW: req.body.client_PW
    }})
    .then((client) => {
      console.log('successfully loged in');
      console.log(client[0].dataValues);
      res.status(200).send({
        id_token: helpers.createToken(client[0].dataValues),
      });
    })
    .catch((error) => {
      console.log("cannot log in:", error);
      res.send(error);
    })

  },

  getAllContracts: (req, res) => {

    db.Client.findOne({ client_Email: req.params.client_Email })
    .then((client) => {
      console.log(client.dataValues.client_Index);
      return client.dataValues.client_Index;
    })
    .then((client_Index) => {
      return db.Deal.findAll({
        where: {
          client_Index: client_Index,
          bid_Transaction: true
        }
      })
    })
    .then((deals) => {
      console.log('>>>> deals');
      let results = [];
      for (let i = 0; i < deals.length; i++) {
        console.log(deals[i].dataValues);
        results.push(deals[i].dataValues);
      }
      res.send(results);
    })
    .catch((error) => {
      console.log("cannot get contract information: ", error);
      res.send(error);
    })

  },

  getContract: (req, res) => {

    db.Client.findOne({ client_Email: req.params.client_Email })
    .then((client) => {
      console.log(client.dataValues.client_Index);
      return client.dataValues.client_Index;
    })
    .then((client_Index) => {
      return db.Deal.findAll({
        where: {
          client_Index: client_Index,
          bid_Transaction: true,
          booking_Num: req.params.booking_Num
        }
      })
    })
    .then((deal) => {
      console.log(deal[0].dataValues);
      res.send(deal[0].dataValues);
    })
    .catch((error) => {
      console.log("cannot get contract information:", error);
      res.send(error);
    })

  },

  makeContract: (req, res) => {

    db.Client.findOne({ client_Email: req.params.client_Email })
    .then((client) => {
      console.log(client.dataValues.client_Index);
      return client.dataValues.client_Index;
    })
    .then((client_Index) => {
      let now = new Date();
      let tomorrow = moment(now).add(1, 'day');

      let makeTime = (date) => {
        let yyyymmdd = date.toISOString().split('T')[0];
{'fraction_non_alphanumeric': 0.1653658536585366, 'fraction_numerical': 0.0055284552845528455, 'mean_word_length': 2.394591611479029, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 51, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6333923', 'n_tokens_mistral': 2065, 'n_tokens_neox': 2001, 'n_words': 333}