Skip to content

Commit dd26b18

Browse files
committed
dry code
1 parent b1b081c commit dd26b18

1 file changed

Lines changed: 13 additions & 8 deletions

File tree

src/pages/workspace/rules/SpendRules/SpendRuleCardPage.tsx

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,8 @@ function SpendRuleCardPage({route}: SpendRuleCardPageProps) {
184184
Navigation.goBack(parentRoute);
185185
};
186186

187-
const headerMessage = eligibleCards.length > 0 ? getHeaderMessage(listData.length > 0, false, inputValue, countryCode, false) : '';
187+
const hasEligibleCards = eligibleCards.length > 0;
188+
const headerMessage = hasEligibleCards ? getHeaderMessage(listData.length > 0, false, inputValue, countryCode, false) : '';
188189

189190
return (
190191
<AccessOrNotFoundWrapper
@@ -214,12 +215,16 @@ function SpendRuleCardPage({route}: SpendRuleCardPageProps) {
214215
/>
215216
<SelectionList
216217
canSelectMultiple
217-
textInputOptions={eligibleCards.length > 0 ? {
218-
headerMessage,
219-
value: inputValue,
220-
label: translate('common.search'),
221-
onChangeText: setInputValue,
222-
} : undefined}
218+
textInputOptions={
219+
hasEligibleCards
220+
? {
221+
headerMessage,
222+
value: inputValue,
223+
label: translate('common.search'),
224+
onChangeText: setInputValue,
225+
}
226+
: undefined
227+
}
223228
data={listData}
224229
style={{
225230
listHeaderWrapperStyle: [styles.pt5, styles.pb2],
@@ -243,7 +248,7 @@ function SpendRuleCardPage({route}: SpendRuleCardPageProps) {
243248
}
244249
footerContent={
245250
<FormAlertWithSubmitButton
246-
buttonText={eligibleCards.length > 0 ? translate('common.save') : translate('common.buttonConfirm')}
251+
buttonText={hasEligibleCards ? translate('common.save') : translate('common.buttonConfirm')}
247252
isAlertVisible={false}
248253
isDisabled={isCardSettingsLoading}
249254
onSubmit={handleSave}

0 commit comments

Comments
 (0)