import { createAction, props } from '@ngrx/store';
import {
  MessageType,
  RetrieveResponse,
  MessageSearchType,
  DelRequest,
  DelResponse,
  DetailResponse
} from '@ucap-webmessenger/api-message';

export const detailMessage = createAction(
  '[Messenger::Message] Detail Message',
  props<{
    messageType: MessageType;
    msgId: number;
  }>()
);
export const detailMessageSuccess = createAction(
  '[Messenger::Message] Detail Message Success',
  props<{
    res: DetailResponse;
  }>()
);
export const detailMessageFailure = createAction(
  '[Messenger::Message] Detail Message Failure',
  props<{ error: any }>()
);

export const detailMessageClear = createAction(
  '[Messenger::Message] Detail Message',
  props()
);

export const retrieveUnreadCount = createAction(
  '[Messenger::Message] RetrieveMessage UnreadCount',
  props()
);
export const retrieveUnreadCountSuccess = createAction(
  '[Messenger::Message] RetrieveMessage UnreadCount Success',
  props<{ count: number }>()
);
export const retrieveUnreadCountFailure = createAction(
  '[Messenger::Message] RetrieveMessage UnreadCount Failure',
  props<{ error: any }>()
);

export const retrieveMessage = createAction(
  '[Messenger::Message] RetrieveMessage',
  props<{
    messageType: MessageType;
    pageSize?: number;
    pageCount?: number;
  }>()
);
export const retrieveMessageSuccess = createAction(
  '[Messenger::Message] RetrieveMessage Success',
  props<{ res: RetrieveResponse; messageType: MessageType }>()
);
export const retrieveMessageFailure = createAction(
  '[Messenger::Message] RetrieveMessage Failure',
  props<{ error: any }>()
);

export const searchMessage = createAction(
  '[Messenger::Message] searchMessage',
  props<{
    messageType: MessageType;
    pageSize?: number;
    pageCount?: number;
    searchType?: MessageSearchType;
    searchStr?: string;
  }>()
);
export const searchMessageSuccess = createAction(
  '[Messenger::Message] searchMessage Success',
  props<{ res: RetrieveResponse; messageType: MessageType }>()
);
export const searchMessageFailure = createAction(
  '[Messenger::Message] searchMessage Failure',
  props<{ error: any }>()
);

export const deleteMessage = createAction(
  '[Messenger::Message] Delete Message',
  props<{
    messageType: MessageType;
    msgList: { msgId: number }[];
  }>()
);
export const deleteMessageSuccess = createAction(
  '[Messenger::Message] Delete Message Success',
  props<{
    messageType: MessageType;
    msgList: { msgId: number }[];
  }>()
);
export const deleteMessageFailure = createAction(
  '[Messenger::Message] Delete Message Failure',
  props<{ error: any }>()
);

export const cancelReservationMessage = createAction(
  '[Messenger::Message] Cancel Reservation Message',
  props<{
    messageType: MessageType;
    msgId: number;
  }>()
);
export const cancelReservationMessageSuccess = createAction(
  '[Messenger::Message] Cancel Reservation Message Success',
  props<{
    messageType: MessageType;
    msgId: number;
  }>()
);
export const cancelReservationMessageFailure = createAction(
  '[Messenger::Message] Cancel Reservation Message Failure',
  props<{ error: any }>()
);

export const clearSearchMessage = createAction(
  '[Messenger::Message] Clear Search Message',
  props()
);

export const clearNewFlagReceiveMessage = createAction(
  '[Messenger::Message] Clear NewFlag Message',
  props<{ msgId: number }>()
);
