no redux
This commit is contained in:
@@ -14,7 +14,7 @@ import CheckIcon from '@mui/icons-material/Check';
|
||||
import FolderIcon from '@mui/icons-material/Folder';
|
||||
import FolderOpenIcon from '@mui/icons-material/FolderOpen';
|
||||
import Box from '@mui/material/Box';
|
||||
import { getCategoryChildren, categoryDisplayName } from '../../store/categorySlice';
|
||||
import { getCategoryChildren, categoryDisplayName } from '../../utils/categoryUtils';
|
||||
function CategoryNode({
|
||||
categories,
|
||||
categoryId,
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -2,7 +2,7 @@ import { Component, PureComponent } from 'react';
|
||||
import { EditablePanelTile } from 'dashgui/panels';
|
||||
import SingleLineTextEdit from 'dashgui/SingleLineTextEdit';
|
||||
import { StorageManagerContext } from '../../../api/storageManagerContext';
|
||||
import { getCategoryBreadcrumbs } from '../../../store/categorySlice';
|
||||
import { getCategoryBreadcrumbs } from '../../../utils/categoryUtils';
|
||||
import { Box, Chip, IconButton } from '@mui/material';
|
||||
import AddIcon from '@mui/icons-material/Add';
|
||||
import CategoryPickerDialog from '../CategoryPickerDialog';
|
||||
|
||||
@@ -169,12 +169,7 @@ function priceDraftValid(draft) {
|
||||
|
||||
function companyFromStore(store) {
|
||||
if (!store) return null;
|
||||
const companies = store.companies;
|
||||
const session = store.authMe;
|
||||
if (companies == null || session == null) return null;
|
||||
const companyId = session.user?.selectedCompanyId;
|
||||
if (companyId == null) return null;
|
||||
return companies.find((c) => c.id === companyId) ?? null;
|
||||
return store.company ?? null;
|
||||
}
|
||||
|
||||
class PriceAmountField extends Component {
|
||||
@@ -395,18 +390,12 @@ export default class ArticleViewPrice extends PureComponent {
|
||||
async load() {
|
||||
const store = this.context;
|
||||
try {
|
||||
const [unitList, companies, session] = await Promise.all([
|
||||
const [unitList, company] = await Promise.all([
|
||||
store.unitPromise,
|
||||
store.companyPromise,
|
||||
store.authMePromise,
|
||||
]);
|
||||
const companyId = requireDefined(session.user?.selectedCompanyId, 'selectedCompanyId');
|
||||
const current = requireDefined(
|
||||
companies.find((c) => c.id === companyId),
|
||||
'company',
|
||||
);
|
||||
if (!this._cancelled) {
|
||||
this.setState({ units: unitList, company: current });
|
||||
this.setState({ units: unitList, company: company ?? null });
|
||||
}
|
||||
} catch (err) {
|
||||
if (!this._cancelled) notifyError(err);
|
||||
|
||||
Reference in New Issue
Block a user