Added more data to mock-api and multiple sub-pages

This commit is contained in:
Erik Tiekstra
2021-03-31 15:31:27 +02:00
committed by Erik Tiekstra
parent 9d82c91348
commit cb5cb8b486
28 changed files with 5220 additions and 49 deletions

View File

@@ -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.

View File

@@ -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'));

File diff suppressed because it is too large Load Diff

View File

@@ -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(),

View 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,
};

View 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,
};