Skip to content

Commit

Permalink
[Issue-3468] Improve condition for Marketing campaign
Browse files Browse the repository at this point in the history
  • Loading branch information
dominhquang committed Aug 17, 2024
1 parent 846967a commit bc9ddd5
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 6 deletions.
36 changes: 30 additions & 6 deletions packages/extension-base/src/services/mkt-campaign-service/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -316,44 +316,68 @@ export default class MktCampaignService {
return conditionMap[JSON.stringify(condition)];
});

isPassValidation.push(isValidArr.some((i) => i));
if (item.comparison_operator === 'AND') {
isPassValidation.push(isValidArr.every((i) => i));
} else {
isPassValidation.push(isValidArr.some((i) => i));
}
}

if (conditionEarning && conditionEarning.length) {
const isValidArr = conditionEarning.map((condition) => {
return conditionMap[JSON.stringify(condition)];
});

isPassValidation.push(isValidArr.some((i) => i));
if (item.comparison_operator === 'AND') {
isPassValidation.push(isValidArr.every((i) => i));
} else {
isPassValidation.push(isValidArr.some((i) => i));
}
}

if (conditionNft && conditionNft.length) {
const isValidArr = conditionNft.map((condition) => {
return conditionMap[JSON.stringify(condition)];
});

isPassValidation.push(isValidArr.some((i) => i));
if (item.comparison_operator === 'AND') {
isPassValidation.push(isValidArr.every((i) => i));
} else {
isPassValidation.push(isValidArr.some((i) => i));
}
}

if (conditionCrowdloan && conditionCrowdloan.length) {
const isValidArr = conditionCrowdloan.map((condition) => {
return conditionMap[JSON.stringify(condition)];
});

isPassValidation.push(isValidArr.some((i) => i));
if (item.comparison_operator === 'AND') {
isPassValidation.push(isValidArr.every((i) => i));
} else {
isPassValidation.push(isValidArr.some((i) => i));
}
}

if (conditionHasMoney && conditionHasMoney.length) {
const isValidArr = conditionHasMoney.map((condition) => {
return conditionMap[JSON.stringify(condition)];
});

isPassValidation.push(isValidArr.some((i) => i));
if (item.comparison_operator === 'AND') {
isPassValidation.push(isValidArr.every((i) => i));
} else {
isPassValidation.push(isValidArr.some((i) => i));
}
}
}

if (isPassValidation && isPassValidation.length) {
return isPassValidation.some((_i) => _i);
if (item.comparison_operator === 'AND') {
return isPassValidation.every((_i) => _i);
} else {
return isPassValidation.some((_i) => _i);
}
} else {
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ export interface AppCommonData {
position_params: PositionParam[];
conditions: MktCampaignCondition;
info?: AppBasicInfoData;
comparison_operator: 'AND' | 'OR';
locations: string[];
}

export interface AppPopupData extends AppCommonData {
Expand Down

0 comments on commit bc9ddd5

Please sign in to comment.