import { faker } from '@faker-js/faker';
import { UserPrivilegeModel } from 'src/modules/user-related/user-privilege/data/models/user-privilege.model';
import { UserPrivilegeConfigurationHelper } from 'src/modules/user-related/user-privilege/domain/usecases/user-privilege-configuration/helpers/generate-user-privilege-configuration.helper';
import { define } from 'typeorm-seeding';

define(UserPrivilegeModel, () => {
  const created_at = new Date(
    faker.date.between({
      from: '2020-01-01T00:00:00.000Z',
      to: '2030-01-01T00:00:00.000Z',
    }),
  ).getTime();

  const configs = UserPrivilegeConfigurationHelper.createConfigurations();

  const data = new UserPrivilegeModel();
  data.name = faker.person.jobType();
  data.created_at = created_at;
  data.updated_at = created_at;

  Object.assign(data, {
    user_privilege_configurations: configs,
  });

  return data;
});
