This commit is contained in:
seb
2026-10-09 11:33:12 +02:00
parent 8285936bc9
commit c0b436f9f2

View File

@@ -201,11 +201,10 @@ class PriceAmountField extends Component {
class PriceDisplay extends Component {
render() {
const { saved, taxRates, unitOptions, displaySymbol } = this.props;
const { saved, unitOptions, displaySymbol } = this.props;
return (
<Box sx={priceBodySx}>
<PriceAmountField value={saved.gross} readOnly />
<PriceTaxRow rates={taxRates} selected={saved.taxRate} readOnly />
<TierPricePills tiers={saved.tiers} />
<PriceUnitRow
hasUnit={saved.hasUnit}
@@ -288,61 +287,40 @@ class PriceEdit extends Component {
};
render() {
const {
draft,
onChange,
inputRef,
taxRates,
unitOptions,
displaySymbol,
tiersDialogOpen,
unitEditorOpen,
onOpenTiers,
onCloseTiers,
onCloseUnitEditor,
draft, onChange, inputRef, unitOptions, displaySymbol,
tiersDialogOpen, unitEditorOpen, onCloseTiers, onCloseUnitEditor,
} = this.props;
const draftGross = parsePriceInput(draft.gross);
const draftAmount = parsePriceInput(draft.unitamount);
return (
<Box sx={priceBodySx}>
<PriceAmountField
inputRef={inputRef}
value={draft.gross}
inputRef={inputRef} value={draft.gross}
onChange={(gross) => onChange({ ...draft, gross })}
error={draft.gross !== '' && draftGross == null}
/>
<PriceTaxRow
rates={taxRates}
selected={draft.taxRate}
onSelectTax={(taxRate) => onChange({ ...draft, taxRate })}
onOpenTiers={onOpenTiers}
/>
<TierPricePills tiers={draft.tiers} />
<PriceUnitRow
hasUnit={draft.hasUnit}
unitamount={draft.unitamount}
unitSi={draft.unitSi}
units={unitOptions}
hasUnit={draft.hasUnit} unitamount={draft.unitamount}
unitSi={draft.unitSi} units={unitOptions}
displaySymbol={displaySymbol}
onChangeAmount={(unitamount) => onChange({ ...draft, unitamount })}
onChangeSi={(unitSi) => onChange({ ...draft, unitSi })}
amountError={
draft.hasUnit &&
draft.unitamount !== '' &&
draft.hasUnit && draft.unitamount !== '' &&
(draftAmount == null || draftAmount <= 0)
}
/>
<ArticlePriceTiersDialog
open={tiersDialogOpen}
tiers={draft.tiers ?? []}
onClose={onCloseTiers}
onApply={(tiers) => onChange({ ...draft, tiers })}
open={tiersDialogOpen} tiers={draft.tiers ?? []}
onClose={onCloseTiers} onApply={(tiers) => onChange({ ...draft, tiers })}
/>
<ArticleUnitEditorDialog
open={unitEditorOpen}
onClose={onCloseUnitEditor}
onUnitUpserted={this.handleUnitUpserted}
onUnitDeleted={this.handleUnitDeleted}
open={unitEditorOpen} onClose={onCloseUnitEditor}
onUnitUpserted={this.handleUnitUpserted} onUnitDeleted={this.handleUnitDeleted}
/>
</Box>
);
@@ -557,7 +535,32 @@ export default class ArticleViewPrice extends PureComponent {
wide={1}
minHeight={SECOND_ROW_MIN_HEIGHT}
color={BLUE_PANEL}
title={'€'}
titleContent={({ editing, draft, onChange }) => (
<Box
sx={{
display: 'flex',
alignItems: 'center',
justifyContent: 'space-between',
width: '100%',
gap: 1,
}}
>
<Box component="span" sx={{ fontWeight: 700 }}>
€
</Box>
<PriceTaxRow
rates={taxRates}
selected={editing ? draft?.taxRate : priceValue.taxRate}
onSelectTax={
editing
? (taxRate) => onChange({ ...draft, taxRate })
: undefined
}
readOnly={!editing}
onOpenTiers={this.openTiersDialog}
/>
</Box>
)}
contentAlignItems="flex-start"
value={priceValue}
onSave={this.handleSave}
@@ -577,7 +580,6 @@ export default class ArticleViewPrice extends PureComponent {
display={
<PriceDisplay
saved={priceValue}
taxRates={taxRates}
unitOptions={unitOptions}
displaySymbol={displaySymbol}
/>
@@ -587,12 +589,10 @@ export default class ArticleViewPrice extends PureComponent {
draft={draft}
onChange={onChange}
inputRef={inputRef}
taxRates={taxRates}
unitOptions={unitOptions}
displaySymbol={displaySymbol}
tiersDialogOpen={tiersDialogOpen}
unitEditorOpen={unitEditorOpen}
onOpenTiers={this.openTiersDialog}
onCloseTiers={this.closeTiersDialog}
onCloseUnitEditor={this.closeUnitEditor}
onUnitUpserted={this.refreshUnits}