u
This commit is contained in:
@@ -19,12 +19,29 @@ import PointOfSaleIcon from '@mui/icons-material/PointOfSale';
|
||||
import { enqueueSnackbar } from 'notistack';
|
||||
import BackendError from '../BackendError';
|
||||
import CategoryPickerDialog from '../article/CategoryPickerDialog';
|
||||
import authAutomat from '../../automats/authAutomat';
|
||||
import companyAutomat from '../../automats/companyAutomat';
|
||||
import categoryAutomat, { whenCategoryTreeReady } from '../../automats/categoryAutomat';
|
||||
import { categoryDisplayName } from '../../utils/categoryUtils';
|
||||
import { backendErrorFrom } from '../../utils/backendError';
|
||||
import { notifyError } from '../../utils/notify';
|
||||
|
||||
function parseVhostSettings(str) {
|
||||
if (!str || typeof str !== 'string') return {};
|
||||
const result = {};
|
||||
for (const part of str.split(';')) {
|
||||
const trimmed = part.trim();
|
||||
if (!trimmed) continue;
|
||||
const colonIdx = trimmed.indexOf(':');
|
||||
if (colonIdx !== -1) {
|
||||
const key = trimmed.slice(0, colonIdx).trim().toLowerCase();
|
||||
const val = trimmed.slice(colonIdx + 1).trim();
|
||||
result[key] = val;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function formatDateTime(val) {
|
||||
if (!val) return null;
|
||||
try {
|
||||
@@ -52,6 +69,7 @@ export default class PosTerminalSettingsPanel extends Component {
|
||||
terminals,
|
||||
categories: categoryAutomat.state.categories,
|
||||
rootCategoryId: categoryAutomat.state.rootCategoryId,
|
||||
vhostSettings: authAutomat.state.vhostSettings,
|
||||
newTerminalName: '',
|
||||
creatingTerminal: false,
|
||||
enableAllForNew: true,
|
||||
@@ -82,6 +100,9 @@ export default class PosTerminalSettingsPanel extends Component {
|
||||
categories: state.categories,
|
||||
rootCategoryId: state.rootCategoryId,
|
||||
}));
|
||||
this.unsubAuth = authAutomat.subscribe(this, (state) => ({
|
||||
vhostSettings: state.vhostSettings,
|
||||
}));
|
||||
if (categoryAutomat.state.treeStatus === 'idle') {
|
||||
void categoryAutomat.actions.loadTree();
|
||||
}
|
||||
@@ -90,6 +111,7 @@ export default class PosTerminalSettingsPanel extends Component {
|
||||
componentWillUnmount() {
|
||||
this.unsub?.();
|
||||
this.unsubCategory?.();
|
||||
this.unsubAuth?.();
|
||||
}
|
||||
|
||||
async loadTerminals() {
|
||||
@@ -275,6 +297,7 @@ export default class PosTerminalSettingsPanel extends Component {
|
||||
status,
|
||||
error,
|
||||
terminals,
|
||||
vhostSettings,
|
||||
newTerminalName,
|
||||
creatingTerminal,
|
||||
enableAllForNew,
|
||||
@@ -284,6 +307,11 @@ export default class PosTerminalSettingsPanel extends Component {
|
||||
rootCategoryId,
|
||||
} = this.state;
|
||||
|
||||
const parsedVhost = parseVhostSettings(vhostSettings);
|
||||
const posIp = parsedVhost.posip || parsedVhost.ip || null;
|
||||
const posPort = parsedVhost.posport || parsedVhost.port || null;
|
||||
const hasVhostSettings = Boolean(posIp || posPort || vhostSettings);
|
||||
|
||||
if (status === 'loading' && terminals.length === 0) {
|
||||
return (
|
||||
<Box sx={{ display: 'flex', justifyContent: 'center', py: 6 }}>
|
||||
@@ -298,6 +326,36 @@ export default class PosTerminalSettingsPanel extends Component {
|
||||
|
||||
return (
|
||||
<Box sx={{ maxWidth: 680, mx: 'auto', py: 2 }}>
|
||||
{hasVhostSettings && (
|
||||
<Box
|
||||
sx={{
|
||||
mb: 2,
|
||||
p: 1.5,
|
||||
px: 2,
|
||||
borderRadius: 2,
|
||||
bgcolor: 'action.hover',
|
||||
border: '1px solid',
|
||||
borderColor: 'divider',
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
gap: 4,
|
||||
flexWrap: 'wrap',
|
||||
}}
|
||||
>
|
||||
<Typography variant="body2" sx={{ color: 'text.secondary', fontWeight: 500 }}>
|
||||
Pos Sync IP:{' '}
|
||||
<Box component="span" sx={{ color: 'text.primary', fontFamily: 'monospace', fontWeight: 600 }}>
|
||||
{posIp ?? '—'}
|
||||
</Box>
|
||||
</Typography>
|
||||
<Typography variant="body2" sx={{ color: 'text.secondary', fontWeight: 500 }}>
|
||||
Pos Sync Port:{' '}
|
||||
<Box component="span" sx={{ color: 'text.primary', fontFamily: 'monospace', fontWeight: 600 }}>
|
||||
{posPort ?? '—'}
|
||||
</Box>
|
||||
</Typography>
|
||||
</Box>
|
||||
)}
|
||||
<Box sx={{ display: 'flex', alignItems: 'center', gap: 1, mb: 2 }}>
|
||||
<TextField
|
||||
size="small"
|
||||
|
||||
Reference in New Issue
Block a user