Skip to content

Commit

Permalink
Finalize programmation workflow (#70)
Browse files Browse the repository at this point in the history
  • Loading branch information
jrivals authored Dec 4, 2024
1 parent 8e34784 commit 83e2e80
Show file tree
Hide file tree
Showing 87 changed files with 2,619 additions and 1,907 deletions.
20 changes: 20 additions & 0 deletions database/migrations/022-programming-plans-status-drom.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { Knex } from 'knex';
exports.up = async (knex: Knex) => {
await knex.schema.alterTable('programming_plans', (table) => {
table.string('status_drom');
});

await knex('programming_plans').update({
status_drom: knex.raw('status')
});

await knex.schema.alterTable('programming_plans', (table) => {
table.string('status').notNullable().alter();
});
};

exports.down = async (knex: Knex) => {
await knex.schema.alterTable('programming_plans', (table) => {
table.dropColumn('status_drom');
});
};
12 changes: 12 additions & 0 deletions database/migrations/023-prescription-notes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Knex } from 'knex';
exports.up = async (knex: Knex) => {
await knex.schema.alterTable('prescriptions', (table) => {
table.string('notes');
});
};

exports.down = async (knex: Knex) => {
await knex.schema.alterTable('prescriptions', (table) => {
table.dropColumn('notes');
});
};
34 changes: 26 additions & 8 deletions database/seeds/dummy/001-users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,37 +7,55 @@ exports.seed = async function () {
await Users().insert([
{
id: uuidv4(),
email: 'admin@pspc.fr',
email: 'admin@maestro.fr',
password: bcrypt.hashSync('Test2024'),
firstName: fakerFR.person.firstName(),
lastName: fakerFR.person.lastName(),
roles: ['Administrator'],
roles: ['Administrator']
},
{
id: uuidv4(),
email: 'coordinateur.national@pspc.fr',
email: 'coordinateur.national@maestro.fr',
password: bcrypt.hashSync('Test2024'),
firstName: fakerFR.person.firstName(),
lastName: fakerFR.person.lastName(),
roles: ['NationalCoordinator'],
roles: ['NationalCoordinator']
},
{
id: uuidv4(),
email: 'coordinateur.regional@pspc.fr',
email: 'coordinateur.regional@maestro.fr',
password: bcrypt.hashSync('Test2024'),
firstName: fakerFR.person.firstName(),
lastName: fakerFR.person.lastName(),
roles: ['RegionalCoordinator'],
region: '44',
region: '44'
},
{
id: uuidv4(),
email: '[email protected]',
email: '[email protected]',
password: bcrypt.hashSync('Test2024'),
firstName: fakerFR.person.firstName(),
lastName: fakerFR.person.lastName(),
roles: ['RegionalCoordinator'],
region: '01'
},
{
id: uuidv4(),
email: '[email protected]',
password: bcrypt.hashSync('Test2024'),
firstName: fakerFR.person.firstName(),
lastName: fakerFR.person.lastName(),
roles: ['Sampler'],
region: '44',
region: '44'
},
{
id: uuidv4(),
email: '[email protected]',
password: bcrypt.hashSync('Test2024'),
firstName: fakerFR.person.firstName(),
lastName: fakerFR.person.lastName(),
roles: ['Sampler'],
region: '01'
}
]);
};
14 changes: 8 additions & 6 deletions database/seeds/dummy/003-programming-plans.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
import { v4 as uuidv4 } from 'uuid';
import { ProgrammingPlans } from '../../../server/repositories/programmingPlanRepository';
import userRepository from '../../../server/repositories/userRepository';
import { genProgrammingPlan } from '../../../shared/test/programmingPlanFixtures';

export const validatedProgrammingPlanId = uuidv4();

