This commit is contained in:
seb
2026-09-21 03:19:32 +02:00
parent 5594c59d88
commit 366d2517d6
17 changed files with 467 additions and 269 deletions

View File

@@ -1,5 +1,4 @@
import { Component } from 'react';
import { connect } from 'react-redux';
import Alert from '@mui/material/Alert';
import Box from '@mui/material/Box';
import Button from '@mui/material/Button';
@@ -23,11 +22,7 @@ import BusinessIcon from '@mui/icons-material/Business';
import BackendError from './BackendError';
import { company } from '../api';
import { StorageManagerContext } from '../api/storageManagerContext';
import {
createCompany as createCompanyThunk,
logout as logoutThunk,
selectCompany as selectCompanyThunk,
} from '../store/authSlice';
import authAutomat from '../automats/authAutomat';
import {
defaultIso639,
ISO639_OPTIONS,
@@ -75,7 +70,7 @@ class CompanySetupDialog extends Component {
async handleSelect(companyId) {
this.setState({ busy: true, error: null });
try {
await this.props.selectCompany(companyId).unwrap();
await authAutomat.actions.selectCompany(companyId);
await this.context.updateAuthMe();
} catch (err) {
this.setState({ error: backendErrorFrom(err) });
@@ -102,14 +97,12 @@ class CompanySetupDialog extends Component {
this.setState({ busy: true, error: null });
try {
await this.props
.createCompany({
name: name.trim(),
iso639,
taxrate: parsedTaxrate,
reducedtaxrate: parsedReducedtaxrate,
})
.unwrap();
await authAutomat.actions.createCompany({
name: name.trim(),
iso639,
taxrate: parsedTaxrate,
reducedtaxrate: parsedReducedtaxrate,
});
await this.context.updateAuthMe();
await this.context.updateCompany();
} catch (err) {
@@ -121,7 +114,7 @@ class CompanySetupDialog extends Component {
async handleLogout() {
try {
await this.props.logout().unwrap();
await authAutomat.actions.logout();
await this.context.updateAuthMe();
} catch (err) {
this.setState({ error: backendErrorFrom(err) });
@@ -293,10 +286,4 @@ class CompanySetupDialog extends Component {
}
}
const mapDispatchToProps = (dispatch) => ({
createCompany: (payload) => dispatch(createCompanyThunk(payload)),
selectCompany: (companyId) => dispatch(selectCompanyThunk(companyId)),
logout: () => dispatch(logoutThunk()),
});
export default connect(null, mapDispatchToProps)(CompanySetupDialog);
export default CompanySetupDialog;