stores/values: remove defaultValues object
This commit is contained in:
parent
110eb94100
commit
b635abc863
@ -23,8 +23,20 @@ export default function commonReactions({ store, apolloClient }: ReactionsContex
|
||||
importProgram: importProgramId,
|
||||
dealer: dealerId,
|
||||
}) => {
|
||||
const {
|
||||
data: { transactioncurrencies },
|
||||
} = await apolloClient.query({
|
||||
query: CRMTypes.GetTransactionCurrenciesDocument,
|
||||
});
|
||||
|
||||
const transactioncurrency_rub = transactioncurrencies?.find(
|
||||
(x) => x?.isocurrencycode === 'RUB'
|
||||
);
|
||||
|
||||
const transactioncurrency_rub_id = transactioncurrency_rub?.transactioncurrencyid || null;
|
||||
|
||||
if (!productId) {
|
||||
$calculation.element('selectSupplierCurrency').resetValue().block();
|
||||
$calculation.element('selectSupplierCurrency').setValue(transactioncurrency_rub_id).block();
|
||||
|
||||
return;
|
||||
}
|
||||
@ -39,7 +51,7 @@ export default function commonReactions({ store, apolloClient }: ReactionsContex
|
||||
});
|
||||
|
||||
if (subsidyId || importProgramId || evo_baseproduct?.evo_sale_without_nds) {
|
||||
$calculation.element('selectSupplierCurrency').resetValue().block();
|
||||
$calculation.element('selectSupplierCurrency').setValue(transactioncurrency_rub_id).block();
|
||||
} else if (dealerId) {
|
||||
const {
|
||||
data: { dealer },
|
||||
@ -50,7 +62,10 @@ export default function commonReactions({ store, apolloClient }: ReactionsContex
|
||||
},
|
||||
});
|
||||
if (dealer?.evo_return_leasing_dealer === true) {
|
||||
$calculation.element('selectSupplierCurrency').resetValue().block();
|
||||
$calculation
|
||||
.element('selectSupplierCurrency')
|
||||
.setValue(transactioncurrency_rub_id)
|
||||
.block();
|
||||
} else {
|
||||
$calculation.element('selectSupplierCurrency').unblock();
|
||||
}
|
||||
|
||||
@ -7,7 +7,6 @@ import { pick } from 'radash';
|
||||
export default class ValuesStore {
|
||||
private root: RootStore;
|
||||
public values = defaultValues;
|
||||
private defaultValues = defaultValues;
|
||||
|
||||
constructor(rootStore: RootStore) {
|
||||
makeAutoObservable(this);
|
||||
@ -16,7 +15,6 @@ export default class ValuesStore {
|
||||
|
||||
public hydrate = (initialValues: CalculationValues) => {
|
||||
this.values = { ...defaultValues, ...initialValues };
|
||||
this.defaultValues = { ...defaultValues, ...initialValues };
|
||||
};
|
||||
|
||||
public getValues = <K extends keyof CalculationValues>(keys: K[]) => pick(this.values, keys);
|
||||
@ -34,6 +32,6 @@ export default class ValuesStore {
|
||||
};
|
||||
|
||||
public resetValue = (valueName: Values) => {
|
||||
this.setValue(valueName, this.defaultValues[valueName]);
|
||||
this.setValue(valueName, defaultValues[valueName]);
|
||||
};
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user