u
This commit is contained in:
@@ -88,7 +88,17 @@ export { default as customergroupAutomat } from './customergroupAutomat';
|
||||
export { default as numberAutomat } from './numberAutomat';
|
||||
export { default as accountAutomat } from './accountAutomat';
|
||||
export { default as backupAutomat } from './backupAutomat';
|
||||
export { default as shipmentAutomat } from './shipmentAutomat';
|
||||
export {
|
||||
default as shipmentAutomat,
|
||||
CHUNK_SIZE as SHIPMENT_CHUNK_SIZE,
|
||||
selectShipments,
|
||||
selectShipmentTotal,
|
||||
selectShipmentUnfilteredTotal,
|
||||
selectShipmentPagination,
|
||||
selectStateFilter,
|
||||
getChunkStats as getShipmentChunkStats,
|
||||
subscribeChunkStats as subscribeShipmentChunkStats,
|
||||
} from './shipmentAutomat';
|
||||
export { createListAutomat, selectListItems, selectListStatus } from './createListAutomat';
|
||||
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -245,6 +245,9 @@ function connect() {
|
||||
void orderAutomat.actions.reload().catch((err) => {
|
||||
console.error('[sse] order refresh failed', err);
|
||||
});
|
||||
void shipmentAutomat.actions.reload().catch((err) => {
|
||||
console.error('[sse] shipment refresh failed', err);
|
||||
});
|
||||
});
|
||||
|
||||
addTrackedListener(es, 'quote', () => {
|
||||
|
||||
@@ -22,7 +22,7 @@ import FillSpace from 'dashgui/FillSpace';
|
||||
import { PanelTile, PanelTileGrid } from 'dashgui/panels';
|
||||
import BackendError from '../BackendError';
|
||||
import AppDialog from '../AppDialog';
|
||||
import shipmentAutomat from '../../automats/shipmentAutomat';
|
||||
import shipmentAutomat, { CHUNK_SIZE } from '../../automats/shipmentAutomat';
|
||||
import orderAutomat from '../../automats/orderAutomat';
|
||||
import numberAutomat from '../../automats/numberAutomat';
|
||||
import { shipment as shipmentApi } from '../../api';
|
||||
@@ -841,6 +841,7 @@ export class ShipmentList extends PureComponent {
|
||||
this.headerItem = createDummyTestShipment();
|
||||
this.state = {
|
||||
items: shipmentAutomat.getItems(),
|
||||
total: shipmentAutomat.state.total ?? 0,
|
||||
unfilteredTotal: shipmentAutomat.state.unfilteredTotal ?? 0,
|
||||
filterKey: shipmentAutomat.getFilterKey?.() ?? '',
|
||||
orders: orderAutomat.state?.items || [],
|
||||
@@ -855,12 +856,14 @@ export class ShipmentList extends PureComponent {
|
||||
this.handleOpenShipment = this.handleOpenShipment.bind(this);
|
||||
this.handleCloseShipment = this.handleCloseShipment.bind(this);
|
||||
this.handleDeleteShipment = this.handleDeleteShipment.bind(this);
|
||||
this.handlePageChange = this.handlePageChange.bind(this);
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
this._cancelled = false;
|
||||
this.unsub = shipmentAutomat.subscribe(this, (state) => ({
|
||||
items: state.items,
|
||||
total: state.total ?? 0,
|
||||
unfilteredTotal: state.unfilteredTotal ?? 0,
|
||||
filterKey: shipmentAutomat.getFilterKey(state),
|
||||
}));
|
||||
@@ -917,8 +920,21 @@ export class ShipmentList extends PureComponent {
|
||||
}
|
||||
}
|
||||
|
||||
handlePageChange(page, meta) {
|
||||
const pageSize = meta?.pageSize ?? 10;
|
||||
const startIndex = (page - 1) * pageSize;
|
||||
const items = this.state.items;
|
||||
const maxIndex = items ? items.length - 1 : startIndex;
|
||||
const endIndex = Math.min(maxIndex, startIndex + pageSize - 1);
|
||||
|
||||
const startChunk = Math.floor(startIndex / CHUNK_SIZE);
|
||||
const endChunk = Math.floor(endIndex / CHUNK_SIZE);
|
||||
|
||||
shipmentAutomat.requireChunk(startChunk, endChunk);
|
||||
}
|
||||
|
||||
handleRetry() {
|
||||
void shipmentAutomat.actions.load().catch(() => {});
|
||||
void shipmentAutomat.actions.requireChunk(0, 0, { immediate: true }).catch(() => {});
|
||||
}
|
||||
|
||||
handleOpenShipment(shipment) {
|
||||
@@ -946,6 +962,7 @@ export class ShipmentList extends PureComponent {
|
||||
render() {
|
||||
const {
|
||||
items,
|
||||
total,
|
||||
unfilteredTotal,
|
||||
filterKey,
|
||||
orders,
|
||||
@@ -1017,6 +1034,7 @@ export class ShipmentList extends PureComponent {
|
||||
<Box sx={{ gridColumn: 8, gridRow: 2, ...headerCellSx }} />
|
||||
</Box>
|
||||
}
|
||||
onPageChange={this.handlePageChange}
|
||||
/>
|
||||
{items === null && (
|
||||
<Box
|
||||
|
||||
@@ -39,15 +39,19 @@ import orderAutomat, {
|
||||
isOrderDelivered,
|
||||
} from '../automats/orderAutomat';
|
||||
import quoteAutomat from '../automats/quoteAutomat';
|
||||
import shipmentAutomat from '../automats/shipmentAutomat';
|
||||
import { formatPrice } from '../utils/price';
|
||||
|
||||
function getAutomatFor(target) {
|
||||
return target === 'quote' ? quoteAutomat : orderAutomat;
|
||||
if (target === 'quote') return quoteAutomat;
|
||||
if (target === 'shipment') return shipmentAutomat;
|
||||
return orderAutomat;
|
||||
}
|
||||
|
||||
function getInitialTarget() {
|
||||
if (typeof window !== 'undefined') {
|
||||
const p = window.location.pathname;
|
||||
if (p.startsWith('/auftrag/ausliefern')) return 'shipment';
|
||||
if (p.startsWith('/auftrag/bestellung')) return 'order';
|
||||
if (p.startsWith('/auftrag')) return 'quote';
|
||||
}
|
||||
@@ -152,7 +156,7 @@ class ChunkCacheMonitor extends PureComponent {
|
||||
window.addEventListener('keydown', this.handleKeyDown);
|
||||
this.customEventListener = (event) => {
|
||||
const reqTarget = event?.detail?.target;
|
||||
if (reqTarget === 'quote' || reqTarget === 'order') {
|
||||
if (reqTarget === 'quote' || reqTarget === 'order' || reqTarget === 'shipment') {
|
||||
this.switchTarget(reqTarget);
|
||||
} else {
|
||||
const detected = getInitialTarget();
|
||||
@@ -292,6 +296,9 @@ class ChunkCacheMonitor extends PureComponent {
|
||||
if (p.onlyUnpaid) automat.actions.setOnlyUnpaid(true);
|
||||
if (p.onlyUndelivered) automat.actions.setOnlyUndelivered(true);
|
||||
}
|
||||
if (this.state.target === 'shipment') {
|
||||
if (p.stateFilter) automat.actions.setStateFilter(p.stateFilter);
|
||||
}
|
||||
if (p.negativeSeekMonths) automat.actions.addNegativeSeek(p.negativeSeekMonths);
|
||||
this.setState({ inspectFilterKey: null, selectedChunk: null });
|
||||
}
|
||||
@@ -715,9 +722,10 @@ class ChunkCacheMonitor extends PureComponent {
|
||||
<Stack spacing={0.5}>
|
||||
{chunkOrders.map(({ item: order, index }) => {
|
||||
const isOrd = this.state.target === 'order';
|
||||
const isShip = this.state.target === 'shipment';
|
||||
const paid = isOrd ? isOrderPaid(order) : false;
|
||||
const delivered = isOrd ? isOrderDelivered(order) : false;
|
||||
const gross = order.grossTotal != null ? Number(order.grossTotal) : orderGrossTotal(order.lines);
|
||||
const gross = order.grossTotal != null ? Number(order.grossTotal) : (order.lines ? orderGrossTotal(order.lines) : 0);
|
||||
const customer = order.customerName || (order.entityId ? `Kunde #${order.entityId}` : '–');
|
||||
const posCount = order.positions != null ? order.positions : (order.lines?.length ?? 0);
|
||||
|
||||
@@ -772,11 +780,29 @@ class ChunkCacheMonitor extends PureComponent {
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
{isShip && (
|
||||
<>
|
||||
<Chip
|
||||
size="small"
|
||||
label={order.state === 'delivered' ? 'Geliefert' : order.state === 'returned' ? 'Retoure' : 'Neu'}
|
||||
color={order.state === 'delivered' ? 'success' : order.state === 'returned' ? 'error' : 'info'}
|
||||
sx={{ height: 20, fontSize: '0.7rem' }}
|
||||
/>
|
||||
{order.carrier && (
|
||||
<Chip
|
||||
size="small"
|
||||
variant="outlined"
|
||||
label={order.carrier}
|
||||
sx={{ height: 20, fontSize: '0.7rem' }}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
<Typography
|
||||
variant="caption"
|
||||
sx={{ fontWeight: 600, width: 75, textAlign: 'right', fontVariantNumeric: 'tabular-nums' }}
|
||||
>
|
||||
{gross > 0 ? formatPrice(gross) : '–'}
|
||||
{!isShip && gross > 0 ? formatPrice(gross) : (isShip && order.totalQuantity ? `${order.totalQuantity} Stk` : '–')}
|
||||
</Typography>
|
||||
</Box>
|
||||
);
|
||||
@@ -1046,6 +1072,14 @@ class ChunkCacheMonitor extends PureComponent {
|
||||
onClick={() => this.switchTarget('order')}
|
||||
sx={{ cursor: 'pointer', height: 24, fontSize: '0.72rem', fontWeight: this.state.target === 'order' ? 700 : 500 }}
|
||||
/>
|
||||
<Chip
|
||||
size="small"
|
||||
color={this.state.target === 'shipment' ? 'primary' : 'default'}
|
||||
variant={this.state.target === 'shipment' ? 'filled' : 'outlined'}
|
||||
label="Lieferscheine (shipmentAutomat)"
|
||||
onClick={() => this.switchTarget('shipment')}
|
||||
sx={{ cursor: 'pointer', height: 24, fontSize: '0.72rem', fontWeight: this.state.target === 'shipment' ? 700 : 500 }}
|
||||
/>
|
||||
</Stack>
|
||||
<Chip
|
||||
size="small"
|
||||
|
||||
Reference in New Issue
Block a user