All files / src/lib/notifications types.ts

0% Statements 0/85
100% Branches 0/0
0% Functions 0/1
0% Lines 0/85

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86                                                                                                                                                                           
/**
 * Notification Types
 *
 * Type definitions for the notification system.
 */

export type NotificationType =
  | 'ORDER_UPDATE'
  | 'PROMOTION'
  | 'PRICE_DROP'
  | 'BACK_IN_STOCK'
  | 'REVIEW_RESPONSE'
  | 'SUPPORT_RESPONSE'
  | 'SYSTEM';

export interface Notification {
  id: string;
  userId: number;
  type: NotificationType;
  title: string;
  message: string;
  link?: string | null;
  read: boolean;
  readAt?: Date | null;
  createdAt: Date;
  metadata?: Record<string, unknown>;
}

export interface NotificationPreference {
  id: string;
  userId: number;
  email: boolean;
  push: boolean;
  sms: boolean;
  orders: boolean;
  reviews: boolean;
  stock: boolean;
  promotions: boolean;
}

export interface CreateNotificationParams {
  userId: number;
  type: NotificationType;
  title: string;
  message: string;
  link?: string;
  metadata?: Record<string, unknown>;
}

export interface NotificationPayload {
  id: string;
  type: NotificationType;
  title: string;
  message: string;
  link?: string;
  read: boolean;
  createdAt: string;
}

export interface NotificationsResponse {
  notifications: Notification[];
  pagination: {
    page: number;
    limit: number;
    total: number;
    pages: number;
  };
  unreadCount: number;
}

// Event types for real-time notifications
export enum NotificationEventType {
  NEW = 'notification:new',
  READ = 'notification:read',
  READ_ALL = 'notification:read-all',
  COUNT_UPDATE = 'notification:count-update',
}

// Admin-specific notification events
export enum AdminNotificationEventType {
  NEW_ORDER = 'admin:new-order',
  LOW_STOCK = 'admin:low-stock',
  NEW_REVIEW = 'admin:new-review',
  NEW_TICKET = 'admin:new-ticket',
}