Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add card type dropdown BPS-60 #273

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions api/script/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,14 @@ function conditionSend({
.concat(source?.region?.map(itemNameId => ({itemNameId, factor: 'ss', type: 'region'})))
.concat(source?.city?.map(itemNameId => ({itemNameId, factor: 'ss', type: 'city'})))
.concat(source?.cardProduct?.map(itemNameId => ({itemNameId, factor: 'sc', type: 'cardProduct'})))
.concat(source?.cardType?.map(itemNameId => ({itemNameId, factor: 'sc', type: 'cardType'})))
.concat(source?.accountProduct?.map(itemNameId => ({itemNameId, factor: 'sc', type: 'accountProduct'})))
.concat(source?.accountFeePolicy?.map(itemNameId => ({itemNameId, factor: 'sp', type: 'feePolicy'})))
.concat(destination?.country?.map(itemNameId => ({itemNameId, factor: 'ds', type: 'country'})))
.concat(destination?.region?.map(itemNameId => ({itemNameId, factor: 'ds', type: 'region'})))
.concat(destination?.city?.map(itemNameId => ({itemNameId, factor: 'ds', type: 'city'})))
.concat(destination?.cardProduct?.map(itemNameId => ({itemNameId, factor: 'dc', type: 'cardProduct'})))
.concat(destination?.cardType?.map(itemNameId => ({itemNameId, factor: 'dc', type: 'cardType'})))
.concat(destination?.accountProduct?.map(itemNameId => ({itemNameId, factor: 'dc', type: 'accountProduct'})))
.concat(destination?.accountFeePolicy?.map(itemNameId => ({itemNameId, factor: 'dp', type: 'feePolicy'})))
.filter(Boolean)
Expand Down Expand Up @@ -151,6 +153,7 @@ function conditionReceive({
kyc: getProp(conditionProperty, 'sk', 'source.kyc'),
customerType: getProp(conditionProperty, 'st', 'source.customerType'),
cardProduct: get(conditionItem, 'sc', 'cardProduct', 'itemNameId'),
cardType: get(conditionItem, 'sc', 'cardType', 'itemNameId'),
accountProduct: get(conditionItem, 'sc', 'accountProduct', 'itemNameId'),
country: get(conditionItem, 'ss', 'country', 'itemNameId'),
region: get(conditionItem, 'ss', 'region', 'itemNameId'),
Expand All @@ -163,6 +166,7 @@ function conditionReceive({
kyc: getProp(conditionProperty, 'dk', 'destination.kyc'),
customerType: getProp(conditionProperty, 'dt', 'destination.customerType'),
cardProduct: get(conditionItem, 'dc', 'cardProduct', 'itemNameId'),
cardType: get(conditionItem, 'dc', 'cardType', 'itemNameId'),
accountProduct: get(conditionItem, 'dc', 'accountProduct', 'itemNameId'),
country: get(conditionItem, 'ds', 'country', 'itemNameId'),
region: get(conditionItem, 'ds', 'region', 'itemNameId'),
Expand Down
5 changes: 5 additions & 0 deletions api/sql/schema/750-rule.dropdown.list.sql
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ SELECT [value], [label], [parent]
FROM core.item(@languageId, 'cardProduct')
ORDER BY ISNULL(itemOrder, 99999), 2

SELECT 'rule.cardType' AS resultSetName
SELECT [value], [label], [parent]
FROM core.item(@languageId, 'cardType')
ORDER BY ISNULL(itemOrder, 99999), 2

SELECT 'rule.channel' AS resultSetName
SELECT [value], [label], [parent]
FROM core.item(@languageId, 'channel')
Expand Down
1 change: 1 addition & 0 deletions history/config/rule.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ module.exports = {
{key: 'source,cities', title: 'City', transform: conditionItemTransform},
{key: 'source,organization', title: 'Organization'},
{key: 'source,cardProducts', title: 'Product', transform: conditionItemTransform},
{key: 'source,cardTypes', title: 'Type', transform: conditionItemTransform},
{key: 'source,accountProduct', title: 'Account Product'},
{key: 'source,properties', title: 'Properties', transform: propertyTransform}
],
Expand Down
8 changes: 8 additions & 0 deletions model/condition.js
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,9 @@ module.exports = ({joi}) => ({
cardProduct: {
widget: {type: 'multiSelect', dropdown: 'rule.cardProduct'}
},
cardType: {
widget: {type: 'multiSelect', dropdown: 'rule.cardType'}
},
country: {
widget: {type: 'multiSelect', dropdown: 'rule.country'}
},
Expand Down Expand Up @@ -430,6 +433,9 @@ module.exports = ({joi}) => ({
cardProduct: {
widget: {type: 'multiSelect', dropdown: 'rule.cardProduct'}
},
cardType: {
widget: {type: 'multiSelect', dropdown: 'rule.cardType'}
},
country: {
widget: {type: 'multiSelect', dropdown: 'rule.country'}
},
Expand Down Expand Up @@ -536,6 +542,7 @@ module.exports = ({joi}) => ({
'source.customerType',
'source.kyc',
'source.cardProduct',
'source.cardType',
'source.accountProduct',
'condition.sourceAccountId'
]
Expand All @@ -552,6 +559,7 @@ module.exports = ({joi}) => ({
'destination.customerType',
'destination.kyc',
'destination.cardProduct',
'destination.cardType',
'destination.accountProduct',
'condition.destinationAccountId'
]
Expand Down
6 changes: 5 additions & 1 deletion ui/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const propMap = {
city: 'cities',
operation: 'operations',
cardProduct: 'cardProducts',
cardType: 'cardTypes',
feePolicy: 'accountFeePolicies',
so: 'source',
do: 'destination',
Expand Down Expand Up @@ -60,6 +61,8 @@ function prepareRuleModel(dbresult) {
countries: [],
cities: [],
regions: [],
cardProducts: [],
cardTypes: [],
accountFeePolicies: []
},
source: {
Expand All @@ -68,6 +71,7 @@ function prepareRuleModel(dbresult) {
cities: [],
regions: [],
cardProducts: [],
cardTypes: [],
accountFeePolicies: []
},
split: {
Expand All @@ -94,7 +98,7 @@ function prepareRuleModel(dbresult) {
});
// condition item
(dbresult.conditionItem || []).forEach((item) => {
if (['operation', 'country', 'city', 'region', 'cardProduct', 'feePolicy'].indexOf(item.type) > -1) {
if (['operation', 'country', 'city', 'region', 'cardProduct', 'cardType', 'feePolicy'].indexOf(item.type) > -1) {
const obj = rule[propMap[item.factor]] && rule[propMap[item.factor]][propMap[item.type]];
obj && obj.push({
key: item.itemNameId,
Expand Down
13 changes: 13 additions & 0 deletions ui/react/configuration/reducers.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const defaultUiState = {
'operation',
'supervisor',
'cardProduct',
'cardType',
'accountProduct',
'feePolicy',
'account'
Expand Down Expand Up @@ -133,6 +134,10 @@ const defaultUiState = {
visible: true,
title: 'Product'
},
cardType: {
visible: true,
title: 'Type'
},
accountProduct: {
visible: true,
title: 'Account Product'
Expand Down Expand Up @@ -163,6 +168,14 @@ const defaultUiState = {
visible: true,
title: 'Organization'
},
cardProduct: {
visible: true,
title: 'Product'
},
cardType: {
visible: true,
title: 'Type'
},
accountProduct: {
visible: true,
title: 'Account Product'
Expand Down
34 changes: 33 additions & 1 deletion ui/react/pages/RuleProfile/Tabs/Destination/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ const propTypes = {
accountProducts: PropTypes.array,
fieldValues: PropTypes.object,
errors: PropTypes.object, // immutable
destinationConfig: PropTypes.object.isRequired
destinationConfig: PropTypes.object.isRequired,
cardProducts: PropTypes.object,
cardTypes: PropTypes.object
};

const defaultProps = {
Expand Down Expand Up @@ -52,6 +54,8 @@ class DestinationTab extends Component {
accountProducts,
fieldValues,
feePolicies,
cardTypes,
cardProducts,
destinationConfig: { fields }
} = this.props;
const changeInput = (field, value) => {
Expand Down Expand Up @@ -109,6 +113,32 @@ class DestinationTab extends Component {
label={fields.organization.title || 'Organization'}
/>
</div>}
{fields.cardProduct.visible && <div className={style.inputWrapper}>
<MultiSelectDropdown
boldLabel
disabled={readonly}
canSelectPlaceholder
keyProp='cardProducts'
data={cardProducts}
defaultSelected={fieldValues.cardProducts}
placeholder='Select Product'
onSelect={(field) => { changeInput(field); }}
label={fields.cardProduct.title || 'Product'}
/>
</div>}
{fields.cardType.visible && <div className={style.inputWrapper}>
<MultiSelectDropdown
boldLabel
disabled={readonly}
canSelectPlaceholder
keyProp='cardTypes'
data={cardTypes}
defaultSelected={fieldValues.cardTypes}
placeholder='Select Type'
onSelect={(field) => { changeInput(field); }}
label={fields.cardType.title || 'Type'}
/>
</div>}
{fields.accountProduct.visible && <div className={style.inputWrapper}>
<Dropdown
disabled={readonly}
Expand Down Expand Up @@ -204,6 +234,8 @@ const mapStateToProps = (state, ownProps) => {
cities: state.ruleProfileReducer.getIn(['nomenclatures', 'city']).toJS(),
feePolicies: state.ruleProfileReducer.getIn(['nomenclatures', 'feePolicy']).toJS(),
organizations: state.ruleProfileReducer.getIn(['nomenclatures', 'organization']).toJS(),
cardProducts: state.ruleProfileReducer.getIn(['nomenclatures', 'cardProduct']).toJS(),
cardTypes: state.ruleProfileReducer.getIn(['nomenclatures', 'cardType']).toJS(),
fieldValues: state.ruleProfileReducer.getIn([mode, id, destinationProp], fromJS({})).toJS(),
accountProducts: state.ruleProfileReducer.getIn(['nomenclatures', 'accountProduct']).toJS(),
errors: state.ruleProfileReducer.getIn([mode, id, 'errors', destinationProp]) || fromJS({}),
Expand Down
16 changes: 16 additions & 0 deletions ui/react/pages/RuleProfile/Tabs/Source/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const propTypes = {
feePolicies: PropTypes.array,
organizations: PropTypes.array,
cardProducts: PropTypes.array,
cardTypes: PropTypes.array,
accountProducts: PropTypes.array,
fieldValues: PropTypes.object,
errors: PropTypes.object, // immutable
Expand Down Expand Up @@ -51,6 +52,7 @@ class SourceTab extends Component {
cities,
organizations,
cardProducts,
cardTypes,
accountProducts,
fieldValues,
feePolicies,
Expand Down Expand Up @@ -124,6 +126,19 @@ class SourceTab extends Component {
label={fields.cardProduct.title || 'Product'}
/>
</div>}
{fields.cardType.visible && <div className={style.inputWrapper}>
<MultiSelectDropdown
boldLabel
disabled={readonly}
canSelectPlaceholder
keyProp='cardTypes'
data={cardTypes}
defaultSelected={fieldValues.cardTypes}
placeholder='Select Type'
onSelect={(field) => { changeInput(field); }}
label={fields.cardType.title || 'Type'}
/>
</div>}
{fields.accountProduct.visible && <div className={style.inputWrapper}>
<Dropdown
disabled={readonly}
Expand Down Expand Up @@ -220,6 +235,7 @@ const mapStateToProps = (state, ownProps) => {
feePolicies: state.ruleProfileReducer.getIn(['nomenclatures', 'feePolicy']).toJS(),
organizations: state.ruleProfileReducer.getIn(['nomenclatures', 'organization']).toJS(),
cardProducts: state.ruleProfileReducer.getIn(['nomenclatures', 'cardProduct']).toJS(),
cardTypes: state.ruleProfileReducer.getIn(['nomenclatures', 'cardType']).toJS(),
accountProducts: state.ruleProfileReducer.getIn(['nomenclatures', 'accountProduct']).toJS(),
fieldValues: state.ruleProfileReducer.getIn([mode, id, destinationProp], fromJS({})).toJS(),
errors: state.ruleProfileReducer.getIn([mode, id, 'errors', destinationProp]) || fromJS({}),
Expand Down
3 changes: 3 additions & 0 deletions ui/react/pages/RuleProfile/Tabs/defaultState.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ export const defaultTabState = {
cities: [],
organization: '',
role: null,
cardProducts: [],
cardTypes: [],
properties: [],
accountFeePolicies: [],
accountProduct: null
Expand All @@ -95,6 +97,7 @@ export const defaultTabState = {
organization: '',
role: null,
cardProducts: [],
cardTypes: [],
accountFeePolicies: [],
accountProduct: null,
properties: []
Expand Down
2 changes: 1 addition & 1 deletion ui/react/pages/RuleProfile/Tabs/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@
width: 30%;
}
.outerWrap .labelWrap {
width: 25%;
width: 30%;
display: table-cell;
font-weight: bold;
vertical-align: middle;
Expand Down
20 changes: 12 additions & 8 deletions ui/react/pages/RuleProfile/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const conditionPropertyFactor = {
export const formatNomenclatures = (items) => {
const formattedPayload = {};
// default object properties
['accountProduct', 'cardProduct', 'channel', 'city', 'country', 'operation', 'region', 'currency', 'organization']
['accountProduct', 'cardProduct', 'cardType', 'channel', 'city', 'country', 'operation', 'region', 'currency', 'organization']
.forEach((objName) => (formattedPayload[objName] = []));
items.map(item => {
if (!formattedPayload[item.type]) {
Expand Down Expand Up @@ -137,16 +137,20 @@ export const prepareRuleToSave = (rule) => {
});
});

const cardProducts = rule && rule.source && rule.source.cardProducts;
if (cardProducts && cardProducts.length) {
cardProducts.forEach(cp => {
const pushItems = (items, factor) => {
items.forEach(cp => {
formattedRule.conditionItem.push({
itemNameId: cp.key,
conditionId,
factor: factors.sourceCategory
factor: factors[factor]
});
});
}
};

rule?.source?.cardProducts?.length && pushItems(rule?.source?.cardProducts, 'sourceCategory');
rule?.source?.cardTypes?.length && pushItems(rule?.source?.cardTypes, 'sourceCategory');
rule?.destination?.cardProducts?.length && pushItems(rule?.destination?.cardProducts, 'destinationCategory');
rule?.destination?.cardTypes?.length && pushItems(rule?.destination?.cardTypes, 'destinationCategory');

formattedRule.conditionProperty = [];

Expand Down Expand Up @@ -182,7 +186,7 @@ export const prepareRuleToSave = (rule) => {
});
});

formattedRule.split = {data: {rows: []}};
formattedRule.split = { data: { rows: [] } };
split.splits.forEach(split => {
if (!split.name) return;
const formattedSplit = {};
Expand Down Expand Up @@ -295,7 +299,7 @@ export const prepareRuleErrors = (rule, existErrors) => {
// cumulative
split.cumulatives.forEach(function(cumulative, cidx) {
cumulative && !cumulative.currency && !isEmptyValuesOnly(cumulative) &&
(errors = errors.setIn(['split', 'splits', idx, 'cumulatives', cidx, 'currency'], errorMessage.currencyRequired));
(errors = errors.setIn(['split', 'splits', idx, 'cumulatives', cidx, 'currency'], errorMessage.currencyRequired));

// ranges
cumulative && cumulative.ranges && cumulative.ranges.forEach(function(range, ridx) {
Expand Down
1 change: 1 addition & 0 deletions ui/react/pages/RuleProfile/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const defaultState = {
nomenclatures: {
accountProduct: [],
cardProduct: [],
cardType: [],
channel: [],
city: [],
country: [],
Expand Down
1 change: 1 addition & 0 deletions validations/rule/rule.dropdown.list.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ module.exports = ({
'rule.city': dropdownItems,
'rule.accountProduct': dropdownItems,
'rule.cardProduct': dropdownItems,
'rule.cardType': dropdownItems,
'rule.channel': dropdownItems,
'rule.role': dropdownItems,
'rule.kyc': dropdownItems,
Expand Down