Merge pull request #14 in TEA/dafa-web-monorepo from feature/more-mock-api-fixes to develop
Squashed commit of the following: commit 9473ca4e23eb6c5967d9df3403cc071d48e0ab73 Author: Erik Tiekstra <erik.tiekstra@arbetsformedlingen.se> Date: Tue Jun 1 08:18:39 2021 +0200 Adding footer commit 8f13809ad3928fd09fd67d713a61c2ca4ef27bc4 Author: Erik Tiekstra <erik.tiekstra@arbetsformedlingen.se> Date: Tue Jun 1 06:57:34 2021 +0200 Added footer commit ee8a5be048786843e3c5672368a0663ead424852 Author: Erik Tiekstra <erik.tiekstra@arbetsformedlingen.se> Date: Mon May 31 16:07:14 2021 +0200 Added size to edit icon commit b8e99713bc0190075cfe201f8cd515dca78e184e Author: Erik Tiekstra <erik.tiekstra@arbetsformedlingen.se> Date: Mon May 24 15:54:15 2021 +0200 Renamed create account to employee form and fixed some validation commit 935509bc5dd6bc7f6533b580197da2f8c15affc3 Author: Erik Tiekstra <erik.tiekstra@arbetsformedlingen.se> Date: Mon May 24 08:28:40 2021 +0200 More changes to mock-api and views commit d0bb8e1c0130c996ee89413f5ddda015fcf49ec5 Author: Erik Tiekstra <erik.tiekstra@arbetsformedlingen.se> Date: Fri May 21 11:22:40 2021 +0200 Modified mock-api and implemented a part inside employee-list
This commit is contained in:
28
mock-api/dafa-web/scripts/authorizations.js
Normal file
28
mock-api/dafa-web/scripts/authorizations.js
Normal file
@@ -0,0 +1,28 @@
|
||||
import faker from 'faker';
|
||||
|
||||
faker.locale = 'sv';
|
||||
|
||||
function generateAuthorizations() {
|
||||
return [
|
||||
{
|
||||
id: faker.datatype.uuid(),
|
||||
name: 'Hantera behörigheter',
|
||||
},
|
||||
{
|
||||
id: faker.datatype.uuid(),
|
||||
name: 'Hantera användare',
|
||||
},
|
||||
{
|
||||
id: faker.datatype.uuid(),
|
||||
name: 'Hantera organisation',
|
||||
},
|
||||
{
|
||||
id: faker.datatype.uuid(),
|
||||
name: 'Hantera ekonomi',
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
export default {
|
||||
generate: generateAuthorizations,
|
||||
};
|
||||
@@ -16,9 +16,7 @@ function generateCurrentUser() {
|
||||
min: 1000,
|
||||
max: 9999,
|
||||
})}`,
|
||||
phone: `07${faker.datatype.number(9)}-${faker.datatype.number({ min: 1000000, max: 9999999 })}`,
|
||||
email: faker.internet.email(),
|
||||
organization: ORGANIZATIONS[Math.floor(Math.random() * ORGANIZATIONS.length)],
|
||||
organizations: [ORGANIZATIONS[Math.floor(Math.random() * ORGANIZATIONS.length)]],
|
||||
authorizations: chooseRandom(AUTHORIZATIONS, faker.datatype.number(3)),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,17 +1,12 @@
|
||||
import faker from 'faker';
|
||||
import kommuner from './kommuner.js';
|
||||
import languages from './languages.js';
|
||||
import authorizations from './authorizations.js';
|
||||
import organizations from './organizations.js';
|
||||
import services from './services.js';
|
||||
|
||||
faker.locale = 'sv';
|
||||
|
||||
const SERVICES = services.generate();
|
||||
const KOMMUN = kommuner.generate();
|
||||
const ORGANIZATIONS = organizations.generate();
|
||||
const STATUSES = [true, false];
|
||||
const LANGUAGES = languages.generate();
|
||||
const AUTHORIZATIONS = ['Hantera användare', 'Hantera origisation', 'Hantera ekonomi'];
|
||||
|
||||
function generateEmployees(amount = 10) {
|
||||
const employees = [];
|
||||
@@ -27,24 +22,9 @@ function generateEmployees(amount = 10) {
|
||||
max: 9999,
|
||||
}
|
||||
)}`,
|
||||
phone: `07${faker.datatype.number(9)}-${faker.datatype.number({ min: 1000000, max: 9999999 })}`,
|
||||
email: faker.internet.email(),
|
||||
organization: ORGANIZATIONS[Math.floor(Math.random() * ORGANIZATIONS.length)],
|
||||
services: [SERVICES[Math.floor(Math.random() * SERVICES.length)].name],
|
||||
authorizations: AUTHORIZATIONS,
|
||||
// active: STATUSES[Math.floor(Math.random() * STATUSES.length)],
|
||||
// languages: [
|
||||
// LANGUAGES.find(language => language.name === 'Svenska'),
|
||||
// ...chooseRandom(LANGUAGES, faker.datatype.number(3)),
|
||||
// ],
|
||||
// outOfOffice: STATUSES[Math.floor(Math.random() * STATUSES.length)]
|
||||
// ? [
|
||||
// {
|
||||
// start: new Date('2021-07-12'),
|
||||
// end: new Date('2021-07-24'),
|
||||
// },
|
||||
// ]
|
||||
// : [],
|
||||
organizations: [ORGANIZATIONS[Math.floor(Math.random() * ORGANIZATIONS.length)]],
|
||||
services: [SERVICES[Math.floor(Math.random() * SERVICES.length)]],
|
||||
authorizations: authorizations.generate(),
|
||||
};
|
||||
|
||||
employees.push(person);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import fs from 'fs';
|
||||
import authorizations from './authorizations.js';
|
||||
import currentUser from './current-user.js';
|
||||
import employees from './employees.js';
|
||||
import kommuner from './kommuner.js';
|
||||
@@ -20,6 +21,7 @@ const apiData = {
|
||||
employeeId: generatedEmployees[Math.floor(Math.random() * generatedEmployees.length)].id,
|
||||
})),
|
||||
currentUser: currentUser.generate(),
|
||||
authorizations: authorizations.generate(),
|
||||
};
|
||||
|
||||
fs.writeFileSync('api.json', JSON.stringify(apiData, null, '\t'));
|
||||
|
||||
@@ -1,23 +1,27 @@
|
||||
import faker from 'faker';
|
||||
|
||||
faker.locale = 'sv';
|
||||
|
||||
function generateServices() {
|
||||
const services = [
|
||||
{
|
||||
id: 1,
|
||||
id: faker.datatype.uuid(),
|
||||
name: 'KROM',
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
id: faker.datatype.uuid(),
|
||||
name: 'KVL',
|
||||
},
|
||||
// {
|
||||
// id: 3,
|
||||
// id: faker.datatype.uuid(),
|
||||
// name: 'STOM',
|
||||
// },
|
||||
// {
|
||||
// id: 4,
|
||||
// id: faker.datatype.uuid(),
|
||||
// name: 'YSM',
|
||||
// },
|
||||
// {
|
||||
// id: 5,
|
||||
// id: faker.datatype.uuid(),
|
||||
// name: 'AUB',
|
||||
// },
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user