2021-12-21 15:03:59 +00:00
|
|
|
import { Action } from 'redux';
|
|
|
|
|
2021-12-23 13:20:38 +00:00
|
|
|
import { ISelectedUser } from '../reducers/selectedUsers';
|
2021-12-21 15:03:59 +00:00
|
|
|
import * as types from './actionsTypes';
|
|
|
|
|
2021-12-29 13:33:41 +00:00
|
|
|
type TUser = {
|
2021-12-23 13:20:38 +00:00
|
|
|
user: ISelectedUser;
|
2021-12-21 15:03:59 +00:00
|
|
|
};
|
|
|
|
|
2021-12-29 16:19:48 +00:00
|
|
|
type TAction = Action & TUser;
|
2021-12-21 15:03:59 +00:00
|
|
|
|
2021-12-29 13:33:41 +00:00
|
|
|
interface ISetLoading extends Action {
|
2021-12-21 15:03:59 +00:00
|
|
|
loading: boolean;
|
|
|
|
}
|
|
|
|
|
2021-12-29 16:19:48 +00:00
|
|
|
export type TActionSelectedUsers = TAction & ISetLoading;
|
2021-12-21 15:03:59 +00:00
|
|
|
|
2021-12-29 16:19:48 +00:00
|
|
|
export function addUser(user: ISelectedUser): TAction {
|
2021-12-21 15:03:59 +00:00
|
|
|
return {
|
|
|
|
type: types.SELECTED_USERS.ADD_USER,
|
|
|
|
user
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-12-29 16:19:48 +00:00
|
|
|
export function removeUser(user: ISelectedUser): TAction {
|
2021-12-21 15:03:59 +00:00
|
|
|
return {
|
2021-12-22 12:28:21 +00:00
|
|
|
type: types.SELECTED_USERS.REMOVE_USER,
|
2021-12-21 15:03:59 +00:00
|
|
|
user
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export function reset(): Action {
|
|
|
|
return {
|
|
|
|
type: types.SELECTED_USERS.RESET
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-12-29 13:33:41 +00:00
|
|
|
export function setLoading(loading: boolean): ISetLoading {
|
2021-12-21 15:03:59 +00:00
|
|
|
return {
|
|
|
|
type: types.SELECTED_USERS.SET_LOADING,
|
|
|
|
loading
|
|
|
|
};
|
|
|
|
}
|