Created
December 10, 2019 14:38
-
-
Save chrismay/e87e723ec169e5cbc0e9cb42586290ea to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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