You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
962 B
TypeScript

import getCore from 'cvat-core';
import { ActionUnion, createAction, ThunkAction } from '../utils/redux';
const core = getCore();
export enum AboutActionTypes {
GET_ABOUT = 'GET_ABOUT',
GET_ABOUT_SUCCESS = 'GET_ABOUT_SUCCESS',
GET_ABOUT_FAILED = 'GET_ABOUT_FAILED',
}
const aboutActions = {
getAbout: () => createAction(AboutActionTypes.GET_ABOUT),
getAboutSuccess: (server: any) => createAction(AboutActionTypes.GET_ABOUT_SUCCESS, { server }),
getAboutFailed: (error: any) => createAction(AboutActionTypes.GET_ABOUT_FAILED, { error }),
};
export type AboutActions = ActionUnion<typeof aboutActions>;
export const getAboutAsync = (): ThunkAction => async (dispatch) => {
dispatch(aboutActions.getAbout());
try {
const about = await core.server.about();
dispatch(
aboutActions.getAboutSuccess(about),
);
} catch (error) {
dispatch(aboutActions.getAboutFailed(error));
}
};