refactor: notification

This commit is contained in:
thomas
2024-05-13 16:24:11 +02:00
parent fbb9e3eccf
commit 678dd77030
37 changed files with 41 additions and 41 deletions

View File

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

View File

@@ -0,0 +1,5 @@
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 factorySchool = incrementalNumber();
export const randSchool = (): School => ({
id: factorySchool(),
name: randCompanyName(),
version: 0,
type: 'school',
});
export const isSchool = (notif: Push): notif is School => {
return notif.type === 'school';
};

View File

@@ -0,0 +1,23 @@
import { incrementalNumber, randFirstName, randLastName } from '@ngneat/falso';
import { Push } from './push.model';
export interface Student extends Push {
id: number;
firstname: string;
lastname: string;
version: number;
}
const factoryStudent = incrementalNumber();
export const randStudent = (): Student => ({
id: factoryStudent(),
firstname: randFirstName(),
lastname: randLastName(),
version: 0,
type: 'student',
});
export const isStudent = (notif: Push): notif is Student => {
return notif.type === 'student';
};

View File

@@ -0,0 +1,23 @@
import { incrementalNumber, randFirstName, randLastName } from '@ngneat/falso';
import { Push } from './push.model';
export interface Teacher extends Push {
id: number;
firstname: string;
lastname: string;
version: number;
}
const factoryTeacher = incrementalNumber();
export const randTeacher = (): Teacher => ({
id: factoryTeacher(),
firstname: randFirstName(),
lastname: randLastName(),
version: 0,
type: 'teacher',
});
export const isTeacher = (notif: Push): notif is Teacher => {
return notif.type === 'teacher';
};

View File

@@ -0,0 +1 @@
import 'jest-preset-angular/setup-jest';