Skip to content

Instantly share code, notes, and snippets.

@chrismay
Created December 10, 2019 14:38
Show Gist options
  • Save chrismay/e87e723ec169e5cbc0e9cb42586290ea to your computer and use it in GitHub Desktop.
Save chrismay/e87e723ec169e5cbc0e9cb42586290ea to your computer and use it in GitHub Desktop.
import { Instant } from '../types';
type NotificationType = 'po-approval' | 'program-activation';
interface NotificationSharedFields {
referenceId: string;
message: string;
seen: boolean;
createdAtUtc: Instant;
notificationType: NotificationType;
}
export type PoApprovalNotification = NotificationSharedFields & {
notificationType: 'po-approval';
payload: {
batchId: string;
}
}
export type ProgramActivationNotification = NotificationSharedFields & {
notificationType: 'program-activation';
payload: {
programId: string;
}
}
export type Notification = PoApprovalNotification | ProgramActivationNotification
export function isPoApprovalNotification(n: Notification): n is PoApprovalNotification {
return n.notificationType === 'po-approval'
}
export function isProgramActivationNotification(n: Notification): n is ProgramActivationNotification {
return n.notificationType === 'program-activation'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment