const { DataTypes } = require("sequelize");
const sequelize = require("../config/database");

const ConditionCheck = sequelize.define("ConditionCheck", {
  id: {
    type: DataTypes.UUID,
    defaultValue: DataTypes.UUIDV4,
    primaryKey: true,
  },
  rentalId: {
    type: DataTypes.UUID,
    allowNull: false,
    references: {
      model: "Rentals",
      key: "id",
    },
  },
  checkType: {
    type: DataTypes.ENUM(
      "pre_rental_owner",
      "rental_start_renter",
      "rental_end_renter",
      "post_rental_owner"
    ),
    allowNull: false,
  },
  imageFilenames: {
    type: DataTypes.ARRAY(DataTypes.TEXT),
    defaultValue: [],
  },
  notes: {
    type: DataTypes.TEXT,
  },
  submittedBy: {
    type: DataTypes.UUID,
    allowNull: false,
    references: {
      model: "Users",
      key: "id",
    },
  },
  submittedAt: {
    type: DataTypes.DATE,
    allowNull: false,
    defaultValue: DataTypes.NOW,
  },
});

module.exports = ConditionCheck;