2022-02-02 17:01:31 +00:00
|
|
|
import { Action } from 'redux';
|
|
|
|
|
2022-02-17 13:06:31 +00:00
|
|
|
import { IPermissionsState, TSupportedPermissions } from '../reducers/permissions';
|
2022-02-02 17:01:31 +00:00
|
|
|
import { PERMISSIONS } from './actionsTypes';
|
|
|
|
|
|
|
|
interface ISetPermissions extends Action {
|
2022-02-17 13:06:31 +00:00
|
|
|
permissions: IPermissionsState;
|
2022-02-02 17:01:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
interface IUpdatePermissions extends Action {
|
2022-02-17 13:06:31 +00:00
|
|
|
payload: { id: TSupportedPermissions; roles: string[] };
|
2022-02-02 17:01:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export type TActionPermissions = ISetPermissions & IUpdatePermissions;
|
|
|
|
|
2022-02-17 13:06:31 +00:00
|
|
|
export function setPermissions(permissions: IPermissionsState): ISetPermissions {
|
2022-02-02 17:01:31 +00:00
|
|
|
return {
|
|
|
|
type: PERMISSIONS.SET,
|
|
|
|
permissions
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-02-17 13:06:31 +00:00
|
|
|
export function updatePermission(id: TSupportedPermissions, roles: string[]): IUpdatePermissions {
|
2022-02-02 17:01:31 +00:00
|
|
|
return {
|
|
|
|
type: PERMISSIONS.UPDATE,
|
|
|
|
payload: { id, roles }
|
|
|
|
};
|
|
|
|
}
|