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

Standalone POS: add optional keypad #1949

Merged
merged 6 commits into from
Jan 13, 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
4 changes: 3 additions & 1 deletion locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -723,6 +723,7 @@
"views.Settings.POS.disableTips": "Disable tips",
"views.Settings.POS.taxPercentage": "Tax percentage",
"views.Settings.POS.devMode": "Developer mode",
"views.Settings.POS.showKeypad": "Show keypad",
"views.Settings.POS.recon": "Reconciliation",
"views.Settings.POS.reconExport": "Reconciliation Export",
"views.Settings.POS.Categories": "Categories",
Expand Down Expand Up @@ -1012,5 +1013,6 @@
"views.LspExplanationOverview.step6": "The LSP then forwards the payment to the receiver using that new channel and the payment is completed",
"views.LspExplanationOverview.buttonText": "Learn more about wrapped invoices",
"views.Sweep.title": "Sweep on-chain wallet",
"views.Sweep.explainer": "Sweeping the on-chain wallet will send both the confirmed and unconfirmed balance to the destination address specified above."
"views.Sweep.explainer": "Sweeping the on-chain wallet will send both the confirmed and unconfirmed balance to the destination address specified above.",
"pos.customItem": "Custom item"
}
12 changes: 9 additions & 3 deletions stores/SettingsStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ interface PosSettings {
confirmationPreference?: string;
disableTips?: boolean;
squareDevMode?: boolean;
showKeypad?: boolean;
taxPercentage?: string;
}

Expand Down Expand Up @@ -667,9 +668,13 @@ export const DEFAULT_FIAT_RATES_SOURCE = 'Zeus';
export const DEFAULT_LOCALE = 'English';

export const POS_CONF_PREF_KEYS = [
{ translateKey: 'views.Settings.POS.0conf', value: '0conf' },
{ translateKey: 'views.Settings.POS.1conf', value: '1conf' },
{ translateKey: 'views.Settings.POS.lnOnly', value: 'lnOnly' }
{ key: '0 conf', translateKey: 'views.Settings.POS.0conf', value: '0conf' },
{ key: '1 conf', translateKey: 'views.Settings.POS.1conf', value: '1conf' },
{
key: 'LN only',
translateKey: 'views.Settings.POS.lnOnly',
value: 'lnOnly'
}
];

export const POS_ENABLED_KEYS = [
Expand Down Expand Up @@ -757,6 +762,7 @@ export default class SettingsStore {
confirmationPreference: 'lnOnly',
disableTips: false,
squareDevMode: false,
showKeypad: true,
taxPercentage: '0'
},
payments: {
Expand Down
2 changes: 1 addition & 1 deletion views/Order.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export default class OrderView extends React.Component<OrderProps, OrderState> {
const { settings } = SettingsStore;
const { changeUnits, units } = UnitsStore;
const fiat = settings.fiat;
const disableTips: boolean = settings?.pos?.disableTips;
const disableTips: boolean = settings?.pos?.disableTips || false;
const merchantName = settings?.pos?.merchantName;
const taxPercentage = settings?.pos?.taxPercentage;

Expand Down
83 changes: 69 additions & 14 deletions views/Settings/PointOfSale.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ interface PointOfSaleState {
confirmationPreference: string;
disableTips: boolean;
squareDevMode: boolean;
showKeypad: boolean;
taxPercentage: string;
}

Expand All @@ -53,6 +54,7 @@ export default class PointOfSale extends React.Component<
confirmationPreference: 'lnOnly',
disableTips: false,
squareDevMode: false,
showKeypad: true,
taxPercentage: '0'
};

Expand All @@ -62,21 +64,16 @@ export default class PointOfSale extends React.Component<
const settings = await getSettings();

this.setState({
posEnabled:
(settings.pos && settings.pos.posEnabled) ||
PosEnabled.Disabled,
squareAccessToken:
(settings.pos && settings.pos.squareAccessToken) || '',
squareLocationId:
(settings.pos && settings.pos.squareLocationId) || '',
merchantName: (settings.pos && settings.pos.merchantName) || '',
posEnabled: settings?.pos?.posEnabled || PosEnabled.Disabled,
squareAccessToken: settings?.pos?.squareAccessToken || '',
squareLocationId: settings?.pos?.squareLocationId || '',
merchantName: settings?.pos?.merchantName || '',
confirmationPreference:
(settings.pos && settings.pos.confirmationPreference) ||
'lnOnly',
disableTips: (settings.pos && settings.pos.disableTips) || false,
squareDevMode:
(settings.pos && settings.pos.squareDevMode) || false,
taxPercentage: (settings.pos && settings.pos.taxPercentage) || '0'
settings?.pos?.confirmationPreference || 'lnOnly',
disableTips: settings?.pos?.disableTips || false,
squareDevMode: settings?.pos?.squareDevMode || false,
showKeypad: settings?.pos?.showKeypad || false,
taxPercentage: settings?.pos?.taxPercentage || '0'
});
}

Expand All @@ -99,6 +96,7 @@ export default class PointOfSale extends React.Component<
confirmationPreference,
disableTips,
squareDevMode,
showKeypad,
taxPercentage
} = this.state;
const { updateSettings, settings }: any = SettingsStore;
Expand Down Expand Up @@ -181,6 +179,7 @@ export default class PointOfSale extends React.Component<
confirmationPreference,
disableTips,
squareDevMode,
showKeypad,
taxPercentage
}
});
Expand Down Expand Up @@ -216,6 +215,7 @@ export default class PointOfSale extends React.Component<
confirmationPreference,
disableTips,
squareDevMode,
showKeypad,
taxPercentage
}
});
Expand Down Expand Up @@ -248,6 +248,7 @@ export default class PointOfSale extends React.Component<
confirmationPreference,
disableTips,
squareDevMode,
showKeypad,
taxPercentage
}
});
Expand Down Expand Up @@ -280,6 +281,7 @@ export default class PointOfSale extends React.Component<
confirmationPreference,
disableTips,
squareDevMode,
showKeypad,
taxPercentage
}
});
Expand Down Expand Up @@ -331,6 +333,7 @@ export default class PointOfSale extends React.Component<
disableTips,
squareDevMode:
!squareDevMode,
showKeypad,
taxPercentage
}
});
Expand Down Expand Up @@ -428,6 +431,58 @@ export default class PointOfSale extends React.Component<

{posEnabled === PosEnabled.Standalone && (
<>
<ListItem
containerStyle={{
borderBottomWidth: 0,
backgroundColor:
themeColor('background')
}}
>
<ListItem.Title
style={{
color: themeColor(
'secondaryText'
),
fontFamily:
'PPNeueMontreal-Book',
left: -10
}}
>
{localeString(
'views.Settings.POS.showKeypad'
)}
</ListItem.Title>
<View
style={{
flex: 1,
flexDirection: 'row',
justifyContent: 'flex-end'
}}
>
<Switch
value={showKeypad}
onValueChange={async () => {
this.setState({
showKeypad: !showKeypad
});
await updateSettings({
pos: {
squareAccessToken,
squareLocationId,
posEnabled,
merchantName,
confirmationPreference,
disableTips,
squareDevMode,
showKeypad:
!showKeypad,
taxPercentage
}
});
}}
/>
</View>
</ListItem>
<Text
style={{
color: themeColor('secondaryText'),
Expand Down
Loading