/*
 * @Author: your name
 * @Date: 2020-11-19 16:54:53
 * @LastEditTime: 2020-12-08 16:20:13
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \tostumi\src\utils\tip.ts
 */
// 只能输入字母数字限制
const inputNumberStr = (rule: any, value: any, callback: any) => {
  if (value) {
    if (/^[a-zA-Z0-9]+$/g.test(value)) {
      callback();
    } else {
      callback(new Error('Only numbers and letters can be entered!'));
    }
  } else {
    callback(new Error('Required!'));
  }
};

// 只能输入数字限制
const inputNumber = (rule: any, value: any, callback: any) => {
  if (value) {
    if (/^[0-9]+$/g.test(value)) {
      callback();
    } else {
      callback(new Error('Only numbers!'));
    }
  } else {
    callback(new Error('Required!'));
  }
};

// 只能输入数字限制 电话提示
const inputNumberTel = (rule: any, value: any, callback: any) => {
  if (value) {
    if (
      (/^[0-9]+$/g.test(value) && value.length == 8) ||
      (/^[0-9]+$/g.test(value) && value.length == 11)
    ) {
      callback();
    } else {
      callback(new Error('Please input contact information (8-11 digits)!'));
    }
  } else {
    callback(new Error('Required!'));
  }
};

const reqMes = (msg: string) => {
  return {
    required: true,
    message: msg,
  };
};

// 合同提示
export const tipList = [
  [reqMes('Please Input Contract Numbe!')],
  [reqMes('Please Input Contract Party A!')],
  [reqMes('Please Input Contract Party B!')],
  [reqMes('Please Choice CommunityName!')],
  [reqMes('Please Choice Contract Title!')],
  [reqMes('Please Choice Contract Time!')],
  [reqMes('Please upload Contract Annex!')],
  // [reqMes('Please Input Contract Remarks!')],
];

// 小区提示
export const village = [
  [reqMes('Please enter the postcode !')],
  [reqMes('Please enter the address of the community !')],
  [reqMes('Please enter the cell name !')],
  [reqMes('Please select the time !')],
  [reqMes('Please enter your mobile phone number !')],
  [{ ...reqMes('Please enter the correct email address !'), type: 'email' }],
  [reqMes('Please enter the name of the community administrator !')],
];

//公告提示
export const Notice = [
  [reqMes('Please select community')],
  [reqMes('Please input the notice title.')],
  [reqMes('Please input the announcement content.')],
  [reqMes('Please choose the effective time of the announcement.')],
];

// 新增设施
export const NewFaci = [
  [reqMes('Please select community')],
  [reqMes('Please input Facility Name')],
  [reqMes('Please Set management fee')],
  [reqMes('Please Set Setting deposit')],
  [reqMes('Please Upload facility photos')],
  [reqMes('Required')],
  [reqMes('Required')],
  [reqMes('Required')],
  [reqMes('Required')],
  [reqMes('Required')],
];

// 设施预订
export const BookingsTip = [
  [reqMes('Please input Name ')],
  [{ ...reqMes('Please input contact information (8-11 digits)'), validator: inputNumberTel }],
  // [{ required: true, pattern: new RegExp(/^[1-9]\d*$/, 'g'), message: 'Only numbers!')],
  [{ required: true, message: 'Only numbers!', validator: inputNumber }],
  [{ required: true, message: 'Only numbers!', validator: inputNumber }],
  [{ required: true, message: 'Only numbers!', validator: inputNumberStr }],
  [reqMes('Please Select The Date')],
];

// 账号新增编辑
export const AccountTip = [
  [{ ...reqMes('Please enter email address !'), type: 'email' }],
  [reqMes('Required')],
  [reqMes('Please enter the correct contact information !')],
];
