Skip to content

Commit

Permalink
Merge pull request #2195 from myxmaster/improve-currency-enabled-hand…
Browse files Browse the repository at this point in the history
…ling

Improve currency enabled error handling
  • Loading branch information
kaloudis authored May 22, 2024
2 parents 0e479e1 + 5407675 commit 3f24641
Show file tree
Hide file tree
Showing 4 changed files with 284 additions and 298 deletions.
2 changes: 1 addition & 1 deletion locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -991,7 +991,7 @@
"pos.views.Order.printInvoice": "Print Invoice",
"pos.views.Settings.PointOfSale.authWarning": "Warning: no password or PIN set",
"pos.views.Settings.PointOfSale.backendWarning": "Warning: currently only LND nodes are able to mark orders as paid",
"pos.views.Settings.PointOfSale.currencyError": "Error: currency must be set first",
"pos.views.Settings.PointOfSale.currencyMustBeEnabledError": "Error: currency must be enabled first",
"pos.print.taxReceipt": "Receipt",
"pos.print.invoice": "Invoice",
"views.Settings.NodeConfiguration.createMainnetWallet": "Create mainnet wallet",
Expand Down
148 changes: 79 additions & 69 deletions views/Settings/Currency.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,79 +134,89 @@ export default class Currency extends React.Component<
/>
</View>
</ListItem>
<View style={{ marginHorizontal: 16 }}>
<DropdownSetting
title={
localeString('views.Settings.Currency.source') +
':'
}
selectedValue={fiatRatesSource}
onValueChange={async (value: string) => {
this.setState({ fiatRatesSource: value });
const newSettings: any = {
fiatRatesSource: value
};
if (
!CURRENCY_KEYS.find(
(c) => c.value === selectedCurrency
)?.supportedSources.includes(value)
) {
newSettings.fiat = DEFAULT_FIAT;
this.setState({
selectedCurrency: DEFAULT_FIAT
});
}
await updateSettings(newSettings);
}}
values={FIAT_RATES_SOURCE_KEYS}
/>
</View>
<ListItem
containerStyle={{
backgroundColor: 'transparent'
}}
onPress={() => this.navigateToSelectCurrency()}
>
<ListItem.Content>
<ListItem.Title
style={{
color: themeColor('secondaryText'),
fontFamily: 'PPNeueMontreal-Book'
{fiatEnabled && (
<>
<View style={{ marginHorizontal: 16 }}>
<DropdownSetting
title={
localeString(
'views.Settings.Currency.source'
) + ':'
}
selectedValue={fiatRatesSource}
onValueChange={async (value: string) => {
this.setState({
fiatRatesSource: value
});
const newSettings: any = {
fiatRatesSource: value
};
if (
!CURRENCY_KEYS.find(
(c) =>
c.value === selectedCurrency
)?.supportedSources.includes(value)
) {
newSettings.fiat = DEFAULT_FIAT;
this.setState({
selectedCurrency: DEFAULT_FIAT
});
}
await updateSettings(newSettings);
}}
values={FIAT_RATES_SOURCE_KEYS}
/>
</View>
<ListItem
containerStyle={{
backgroundColor: 'transparent'
}}
onPress={() => this.navigateToSelectCurrency()}
>
{localeString(
'views.Settings.Currency.selectCurrency'
) + ` (${selectedCurrency})`}
</ListItem.Title>
</ListItem.Content>
<Icon
name="keyboard-arrow-right"
color={themeColor('secondaryText')}
/>
</ListItem>
<ListItem
containerStyle={{
backgroundColor: 'transparent'
}}
onPress={() => navigation.navigate('CurrencyConverter')}
>
<ListItem.Content>
<ListItem.Title
style={{
color: themeColor('secondaryText'),
fontFamily: 'PPNeueMontreal-Book'
<ListItem.Content>
<ListItem.Title
style={{
color: themeColor('secondaryText'),
fontFamily: 'PPNeueMontreal-Book'
}}
>
{localeString(
'views.Settings.Currency.selectCurrency'
) + ` (${selectedCurrency})`}
</ListItem.Title>
</ListItem.Content>
<Icon
name="keyboard-arrow-right"
color={themeColor('secondaryText')}
/>
</ListItem>
<ListItem
containerStyle={{
backgroundColor: 'transparent'
}}
onPress={() =>
navigation.navigate('CurrencyConverter')
}
>
{localeString(
'views.Settings.CurrencyConverter.title'
)}
</ListItem.Title>
</ListItem.Content>
<Icon
name="keyboard-arrow-right"
color={themeColor('secondaryText')}
/>
</ListItem>
<ListItem.Content>
<ListItem.Title
style={{
color: themeColor('secondaryText'),
fontFamily: 'PPNeueMontreal-Book'
}}
>
{localeString(
'views.Settings.CurrencyConverter.title'
)}
</ListItem.Title>
</ListItem.Content>
<Icon
name="keyboard-arrow-right"
color={themeColor('secondaryText')}
/>
</ListItem>
</>
)}
</View>
</Screen>
);
Expand Down
Loading

0 comments on commit 3f24641

Please sign in to comment.