mirror of
https://github.com/Raghu-Ch/angular-challenges.git
synced 2026-02-10 12:53:03 -05:00
feat(challenge7): add all mecanism
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
export * from './lib/push.model';
|
||||
export * from './lib/school.model';
|
||||
export * from './lib/student.model';
|
||||
export * from './lib/teacher.model';
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export type PushType = 'teacher' | 'student';
|
||||
export type PushType = 'teacher' | 'student' | 'school';
|
||||
|
||||
export interface Push {
|
||||
type: PushType;
|
||||
|
||||
21
libs/ngrx-notification/model/src/lib/school.model.ts
Normal file
21
libs/ngrx-notification/model/src/lib/school.model.ts
Normal 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';
|
||||
};
|
||||
@@ -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',
|
||||
});
|
||||
|
||||
|
||||
@@ -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',
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user