feat(challenge7): add all mecanism

This commit is contained in:
thomas
2022-11-24 14:44:34 +01:00
parent e8ffed31ec
commit b76ff2b624
34 changed files with 604 additions and 142 deletions

View File

@@ -1,3 +1,4 @@
export * from './lib/push.model';
export * from './lib/school.model';
export * from './lib/student.model';
export * from './lib/teacher.model';

View File

@@ -1,4 +1,4 @@
export type PushType = 'teacher' | 'student';
export type PushType = 'teacher' | 'student' | 'school';
export interface Push {
type: PushType;

View File

@@ -0,0 +1,21 @@
import { incrementalNumber, randCompanyName } from '@ngneat/falso';
import { Push } from './push.model';
export interface School extends Push {
id: number;
name: string;
version: number;
}
const schoolTeacher = incrementalNumber();
export const randSchool = (): School => ({
id: schoolTeacher(),
name: randCompanyName(),
version: 0,
type: 'school',
});
export const isSchool = (notif: Push): notif is School => {
return notif.type === 'school';
};

View File

@@ -1,16 +1,11 @@
import {
incrementalNumber,
randFirstName,
randLastName,
randWord,
} from '@ngneat/falso';
import { incrementalNumber, randFirstName, randLastName } from '@ngneat/falso';
import { Push } from './push.model';
export interface Student extends Push {
id: number;
firstname: string;
lastname: string;
school: string;
version: number;
}
const factoryStudent = incrementalNumber();
@@ -19,7 +14,7 @@ export const randStudent = (): Student => ({
id: factoryStudent(),
firstname: randFirstName(),
lastname: randLastName(),
school: randWord(),
version: 0,
type: 'student',
});

View File

@@ -1,25 +1,11 @@
import {
incrementalNumber,
rand,
randFirstName,
randLastName,
} from '@ngneat/falso';
import { incrementalNumber, randFirstName, randLastName } from '@ngneat/falso';
import { Push } from './push.model';
export const subject = [
'Sciences',
'History',
'English',
'Maths',
'Sport',
] as const;
export type Subject = typeof subject[number];
export interface Teacher extends Push {
id: number;
firstname: string;
lastname: string;
subject: Subject;
version: number;
}
const factoryTeacher = incrementalNumber();
@@ -28,7 +14,7 @@ export const randTeacher = (): Teacher => ({
id: factoryTeacher(),
firstname: randFirstName(),
lastname: randLastName(),
subject: rand(subject),
version: 0,
type: 'teacher',
});