|
|
@@ -1,30 +1,44 @@
|
|
|
import React, { Fragment } from 'react';
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
|
|
-import { createSubscribedElement } from '../../UnstatedUtils';
|
|
|
import AppContainer from '../../../services/AppContainer';
|
|
|
|
|
|
+import { createSubscribedElement } from '../../UnstatedUtils';
|
|
|
+import { toastSuccess, toastError } from '../../../util/apiNotification';
|
|
|
+
|
|
|
+
|
|
|
class FullTextSearchManagement extends React.Component {
|
|
|
|
|
|
constructor(props) {
|
|
|
super(props);
|
|
|
|
|
|
- this.Buildindex = this.Buildindex.bind(this);
|
|
|
+ this.buildIndex = this.buildIndex.bind(this);
|
|
|
}
|
|
|
|
|
|
- Buildindex() {
|
|
|
+ async buildIndex() {
|
|
|
|
|
|
const { appContainer } = this.props;
|
|
|
const pageId = this.pageId;
|
|
|
|
|
|
- appContainer.apiPost('/admin/search/build', { page_id: pageId });
|
|
|
+ try {
|
|
|
+ const res = await appContainer.apiPost('/admin/search/build', { page_id: pageId });
|
|
|
+ if (!res.ok) {
|
|
|
+ throw new Error(res.message);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ toastSuccess('Building request is successfully posted.');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch (e) {
|
|
|
+ toastError(e, (new Error('エラーが発生しました')));
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
render() {
|
|
|
return (
|
|
|
<Fragment>
|
|
|
<div>
|
|
|
- <button type="submit" className="btn btn-inverse" onClick={this.Buildindex}>Build Now</button>
|
|
|
+ <button type="submit" className="btn btn-inverse" onClick={this.buildIndex}>Build Now</button>
|
|
|
</div>
|
|
|
</Fragment>
|
|
|
);
|