forked from mattermost/mattermost-webapp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
actions.ts
22 lines (16 loc) · 722 Bytes
/
actions.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {ActionResult} from 'mattermost-redux/types/actions';
export type SuccessResult = {data: any}
export type ErrorResult = {error: any}
export function isSuccess(result: ActionResult): result is SuccessResult {
return 'data' in result && !isError(result);
}
export function isError(result: ActionResult): result is ErrorResult {
return Boolean((result as ErrorResult).error);
}
export type ModalData<ModalProps> = {
modalId: string;
dialogProps?: Omit<ModalProps, 'onHide' | 'onExited'> & {onHide?: () => void; onExited?: () => void};
dialogType: React.ElementType<ModalProps>;
}