exports.seed = async function () {
const user = await userRepository.findOne('coordinateur.national@pspc.fr');
const user = await userRepository.findOne('coordinateur.national@maestro.fr');

if (!user) {
return;
}

await ProgrammingPlans().insert([
{
await ProgrammingPlans().insert(
genProgrammingPlan({
id: validatedProgrammingPlanId,
createdAt: new Date(),
createdBy: user.id,
status: 'Validated',
year: new Date().getFullYear(),
},
]);
statusDrom: 'Validated',
year: new Date().getFullYear()
})
);
};
50 changes: 30 additions & 20 deletions database/seeds/dummy/006-samples.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ import { ProgrammingPlans } from '../../../server/repositories/programmingPlanRe
import { SampleItems } from '../../../server/repositories/sampleItemRepository';
import {
formatPartialSample,
Samples,
Samples
} from '../../../server/repositories/sampleRepository';
import { Users } from '../../../server/repositories/userRepository';
import { Regions } from '../../../shared/referential/Region';
import { Region, Regions } from '../../../shared/referential/Region';
import { Sample } from '../../../shared/schema/Sample/Sample';
import { genCreatedSample } from '../../../shared/test/sampleFixtures';
import { oneOf } from '../../../shared/test/testFixtures';
import { Sampler1Fixture } from '../test/001-users';
import { DummyLaboratoryIds } from './002-laboratories';
import {
abricotsEtSimilaires,
Expand All @@ -19,7 +20,7 @@ import {
cerisesEtSimilaires,
fevesDeSoja,
lentilles,
oignons,
oignons
} from './004-prescriptions';

exports.seed = async function () {
Expand All @@ -28,11 +29,13 @@ exports.seed = async function () {
.first();

const sampler = await Users()
.where({ roles: ['Sampler'] })
.where({ roles: ['Sampler'], region: Sampler1Fixture.region })
.first();

const companies = await Companies();

console.log('samples', validatedProgrammingPlan, sampler);

if (!validatedProgrammingPlan || !sampler) {
return;
}
Expand All @@ -47,12 +50,13 @@ exports.seed = async function () {
matrix: 'A0DVX',
stage: 'STADE1',
status: 'Sent',
department: oneOf(Regions[sampler.region!].departments),
department: oneOf(Regions[sampler.region as Region].departments),
company: oneOf(companies),
prescriptionId: abricotsEtSimilaires.id,
laboratoryId: oneOf(DummyLaboratoryIds),
region: sampler.region as Region
}),
{ count: 2 },
{ count: 2 }
),
faker.helpers.multiple<Sample>(
() =>
Expand All @@ -63,12 +67,13 @@ exports.seed = async function () {
matrix: 'A000F',
stage: 'STADE1',
status: 'Sent',
department: oneOf(Regions[sampler.region!].departments),
department: oneOf(Regions[sampler.region as Region].departments),
company: oneOf(companies),
prescriptionId: avoineEtSimilaires.id,
laboratoryId: oneOf(DummyLaboratoryIds),
region: sampler.region as Region
}),
{ count: 8 },
{ count: 8 }
),
faker.helpers.multiple<Sample>(
() =>
Expand All @@ -79,12 +84,13 @@ exports.seed = async function () {
matrix: 'A00QH',
stage: 'STADE1',
status: 'Sent',
department: oneOf(Regions[sampler.region!].departments),
department: oneOf(Regions[sampler.region as Region].departments),
company: oneOf(companies),
prescriptionId: carottes.id,
laboratoryId: oneOf(DummyLaboratoryIds),
region: sampler.region as Region
}),
{ count: 3 },
{ count: 3 }
),
faker.helpers.multiple<Sample>(
() =>
Expand All @@ -95,12 +101,13 @@ exports.seed = async function () {
matrix: 'A01GG',
stage: 'STADE1',
status: 'Sent',
department: oneOf(Regions[sampler.region!].departments),
department: oneOf(Regions[sampler.region as Region].departments),
company: oneOf(companies),
prescriptionId: cerisesEtSimilaires.id,
laboratoryId: oneOf(DummyLaboratoryIds),
region: sampler.region as Region
}),
{ count: 4 },
{ count: 4 }
),
faker.helpers.multiple<Sample>(
() =>
Expand All @@ -111,12 +118,13 @@ exports.seed = async function () {
matrix: 'A00HC',
stage: 'STADE1',
status: 'Sent',
department: oneOf(Regions[sampler.region!].departments),
department: oneOf(Regions[sampler.region as Region].departments),
company: oneOf(companies),
prescriptionId: oignons.id,
laboratoryId: oneOf(DummyLaboratoryIds),
region: sampler.region as Region
}),
{ count: 7 },
{ count: 7 }
),
faker.helpers.multiple<Sample>(
() =>
Expand All @@ -127,12 +135,13 @@ exports.seed = async function () {
matrix: 'A013Q',
stage: 'STADE1',
status: 'Sent',
department: oneOf(Regions[sampler.region!].departments),
department: oneOf(Regions[sampler.region as Region].departments),
company: oneOf(companies),
prescriptionId: lentilles.id,
laboratoryId: oneOf(DummyLaboratoryIds),
region: sampler.region as Region
}),
{ count: 6 },
{ count: 6 }
),
faker.helpers.multiple<Sample>(
() =>
Expand All @@ -143,13 +152,14 @@ exports.seed = async function () {
matrix: 'A0DFR',
stage: 'STADE1',
status: 'Sent',
department: oneOf(Regions[sampler.region!].departments),
department: oneOf(Regions[sampler.region as Region].departments),
company: oneOf(companies),
prescriptionId: fevesDeSoja.id,
laboratoryId: oneOf(DummyLaboratoryIds),
region: sampler.region as Region
}),
{ count: 6 },
),
{ count: 6 }
)
];

