no redux
This commit is contained in:
@@ -1,10 +1,6 @@
|
||||
import { Component } from 'react';
|
||||
import { connect } from 'react-redux';
|
||||
import { ActionTile } from '../tiles';
|
||||
import {
|
||||
createArticles as createArticlesThunk,
|
||||
createArticle as createArticleThunk,
|
||||
} from '../../store/categorySlice';
|
||||
import categoryAutomat from '../../automats/categoryAutomat';
|
||||
import ArticleNameDialog from './ArticleNameDialog';
|
||||
|
||||
class NewArticleTile extends Component {
|
||||
@@ -28,15 +24,16 @@ class NewArticleTile extends Component {
|
||||
const { parentId } = this.props;
|
||||
const list = (names ?? []).filter(Boolean);
|
||||
if (list.length <= 1) {
|
||||
const article = await this.props
|
||||
.createArticle({ parentId, name: list[0] ?? '' })
|
||||
.unwrap();
|
||||
const article = await categoryAutomat.actions.createArticle({
|
||||
parentId,
|
||||
name: list[0] ?? '',
|
||||
});
|
||||
if (article) {
|
||||
this.props.onOpenArticle?.(article);
|
||||
}
|
||||
return;
|
||||
}
|
||||
const created = await this.props.createArticles({ parentId, names: list }).unwrap();
|
||||
const created = await categoryAutomat.actions.createArticles({ parentId, names: list });
|
||||
if (created?.[0]) {
|
||||
this.props.onOpenArticle?.(created[0]);
|
||||
}
|
||||
@@ -62,9 +59,4 @@ class NewArticleTile extends Component {
|
||||
}
|
||||
}
|
||||
|
||||
const mapDispatchToProps = {
|
||||
createArticle: createArticleThunk,
|
||||
createArticles: createArticlesThunk,
|
||||
};
|
||||
|
||||
export default connect(null, mapDispatchToProps)(NewArticleTile);
|
||||
export default NewArticleTile;
|
||||
|
||||
Reference in New Issue
Block a user