import { createAction, props } from '@ngrx/store';
import {
  InfoRequest,
  RoomInfo,
  UserInfoShort,
  UserInfo,
  InviteNotification,
  ExitNotification,
  ExitForcingNotification,
  UpdateFontNotification,
  UpdateResponse,
  UpdateRequest,
  OpenRequest,
  OpenResponse,
  ExitRequest,
  ExitResponse,
  Open3Request,
  Open3Response,
  InviteRequest,
  InviteResponse,
  UpdateTimerSetRequest,
  UpdateTimerSetResponse
} from '@ucap-webmessenger/protocol-room';
import { ReadNotification } from '@ucap-webmessenger/protocol-event';

export const info = createAction(
  '[Messenger::Room] Info',
  props<InfoRequest>()
);

export const infoSuccess = createAction(
  '[Messenger::Room] Info Success',
  props<{
    roomInfo: RoomInfo;
    userInfoShortList: UserInfoShort[];
    userInfoList: UserInfo[];
  }>()
);

export const infoFailure = createAction(
  '[Messenger::Room] Info Failure',
  props<{ error: any }>()
);

export const inviteNotification = createAction(
  '[Messenger::Room] Invite Notification',
  props<{ noti: InviteNotification }>()
);

export const exitNotification = createAction(
  '[Messenger::Room] Exit Notification',
  props<{ noti: ExitNotification }>()
);

export const exitForcingNotification = createAction(
  '[Messenger::Room]  Exit Forcing Notification',
  props<{ noti: ExitForcingNotification }>()
);

export const updateFontNotification = createAction(
  '[Messenger::Room]  Update Font Notification',
  props<{ noti: UpdateFontNotification }>()
);

export const updateOnlyAlarm = createAction(
  '[Messenger::Room] Update Only Alarm',
  props<{ roomInfo: RoomInfo }>()
);

export const updateRoomUserLastReadSeq = createAction(
  '[Messenger::Room] Update Room User Only LastReadSeq',
  props<ReadNotification>()
);

export const update = createAction(
  '[Messenger::Room] Update',
  props<{ req: UpdateRequest }>()
);

export const updateSuccess = createAction(
  '[Messenger::Room] Update Success',
  props<{
    res: UpdateResponse;
  }>()
);

export const updateFailure = createAction(
  '[Messenger::Room] Update Failure',
  props<{ error: any }>()
);

export const updateTimeRoomInterval = createAction(
  '[Messenger::Room] Update Interval for TimeRoom',
  props<UpdateTimerSetRequest>()
);
export const updateTimeRoomIntervalSuccess = createAction(
  '[Messenger::Room] Update Interval for TimeRoom Success',
  props<{
    res: UpdateTimerSetResponse;
  }>()
);
export const updateTimeRoomIntervalFailure = createAction(
  '[Messenger::Room] Update Interval for TimeRoom Failure',
  props<{ error: any }>()
);

export const open = createAction(
  '[Messenger::Room] Open',
  props<{ req: OpenRequest }>()
);
export const openSuccess = createAction(
  '[Messenger::Room] Open Success',
  props<{
    res: OpenResponse;
  }>()
);
export const openFailure = createAction(
  '[Messenger::Room] Open Failure',
  props<{ error: any }>()
);

export const openTimer = createAction(
  '[Messenger::Room] Open Timer',
  props<{ req: Open3Request }>()
);
export const openTimerSuccess = createAction(
  '[Messenger::Room] Open Timer Success',
  props<{
    res: Open3Response;
  }>()
);
export const openTimerFailure = createAction(
  '[Messenger::Room] Open Timer Failure',
  props<{ error: any }>()
);

export const inviteOrOpen = createAction(
  '[Messenger::Room] Invite or Open',
  props<{ req: OpenRequest }>()
);
export const inviteSuccess = createAction(
  '[Messenger::Room] Invite Success',
  props<InviteResponse>()
);
export const inviteFailure = createAction(
  '[Messenger::Room] Invite Failure',
  props<{ error: any }>()
);

export const exit = createAction(
  '[Messenger::Room] Exit',
  props<ExitRequest>()
);

export const exitSuccess = createAction(
  '[Messenger::Room] Exit Success',
  props<{
    res: ExitResponse;
  }>()
);

export const exitFailure = createAction(
  '[Messenger::Room] Exit Failure',
  props<{ error: any }>()
);
