Squashed commit of the following:
commit b8ea6da64b2fbdc1bbc0d7546c6ce859ce6981cd
Author: Aden Hassan <aden.hassan@arbetsformedlingen.se>
Date: Thu Aug 19 15:17:39 2021 +0200
minor changes to get correct employee data from mock-api
commit 715eff33a8f3cccd7ddce8bd32996190dc6597f3
Author: Aden Hassan <aden.hassan@arbetsformedlingen.se>
Date: Thu Aug 19 15:05:26 2021 +0200
minor changes and added employee email to mock-data (TV-244)
commit 454641e1fd486e4aee271d63406a28f47c299b45
Merge: f5e0950 ecb929a
Author: Aden Hassan <aden.hassan@arbetsformedlingen.se>
Date: Thu Aug 19 14:52:39 2021 +0200
merged with develop and fixed conflicts (TV-244)
commit f5e0950da2de0465fb6eaee39a0e1c13b1c52281
Author: Aden Hassan <aden.hassan@arbetsformedlingen.se>
Date: Thu Aug 19 13:31:01 2021 +0200
flyttat över grundstrukturen till edit-employee-form componenten
commit bcce2e41646b45c65929d057248b6767a832d807
Author: Aden Hassan <aden.hassan@arbetsformedlingen.se>
Date: Thu Aug 19 12:42:12 2021 +0200
pre-populated email-input and minor changes to employee model and moch-api
commit 088ed6efb0cebdea86d25094ca1fd55827f938d2
Author: arbetsformedlingen_garcn <christian.gardebrink@arbetsformedlingen.se>
Date: Thu Aug 19 11:12:57 2021 +0200
TV-244 small adjustments.
commit be17adf5d898b42467a557832e728ca3827f58d6
Author: arbetsformedlingen_garcn <christian.gardebrink@arbetsformedlingen.se>
Date: Thu Aug 19 10:43:26 2021 +0200
TV-244 extended emplyee authorizations to a list with two random authorizations.
commit cc57a6d2ceae4069d48aa670a6fea95c21ebd628
Author: Aden Hassan <aden.hassan@arbetsformedlingen.se>
Date: Thu Aug 19 10:25:42 2021 +0200
minor changes and re-wrote the mock-api to similar data for authorizations and employee-auth
commit 0a22b310729e2a359aa9f1c9d475ac875b6b2301
Author: arbetsformedlingen_garcn <christian.gardebrink@arbetsformedlingen.se>
Date: Thu Aug 19 05:37:05 2021 +0200
TV-244 wip
commit 0e80b5bc4ac14b74f1a8c58ec257ca1f6453e119
Author: arbetsformedlingen_garcn <christian.gardebrink@arbetsformedlingen.se>
Date: Wed Aug 18 17:14:48 2021 +0200
TV-244 WIP
53 lines
1.8 KiB
JavaScript
53 lines
1.8 KiB
JavaScript
import faker from 'faker';
|
|
import organizations from './organizations.js';
|
|
import tjanster from './tjanster.js';
|
|
import chooseRandom from './utils/choose-random.util.js';
|
|
|
|
faker.locale = 'sv';
|
|
|
|
const TJANSTER = tjanster.generate();
|
|
const ORGANIZATIONS = organizations.generate();
|
|
|
|
function generateEmployees(amount = 10) {
|
|
const employees = [];
|
|
|
|
for (let i = 1; i <= amount; ++i) {
|
|
const firstName = faker.name.firstName();
|
|
const lastName = faker.name.lastName();
|
|
const currentTjanster = chooseRandom(TJANSTER, faker.datatype.number({ min: 1, max: TJANSTER.length }));
|
|
const currentOrganizations = chooseRandom(ORGANIZATIONS, faker.datatype.number({ min: 1, max: 5 }));
|
|
const hasBehorigheter = Math.random() > 0.1;
|
|
|
|
const employee = {
|
|
ciamUserId: faker.datatype.uuid(),
|
|
firstName,
|
|
lastName,
|
|
name: `${firstName} ${lastName}`,
|
|
personnummer: `${faker.date
|
|
.between('1950', '2000')
|
|
.toISOString()
|
|
.split('T')[0]
|
|
.replace(/-/g, '')}-${faker.datatype.number({
|
|
min: 1000,
|
|
max: 9999,
|
|
})}`,
|
|
email: '',
|
|
roles: hasBehorigheter ? ['Admin'] : [],
|
|
tjanst: hasBehorigheter ? currentTjanster.map(tjanst => tjanst.name) : [],
|
|
tjansteKoder: hasBehorigheter ? currentTjanster.map(tjanst => tjanst.code) : [],
|
|
utforandeVerksamhet: hasBehorigheter ? currentOrganizations.map(organization => organization.name) : [],
|
|
utforandeVerksamhetIds: hasBehorigheter ? currentOrganizations.map(organization => organization.id) : [],
|
|
};
|
|
|
|
employee.email = `${employee.firstName}.${employee.lastName}@private-epost.se`.toLowerCase();
|
|
employees.push(employee);
|
|
}
|
|
|
|
console.info('Employees generated...');
|
|
return employees;
|
|
}
|
|
|
|
export default {
|
|
generate: generateEmployees,
|
|
};
|