u
This commit is contained in:
@@ -201,11 +201,10 @@ class PriceAmountField extends Component {
|
|||||||
|
|
||||||
class PriceDisplay extends Component {
|
class PriceDisplay extends Component {
|
||||||
render() {
|
render() {
|
||||||
const { saved, taxRates, unitOptions, displaySymbol } = this.props;
|
const { saved, unitOptions, displaySymbol } = this.props;
|
||||||
return (
|
return (
|
||||||
<Box sx={priceBodySx}>
|
<Box sx={priceBodySx}>
|
||||||
<PriceAmountField value={saved.gross} readOnly />
|
<PriceAmountField value={saved.gross} readOnly />
|
||||||
<PriceTaxRow rates={taxRates} selected={saved.taxRate} readOnly />
|
|
||||||
<TierPricePills tiers={saved.tiers} />
|
<TierPricePills tiers={saved.tiers} />
|
||||||
<PriceUnitRow
|
<PriceUnitRow
|
||||||
hasUnit={saved.hasUnit}
|
hasUnit={saved.hasUnit}
|
||||||
@@ -288,61 +287,40 @@ class PriceEdit extends Component {
|
|||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
|
||||||
const {
|
const {
|
||||||
draft,
|
draft, onChange, inputRef, unitOptions, displaySymbol,
|
||||||
onChange,
|
tiersDialogOpen, unitEditorOpen, onCloseTiers, onCloseUnitEditor,
|
||||||
inputRef,
|
|
||||||
taxRates,
|
|
||||||
unitOptions,
|
|
||||||
displaySymbol,
|
|
||||||
tiersDialogOpen,
|
|
||||||
unitEditorOpen,
|
|
||||||
onOpenTiers,
|
|
||||||
onCloseTiers,
|
|
||||||
onCloseUnitEditor,
|
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
|
||||||
const draftGross = parsePriceInput(draft.gross);
|
const draftGross = parsePriceInput(draft.gross);
|
||||||
const draftAmount = parsePriceInput(draft.unitamount);
|
const draftAmount = parsePriceInput(draft.unitamount);
|
||||||
return (
|
return (
|
||||||
<Box sx={priceBodySx}>
|
<Box sx={priceBodySx}>
|
||||||
<PriceAmountField
|
<PriceAmountField
|
||||||
inputRef={inputRef}
|
inputRef={inputRef} value={draft.gross}
|
||||||
value={draft.gross}
|
|
||||||
onChange={(gross) => onChange({ ...draft, gross })}
|
onChange={(gross) => onChange({ ...draft, gross })}
|
||||||
error={draft.gross !== '' && draftGross == null}
|
error={draft.gross !== '' && draftGross == null}
|
||||||
/>
|
/>
|
||||||
<PriceTaxRow
|
|
||||||
rates={taxRates}
|
|
||||||
selected={draft.taxRate}
|
|
||||||
onSelectTax={(taxRate) => onChange({ ...draft, taxRate })}
|
|
||||||
onOpenTiers={onOpenTiers}
|
|
||||||
/>
|
|
||||||
<TierPricePills tiers={draft.tiers} />
|
<TierPricePills tiers={draft.tiers} />
|
||||||
<PriceUnitRow
|
<PriceUnitRow
|
||||||
hasUnit={draft.hasUnit}
|
hasUnit={draft.hasUnit} unitamount={draft.unitamount}
|
||||||
unitamount={draft.unitamount}
|
unitSi={draft.unitSi} units={unitOptions}
|
||||||
unitSi={draft.unitSi}
|
|
||||||
units={unitOptions}
|
|
||||||
displaySymbol={displaySymbol}
|
displaySymbol={displaySymbol}
|
||||||
onChangeAmount={(unitamount) => onChange({ ...draft, unitamount })}
|
onChangeAmount={(unitamount) => onChange({ ...draft, unitamount })}
|
||||||
onChangeSi={(unitSi) => onChange({ ...draft, unitSi })}
|
onChangeSi={(unitSi) => onChange({ ...draft, unitSi })}
|
||||||
amountError={
|
amountError={
|
||||||
draft.hasUnit &&
|
draft.hasUnit && draft.unitamount !== '' &&
|
||||||
draft.unitamount !== '' &&
|
|
||||||
(draftAmount == null || draftAmount <= 0)
|
(draftAmount == null || draftAmount <= 0)
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<ArticlePriceTiersDialog
|
<ArticlePriceTiersDialog
|
||||||
open={tiersDialogOpen}
|
open={tiersDialogOpen} tiers={draft.tiers ?? []}
|
||||||
tiers={draft.tiers ?? []}
|
onClose={onCloseTiers} onApply={(tiers) => onChange({ ...draft, tiers })}
|
||||||
onClose={onCloseTiers}
|
|
||||||
onApply={(tiers) => onChange({ ...draft, tiers })}
|
|
||||||
/>
|
/>
|
||||||
<ArticleUnitEditorDialog
|
<ArticleUnitEditorDialog
|
||||||
open={unitEditorOpen}
|
open={unitEditorOpen} onClose={onCloseUnitEditor}
|
||||||
onClose={onCloseUnitEditor}
|
onUnitUpserted={this.handleUnitUpserted} onUnitDeleted={this.handleUnitDeleted}
|
||||||
onUnitUpserted={this.handleUnitUpserted}
|
|
||||||
onUnitDeleted={this.handleUnitDeleted}
|
|
||||||
/>
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
@@ -557,7 +535,32 @@ export default class ArticleViewPrice extends PureComponent {
|
|||||||
wide={1}
|
wide={1}
|
||||||
minHeight={SECOND_ROW_MIN_HEIGHT}
|
minHeight={SECOND_ROW_MIN_HEIGHT}
|
||||||
color={BLUE_PANEL}
|
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"
|
contentAlignItems="flex-start"
|
||||||
value={priceValue}
|
value={priceValue}
|
||||||
onSave={this.handleSave}
|
onSave={this.handleSave}
|
||||||
@@ -577,7 +580,6 @@ export default class ArticleViewPrice extends PureComponent {
|
|||||||
display={
|
display={
|
||||||
<PriceDisplay
|
<PriceDisplay
|
||||||
saved={priceValue}
|
saved={priceValue}
|
||||||
taxRates={taxRates}
|
|
||||||
unitOptions={unitOptions}
|
unitOptions={unitOptions}
|
||||||
displaySymbol={displaySymbol}
|
displaySymbol={displaySymbol}
|
||||||
/>
|
/>
|
||||||
@@ -587,12 +589,10 @@ export default class ArticleViewPrice extends PureComponent {
|
|||||||
draft={draft}
|
draft={draft}
|
||||||
onChange={onChange}
|
onChange={onChange}
|
||||||
inputRef={inputRef}
|
inputRef={inputRef}
|
||||||
taxRates={taxRates}
|
|
||||||
unitOptions={unitOptions}
|
unitOptions={unitOptions}
|
||||||
displaySymbol={displaySymbol}
|
displaySymbol={displaySymbol}
|
||||||
tiersDialogOpen={tiersDialogOpen}
|
tiersDialogOpen={tiersDialogOpen}
|
||||||
unitEditorOpen={unitEditorOpen}
|
unitEditorOpen={unitEditorOpen}
|
||||||
onOpenTiers={this.openTiersDialog}
|
|
||||||
onCloseTiers={this.closeTiersDialog}
|
onCloseTiers={this.closeTiersDialog}
|
||||||
onCloseUnitEditor={this.closeUnitEditor}
|
onCloseUnitEditor={this.closeUnitEditor}
|
||||||
onUnitUpserted={this.refreshUnits}
|
onUnitUpserted={this.refreshUnits}
|
||||||
|
|||||||
Reference in New Issue
Block a user