fix(dashboard,promotion): percentage promotions + set currency code on percentage promotions (#13161)

This commit is contained in:
Riqwan Thamir
2025-08-07 13:07:41 +02:00
committed by GitHub
parent 9725bff25d
commit 224eaedf5c
5 changed files with 1090 additions and 951 deletions

View File

@@ -47,12 +47,10 @@ export const CreateCampaignFormFields = ({ form, fieldScope = "" }) => {
if (isTypeSpend) {
form.setValue(`campaign.budget.currency_code`, promotionCurrencyValue)
}
if (watchValueType === "usage") {
} else {
form.setValue(`campaign.budget.currency_code`, null)
}
}, [watchValueType])
}, [promotionCurrencyValue, isTypeSpend])
if (promotionCurrencyValue) {
const formCampaignBudget = form.getValues().campaign?.budget

View File

@@ -128,7 +128,7 @@ export const RulesFormField = ({
{t(`promotions.fields.conditions.${ruleType}.description`)}
</Text>
{fields.map((fieldRule: any, index) => {
{fields.map((fieldRule, index) => {
const identifier = fieldRule.id
return (
@@ -157,11 +157,23 @@ export const RulesFormField = ({
(ao) => ao.id === e
)
update(index, {
const fieldRuleOverrides: typeof fieldRule = {
...fieldRule,
values: [],
disguised: currentAttributeOption?.disguised || false,
})
}
if (currentAttributeOption?.operators?.length === 1) {
fieldRuleOverrides.operator =
currentAttributeOption.operators[0].value
}
if (fieldRuleOverrides.operator === "eq") {
fieldRuleOverrides.values = ""
} else {
fieldRuleOverrides.values = []
}
update(index, fieldRuleOverrides)
onChange(e)
}

View File

@@ -299,7 +299,7 @@ export const CreatePromotionForm = () => {
const formData = form.getValues()
let campaignQuery: object = {}
if (isFixedValueType && formData.application_method.currency_code) {
if (formData.application_method.currency_code) {
campaignQuery = {
budget: { currency_code: formData.application_method.currency_code },
}