notification module refactor
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
import type { NotificationType } from './notification.interface';
|
||||
import type { NotificationTitle } from '../entities/notification.entity';
|
||||
import type { NotificationTitleEnum } from './notification.interface';
|
||||
|
||||
export interface NotificationQueueJob {
|
||||
restaurantId: string;
|
||||
userId?: string;
|
||||
title: NotificationTitle;
|
||||
title: NotificationTitleEnum;
|
||||
content: string;
|
||||
idempotencyKey?: string;
|
||||
notificationId?: string; // For retries
|
||||
|
||||
@@ -1,6 +1,44 @@
|
||||
export enum NotificationTitleEnum {
|
||||
ORDER_CREATED = 'order.created',
|
||||
PAYMENT_SUCCESS = 'payment.success',
|
||||
REVIEW_CREATED = 'review.created',
|
||||
ORDER_STATUS_CHANGED = 'order.status.changed',
|
||||
}
|
||||
|
||||
export enum NotificationType {
|
||||
NONE = 'none',
|
||||
SMS = 'sms',
|
||||
PUSH = 'push',
|
||||
Both = 'both',
|
||||
}
|
||||
interface INotifySmsPayload {
|
||||
[key: string]: string | number | Date;
|
||||
}
|
||||
interface INotifySms {
|
||||
phone: string;
|
||||
subject: NotificationTitleEnum;
|
||||
}
|
||||
// Sub intefaces
|
||||
// 1. Order Created Sms Notify Payload
|
||||
interface IOrderCreatedSmsNotifyPayload extends INotifySmsPayload {
|
||||
orderNumber: string;
|
||||
orderAmount: number;
|
||||
orderDate: Date;
|
||||
}
|
||||
|
||||
interface IOrderCreatedSmsNotify extends INotifySms {
|
||||
subject: NotificationTitleEnum.ORDER_CREATED;
|
||||
payload: IOrderCreatedSmsNotifyPayload;
|
||||
}
|
||||
// 2. Payment Success
|
||||
interface IPaymentSuccessSmsNotifyPayload extends INotifySmsPayload {
|
||||
amount: number;
|
||||
date: Date;
|
||||
}
|
||||
|
||||
interface IPaymentSuccessSmsNotify extends INotifySms {
|
||||
subject: NotificationTitleEnum.PAYMENT_SUCCESS;
|
||||
payload: IPaymentSuccessSmsNotifyPayload;
|
||||
}
|
||||
|
||||
export type ISmsNotifyPayload = IOrderCreatedSmsNotify | IPaymentSuccessSmsNotify;
|
||||
|
||||
Reference in New Issue
Block a user