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

Improve currency enabled error handling #2195

Merged
merged 1 commit into from
May 22, 2024
Merged
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
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
Loading