Added more data to mock-api and multiple sub-pages
This commit is contained in:
committed by
Erik Tiekstra
parent
9d82c91348
commit
cb5cb8b486
@@ -6,4 +6,4 @@ Run `npm install` to install all dependencies.
|
||||
|
||||
## Get the mock-api up and running
|
||||
|
||||
Run `npm start` and navigate to `localhost:8000` to see a simple overview of the API.
|
||||
Run `npm start` and navigate to `localhost:8000` to see a simple overview of the API. Navigate to [localhost:8000](localhost:8000) to see a quick explaination on which recources and routes are available inside the API.
|
||||
|
||||
@@ -1,8 +1,14 @@
|
||||
import fs from 'fs';
|
||||
import kommuner from './kommuner.js';
|
||||
import participants from './participants.js';
|
||||
import services from './services.js';
|
||||
import staff from './staff.js';
|
||||
|
||||
const apiData = {
|
||||
participants: participants.generate(50),
|
||||
services: services.generate(),
|
||||
staff: staff.generate(50),
|
||||
kommuner: kommuner.generate(),
|
||||
};
|
||||
|
||||
fs.writeFileSync('api.json', JSON.stringify(apiData, null, '\t'));
|
||||
|
||||
4940
mock-api/dafa-web/scripts/kommuner.js
Normal file
4940
mock-api/dafa-web/scripts/kommuner.js
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,21 +1,22 @@
|
||||
import faker from 'faker';
|
||||
import services from './services.js';
|
||||
|
||||
faker.locale = 'sv';
|
||||
|
||||
const AVAILABLE_SERVICES = ['KROM', 'STOM', 'KVL'];
|
||||
const SERVICES = services.generate();
|
||||
const STATUSES = ['active', 'follow-up'];
|
||||
const STEPS = ['Gemensam planering', 'Periodisk rapport', 'Resultatrapport', 'Slutrapport'];
|
||||
|
||||
function generateParticipants(amount = 10) {
|
||||
const participants = [];
|
||||
|
||||
for (let id = 0; id <= amount; ++id) {
|
||||
for (let id = 1; id <= amount; ++id) {
|
||||
participants.push({
|
||||
id,
|
||||
firstName: faker.name.firstName(),
|
||||
lastName: faker.name.lastName(),
|
||||
status: STATUSES[Math.floor(Math.random() * STATUSES.length)],
|
||||
service: AVAILABLE_SERVICES[Math.floor(Math.random() * AVAILABLE_SERVICES.length)],
|
||||
service: SERVICES[Math.floor(Math.random() * SERVICES.length)].name,
|
||||
nextStep: STEPS[Math.floor(Math.random() * STEPS.length)],
|
||||
errandNumber: faker.random.number({ min: 100000, max: 999999 }),
|
||||
startDate: faker.date.recent(),
|
||||
|
||||
28
mock-api/dafa-web/scripts/services.js
Normal file
28
mock-api/dafa-web/scripts/services.js
Normal file
@@ -0,0 +1,28 @@
|
||||
function generateServices() {
|
||||
return [
|
||||
{
|
||||
id: 1,
|
||||
name: 'KROM',
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: 'STOM',
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
name: 'KVL',
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
name: 'YSM',
|
||||
},
|
||||
{
|
||||
id: 5,
|
||||
name: 'AUB',
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
export default {
|
||||
generate: generateServices,
|
||||
};
|
||||
30
mock-api/dafa-web/scripts/staff.js
Normal file
30
mock-api/dafa-web/scripts/staff.js
Normal file
@@ -0,0 +1,30 @@
|
||||
import faker from 'faker';
|
||||
import kommuner from './kommuner.js';
|
||||
import services from './services.js';
|
||||
|
||||
faker.locale = 'sv';
|
||||
|
||||
const SERVICES = services.generate();
|
||||
const KOMMUN = kommuner.generate();
|
||||
const STATUSES = [true, false];
|
||||
|
||||
function generateStaff(amount = 10) {
|
||||
const staff = [];
|
||||
|
||||
for (let id = 1; id <= amount; ++id) {
|
||||
staff.push({
|
||||
id,
|
||||
firstName: faker.name.firstName(),
|
||||
lastName: faker.name.lastName(),
|
||||
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,
|
||||
});
|
||||
}
|
||||
|
||||
return staff;
|
||||
}
|
||||
|
||||
export default {
|
||||
generate: generateStaff,
|
||||
};
|
||||
Reference in New Issue
Block a user