import { Action } from 'redux';
import { ERoomType } from '../definitions/ERoomType';
import { ROOM } from './actionsTypes';
// TYPE RETURN RELATED
type ISelected = string[];
export interface ITransferData {
roomId: string;
userId?: string;
departmentId?: string;
}
// ACTION RETURN RELATED
interface IBaseReturn extends Action {
rid: string;
type TSubscribeRoom = IBaseReturn;
type TUnsubscribeRoom = IBaseReturn;
type TCloseRoom = IBaseReturn;
type TRoom = Record<string, any>;
interface ILeaveRoom extends Action {
roomType: ERoomType;
room: TRoom;
selected?: ISelected;
interface IDeleteRoom extends Action {
interface IForwardRoom extends Action {
transferData: ITransferData;
interface IUserTyping extends Action {
status: boolean;
export type TActionsRoom = TSubscribeRoom & TUnsubscribeRoom & TCloseRoom & ILeaveRoom & IDeleteRoom & IForwardRoom & IUserTyping;
export function subscribeRoom(rid: string): TSubscribeRoom {
return {
type: ROOM.SUBSCRIBE,
rid
};
export function unsubscribeRoom(rid: string): TUnsubscribeRoom {
type: ROOM.UNSUBSCRIBE,
export function leaveRoom(roomType: ERoomType, room: TRoom, selected?: ISelected): ILeaveRoom {
type: ROOM.LEAVE,
room,
roomType,
selected
export function deleteRoom(roomType: ERoomType, room: TRoom, selected?: ISelected): IDeleteRoom {
type: ROOM.DELETE,
export function closeRoom(rid: string): TCloseRoom {
type: ROOM.CLOSE,
export function forwardRoom(rid: string, transferData: ITransferData): IForwardRoom {
type: ROOM.FORWARD,
transferData,
export function removedRoom(): Action {
type: ROOM.REMOVED
export function userTyping(rid: string, status = true): IUserTyping {
type: ROOM.USER_TYPING,
rid,
status