const sampleItems = samples
Expand All @@ -158,7 +168,7 @@ exports.seed = async function () {
.flat();

await Samples().insert(
samples.flat().map((_: any) => formatPartialSample(_)),
samples.flat().map((_: any) => formatPartialSample(_))
);

await SampleItems().insert(sampleItems);
Expand Down
31 changes: 26 additions & 5 deletions database/seeds/test/001-users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,32 @@ import { genUser } from '../../../shared/test/userFixtures';

export const Region1Fixture = '44' as Region;
export const Region2Fixture = '52' as Region;
export const RegionDromFixture = '01' as Region;

export const Sampler1Fixture = genUser({
roles: ['Sampler'],
id: '11111111-1111-1111-1111-111111111111',
region: Region1Fixture,
firstName: 'John',
lastName: 'Doe',
email: '[email protected]',
email: '[email protected]'
});
export const Sampler2Fixture = genUser({
roles: ['Sampler'],
id: '22222222-2222-2222-2222-222222222222',
region: Region2Fixture,
firstName: 'Jane',
lastName: 'Austen',
email: '[email protected]',
email: '[email protected]'
});

export const SamplerDromFixture = genUser({
roles: ['Sampler'],
id: '66666666-6666-6666-6666-666666666666',
region: RegionDromFixture,
firstName: 'Jack',
lastName: 'Sparrow',
email: '[email protected]'
});

export const RegionalCoordinator = genUser({
Expand All @@ -28,18 +38,29 @@ export const RegionalCoordinator = genUser({
region: Region1Fixture,
firstName: 'Alice',
lastName: 'Wonderland',
email: '[email protected]',
email: '[email protected]'
});

export const RegionalDromCoordinator = genUser({
roles: ['RegionalCoordinator'],
id: '44444444-4444-4444-4444-444444444444',
region: RegionDromFixture,
firstName: 'Bob',
lastName: 'Marley',
email: '[email protected]'
});
export const NationalCoordinator = genUser({
roles: ['NationalCoordinator'],
id: '44444444-4444-4444-4444-444444444444',
id: '55555555-5555-5555-5555-555555555555'
});

exports.seed = async function () {
await Users().insert([
Sampler1Fixture,
Sampler2Fixture,
SamplerDromFixture,
RegionalCoordinator,
NationalCoordinator,
RegionalDromCoordinator,
NationalCoordinator
]);
};
6 changes: 3 additions & 3 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion frontend/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<link rel="apple-touch-icon" href="/dsfr/favicon/apple-touch-icon.png?v=1.12.1" />
<link rel="icon" href="/dsfr/favicon/favicon.svg?v=1.12.1" type="image/svg+xml" />
<link rel="shortcut icon" href="/dsfr/favicon/favicon.ico?v=1.12.1" type="image/x-icon" />
<link rel="stylesheet" href="/dsfr/utility/icons/icons.min.css?hash=483b6fe2" />
<link rel="stylesheet" href="/dsfr/utility/icons/icons.min.css?hash=19f0b40b" />
<link rel="stylesheet" href="/dsfr/dsfr.min.css?v=1.12.1" />
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/maplibre-gl.css" />

Expand Down
Loading

0 comments on commit 83e2e80

Please sign in to comment.