feat: Implement real-time messaging functionality with dedicated services, types, a custom hook, and UI integration.
This commit is contained in:
108
src/types/messaging.ts
Normal file
108
src/types/messaging.ts
Normal file
@@ -0,0 +1,108 @@
|
||||
export enum MessageType {
|
||||
TEXT = 'TEXT',
|
||||
FILE = 'FILE',
|
||||
IMAGE = 'IMAGE',
|
||||
SYSTEM = 'SYSTEM',
|
||||
}
|
||||
|
||||
export enum MessageStatus {
|
||||
SENT = 'SENT',
|
||||
DELIVERED = 'DELIVERED',
|
||||
READ = 'READ',
|
||||
}
|
||||
|
||||
export interface OtherParty {
|
||||
id: string;
|
||||
userId?: string;
|
||||
name: string;
|
||||
avatar?: string | null;
|
||||
headline?: string;
|
||||
isOnline: boolean;
|
||||
lastSeenAt?: string | null;
|
||||
}
|
||||
|
||||
export interface Conversation {
|
||||
id: string;
|
||||
userId: string;
|
||||
agentProfileId: string;
|
||||
lastMessageAt: string | null;
|
||||
lastMessageText: string | null;
|
||||
userUnreadCount: number;
|
||||
agentUnreadCount: number;
|
||||
unreadCount: number;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
otherParty: OtherParty;
|
||||
messages?: Message[];
|
||||
}
|
||||
|
||||
export interface MessageSender {
|
||||
id: string;
|
||||
role: string;
|
||||
userProfile?: {
|
||||
firstName: string | null;
|
||||
lastName: string | null;
|
||||
avatar: string | null;
|
||||
};
|
||||
agentProfile?: {
|
||||
firstName: string | null;
|
||||
lastName: string | null;
|
||||
avatar: string | null;
|
||||
};
|
||||
}
|
||||
|
||||
export interface Message {
|
||||
id: string;
|
||||
conversationId: string;
|
||||
senderId: string;
|
||||
content: string;
|
||||
messageType: MessageType;
|
||||
fileUrl?: string | null;
|
||||
fileName?: string | null;
|
||||
fileSize?: number | null;
|
||||
mimeType?: string | null;
|
||||
status: MessageStatus;
|
||||
deliveredAt?: string | null;
|
||||
readAt?: string | null;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
sender: MessageSender;
|
||||
}
|
||||
|
||||
export interface CreateMessageDto {
|
||||
content: string;
|
||||
messageType?: MessageType;
|
||||
fileUrl?: string;
|
||||
fileName?: string;
|
||||
fileSize?: number;
|
||||
mimeType?: string;
|
||||
}
|
||||
|
||||
export interface TypingIndicator {
|
||||
userId: string;
|
||||
conversationId: string;
|
||||
}
|
||||
|
||||
export interface UserStatusChange {
|
||||
userId: string;
|
||||
isOnline: boolean;
|
||||
lastSeenAt?: string | null;
|
||||
}
|
||||
|
||||
export interface MessagesReadEvent {
|
||||
conversationId: string;
|
||||
readBy: string;
|
||||
readAt: string;
|
||||
}
|
||||
|
||||
export interface PaginationInfo {
|
||||
page: number;
|
||||
limit: number;
|
||||
total: number;
|
||||
pages: number;
|
||||
}
|
||||
|
||||
export interface MessagesResponse {
|
||||
messages: Message[];
|
||||
pagination: PaginationInfo;
|
||||
}
|
||||
Reference in New Issue
Block a user