import faker from 'faker';
import chooseRandom from './utils/choose-random.util.js';

faker.locale = 'sv';

function generateUtforandeVerksamheter(amount = 10) {
  const utforandeVerksamheter = [];

  const addresses = [];
  for (let i = 1; i <= 5; ++i) {
    addresses.push({
      adressId: faker.datatype.uuid(),
      adressrad: `${faker.address.streetName()} ${faker.datatype.number({ min: 1, max: 999 })}`,
      postort: faker.address.city(),
      postnummer: faker.address.zipCode(),
    });
  }

  for (let i = 1; i <= amount; ++i) {
    utforandeVerksamheter.push({
      utforandeVerksamhetId: faker.datatype.uuid(),
      namn: faker.company.companyName(),
      leverantorNamn: faker.company.companyName(),
      tjanstId: faker.datatype.number(10),
      tjanst: faker.name.jobTitle(),
      adresser: chooseRandom(addresses, faker.datatype.number({ min: 1, max: addresses.length })),
    });
  }

  console.info('Utforande verksamheter generated...');

  return utforandeVerksamheter;
}

export default {
  generate: generateUtforandeVerksamheter,
};
