Added more staff data and staff-card page
This commit is contained in:
@@ -7,6 +7,8 @@ faker.locale = 'sv';
|
||||
const SERVICES = services.generate();
|
||||
const KOMMUN = kommuner.generate();
|
||||
const STATUSES = [true, false];
|
||||
const LANGUAGES = ['Franska', 'Nederländska', 'Arabiska', 'Spanska', 'Tyska', 'Italienska'];
|
||||
const AUTHORISATIONS = ['Hantera användare', 'Hantera origisation', 'Hantera ekonomi'];
|
||||
|
||||
function generateStaff(amount = 10) {
|
||||
const staff = [];
|
||||
@@ -20,6 +22,24 @@ function generateStaff(amount = 10) {
|
||||
kommun: KOMMUN[Math.floor(Math.random() * KOMMUN.length)].kommun,
|
||||
active: STATUSES[Math.floor(Math.random() * STATUSES.length)],
|
||||
service: SERVICES[Math.floor(Math.random() * SERVICES.length)].name,
|
||||
languages: ['Svenska', ...chooseRandom(LANGUAGES, faker.random.number(3))],
|
||||
ssn: `${faker.date.between('1950', '2000').toISOString().split('T')[0].replaceAll('-', '')}-${faker.random.number(
|
||||
{
|
||||
min: 1000,
|
||||
max: 9999,
|
||||
}
|
||||
)}`,
|
||||
phone: `07${faker.random.number(9)}-${faker.random.number({ min: 1000000, max: 9999999 })}`,
|
||||
email: faker.internet.email(),
|
||||
authorisations: chooseRandom(AUTHORISATIONS, faker.random.number(3)),
|
||||
outOfOffice: STATUSES[Math.floor(Math.random() * STATUSES.length)]
|
||||
? [
|
||||
{
|
||||
start: new Date('2021-07-12'),
|
||||
end: new Date('2021-07-24'),
|
||||
},
|
||||
]
|
||||
: [],
|
||||
});
|
||||
}
|
||||
|
||||
@@ -29,3 +49,16 @@ function generateStaff(amount = 10) {
|
||||
export default {
|
||||
generate: generateStaff,
|
||||
};
|
||||
|
||||
function chooseRandom(arr, num = 1) {
|
||||
const res = [];
|
||||
for (let i = 0; i < num; ) {
|
||||
const random = Math.floor(Math.random() * arr.length);
|
||||
if (res.indexOf(arr[random]) !== -1) {
|
||||
continue;
|
||||
}
|
||||
res.push(arr[random]);
|
||||
i++;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user