u
This commit is contained in:
@@ -17,7 +17,7 @@ import { enqueueSnackbar } from 'notistack';
|
||||
import { company } from '../../api';
|
||||
import categoryAutomat from '../../automats/categoryAutomat';
|
||||
import articleIndexAutomat from '../../automats/articleIndexAutomat';
|
||||
import brandAutomat from '../../automats/brandAutomat';
|
||||
import companyAutomat from '../../automats/companyAutomat';
|
||||
import { orderAutomat } from '../../automats/orderAutomat';
|
||||
import SkeleHashImage from './SkeleHashImage';
|
||||
|
||||
@@ -240,7 +240,7 @@ export default class ImportExportSettingsPanel extends Component {
|
||||
enqueueSnackbar('Import erfolgreich abgeschlossen.', { variant: 'success' });
|
||||
void categoryAutomat.actions.loadTree();
|
||||
void articleIndexAutomat.actions.reload?.();
|
||||
void brandAutomat.actions.load?.();
|
||||
void companyAutomat.actions.loadBrands?.();
|
||||
if (stats?.ordersImported) {
|
||||
void orderAutomat.actions.reload?.();
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ import SaveOutlinedIcon from '@mui/icons-material/SaveOutlined';
|
||||
import { enqueueSnackbar } from 'notistack';
|
||||
import BackendError from '../BackendError';
|
||||
import { number as numberApi } from '../../api';
|
||||
import numberAutomat from '../../automats/numberAutomat';
|
||||
import companyAutomat from '../../automats/companyAutomat';
|
||||
import { requireArray, requireDefined, requireObject } from '../../utils/apiShape';
|
||||
import { backendErrorFrom } from '../../utils/backendError';
|
||||
import { notifyError } from '../../utils/notify';
|
||||
@@ -53,7 +53,7 @@ export default class NumberSettingsPanel extends Component {
|
||||
this.setState({ status: 'loading', error: null });
|
||||
try {
|
||||
const numbers = requireArray(
|
||||
await numberAutomat.actions.reload(),
|
||||
await companyAutomat.actions.reloadNumbers(),
|
||||
'numbers',
|
||||
);
|
||||
const drafts = Object.fromEntries(
|
||||
@@ -146,7 +146,7 @@ export default class NumberSettingsPanel extends Component {
|
||||
const updated = requireDefined(data.number, 'number');
|
||||
|
||||
const numbers = this.state.numbers.map((n) => (n.id === id ? { ...n, ...body } : n));
|
||||
await this.context.updateNumber();
|
||||
await companyAutomat.actions.reloadNumbers();
|
||||
this.setState({
|
||||
numbers,
|
||||
drafts: {
|
||||
|
||||
@@ -17,7 +17,7 @@ import PointOfSaleIcon from '@mui/icons-material/PointOfSale';
|
||||
import { enqueueSnackbar } from 'notistack';
|
||||
import BackendError from '../BackendError';
|
||||
import CategoryPickerDialog from '../article/CategoryPickerDialog';
|
||||
import posterminalAutomat from '../../automats/posterminalAutomat';
|
||||
import companyAutomat from '../../automats/companyAutomat';
|
||||
import categoryAutomat, { whenCategoryTreeReady } from '../../automats/categoryAutomat';
|
||||
import { categoryDisplayName } from '../../utils/categoryUtils';
|
||||
import { backendErrorFrom } from '../../utils/backendError';
|
||||
@@ -43,9 +43,9 @@ function formatDateTime(val) {
|
||||
export default class PosTerminalSettingsPanel extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
const terminals = posterminalAutomat.state.terminals ?? [];
|
||||
const terminals = companyAutomat.state.terminals ?? [];
|
||||
this.state = {
|
||||
status: posterminalAutomat.state.status === 'succeeded' ? 'ready' : 'loading',
|
||||
status: companyAutomat.state.terminalsStatus === 'succeeded' ? 'ready' : 'loading',
|
||||
error: null,
|
||||
terminals,
|
||||
categories: categoryAutomat.state.categories,
|
||||
@@ -67,9 +67,9 @@ export default class PosTerminalSettingsPanel extends Component {
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
this.unsub = posterminalAutomat.subscribe(this, (state) => ({
|
||||
this.unsub = companyAutomat.subscribe(this, (state) => ({
|
||||
terminals: Array.isArray(state.terminals) ? state.terminals : [],
|
||||
status: state.status === 'succeeded' ? 'ready' : state.status === 'failed' ? 'failed' : this.state.status,
|
||||
status: state.terminalsStatus === 'succeeded' ? 'ready' : state.terminalsStatus === 'failed' ? 'failed' : this.state.status,
|
||||
}));
|
||||
this.unsubCategory = categoryAutomat.subscribe(this, (state) => ({
|
||||
categories: state.categories,
|
||||
@@ -89,7 +89,7 @@ export default class PosTerminalSettingsPanel extends Component {
|
||||
async loadTerminals() {
|
||||
this.setState({ error: null });
|
||||
try {
|
||||
const terminals = await posterminalAutomat.actions.load();
|
||||
const terminals = await companyAutomat.actions.loadTerminals();
|
||||
this.setState({
|
||||
status: 'ready',
|
||||
terminals: Array.isArray(terminals) ? terminals : [],
|
||||
@@ -111,14 +111,14 @@ export default class PosTerminalSettingsPanel extends Component {
|
||||
|
||||
this.setState({ creatingTerminal: true });
|
||||
try {
|
||||
const created = await posterminalAutomat.actions.create({ name: trimmed });
|
||||
const created = await companyAutomat.actions.createTerminal({ name: trimmed });
|
||||
|
||||
if (enableAllForNew && created?.id != null) {
|
||||
await posterminalAutomat.actions.enableAll({ terminalId: created.id });
|
||||
await companyAutomat.actions.enableAllTerminalCategories({ terminalId: created.id });
|
||||
await whenCategoryTreeReady();
|
||||
}
|
||||
|
||||
await posterminalAutomat.actions.load();
|
||||
await companyAutomat.actions.loadTerminals();
|
||||
this.setState({ newTerminalName: '' });
|
||||
enqueueSnackbar('Terminal hinzugefügt.', { variant: 'success' });
|
||||
} catch (err) {
|
||||
@@ -131,8 +131,8 @@ export default class PosTerminalSettingsPanel extends Component {
|
||||
async handleDeleteTerminal(terminal) {
|
||||
this.setState({ deletingId: terminal.id });
|
||||
try {
|
||||
await posterminalAutomat.actions.delete(terminal.id);
|
||||
await posterminalAutomat.actions.load();
|
||||
await companyAutomat.actions.deleteTerminal(terminal.id);
|
||||
await companyAutomat.actions.loadTerminals();
|
||||
enqueueSnackbar('Terminal gelöscht.', { variant: 'info' });
|
||||
} catch (err) {
|
||||
notifyError(err);
|
||||
@@ -144,7 +144,7 @@ export default class PosTerminalSettingsPanel extends Component {
|
||||
async handleSetRootCategory(terminal, categoryId) {
|
||||
this.setState({ patchingTerminalId: terminal.id });
|
||||
try {
|
||||
await posterminalAutomat.actions.update(terminal.id, {
|
||||
await companyAutomat.actions.updateTerminal(terminal.id, {
|
||||
rootCategoryId: categoryId != null ? Number(categoryId) : null,
|
||||
});
|
||||
enqueueSnackbar('Root-Kategorie aktualisiert.', { variant: 'success' });
|
||||
@@ -158,7 +158,7 @@ export default class PosTerminalSettingsPanel extends Component {
|
||||
async handleToggleSyncRootArticles(terminal, nextValue) {
|
||||
this.setState({ patchingTerminalId: terminal.id });
|
||||
try {
|
||||
await posterminalAutomat.actions.update(terminal.id, {
|
||||
await companyAutomat.actions.updateTerminal(terminal.id, {
|
||||
syncRootArticles: Boolean(nextValue),
|
||||
});
|
||||
enqueueSnackbar('Synchronisierungseinstellung gespeichert.', { variant: 'success' });
|
||||
|
||||
Reference in New Issue
Block a user