export function generateRandom(length: number, is_number?: boolean): string {
  let result = '';
  let base = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
  if (is_number) base = '123456789';

  let counter = 0;
  while (counter < length) {
    result += base.charAt(Math.floor(Math.random() * base.length));
    counter += 1;
  }

  return result;
}

export function generateCodeDate() {
  const date = new Date();
  const month =
    date.getMonth() < 10
      ? `0${date.getMonth() + 1}`
      : (date.getMonth() + 1).toString();
  const year = date.getFullYear().toString().slice(-2);

  return `${month}${year}`;
}

export function padCode(number: number, pad = 4): string {
  return String(number).padStart(pad, '0');
}
