diff options
author | Sebastian <sebasjm@gmail.com> | 2023-03-12 23:56:54 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2023-03-12 23:56:54 -0300 |
commit | b874f9a0c50084803de58febb698864aa8dd061a (patch) | |
tree | 50f23d8faa674a94646a21c5821fd4f494c60f64 /packages/merchant-backoffice-ui/src/paths/instance/templates/update | |
parent | ae1aee13581469a8398321b57e95cc85f210047b (diff) | |
download | wallet-core-b874f9a0c50084803de58febb698864aa8dd061a.tar.xz |
print and setup totp
Diffstat (limited to 'packages/merchant-backoffice-ui/src/paths/instance/templates/update')
-rw-r--r-- | packages/merchant-backoffice-ui/src/paths/instance/templates/update/UpdatePage.tsx | 42 |
1 files changed, 37 insertions, 5 deletions
diff --git a/packages/merchant-backoffice-ui/src/paths/instance/templates/update/UpdatePage.tsx b/packages/merchant-backoffice-ui/src/paths/instance/templates/update/UpdatePage.tsx index eba212517..e34e2c746 100644 --- a/packages/merchant-backoffice-ui/src/paths/instance/templates/update/UpdatePage.tsx +++ b/packages/merchant-backoffice-ui/src/paths/instance/templates/update/UpdatePage.tsx @@ -31,9 +31,11 @@ import { Input } from "../../../../components/form/Input.js"; import { InputCurrency } from "../../../../components/form/InputCurrency.js"; import { InputDuration } from "../../../../components/form/InputDuration.js"; import { InputNumber } from "../../../../components/form/InputNumber.js"; +import { InputSelector } from "../../../../components/form/InputSelector.js"; import { InputWithAddon } from "../../../../components/form/InputWithAddon.js"; import { useBackendContext } from "../../../../context/backend.js"; import { MerchantBackend, WithId } from "../../../../declaration.js"; +import { randomBase32Key } from "../../../../utils/crypto.js"; import { undefinedIfEmpty } from "../../../../utils/table.js"; type Entity = MerchantBackend.Template.TemplatePatchDetails & WithId; @@ -44,6 +46,13 @@ interface Props { template: Entity; } +const algorithms = ["0", "1", "2"]; +const algorithmsNames = [ + "off", + "30s 8d TOTP-SHA1 without amount", + "30s 8d eTOTP-SHA1 with amount", +]; + export function UpdatePage({ template, onUpdate, onBack }: Props): VNode { const { i18n } = useTranslationContext(); const backend = useBackendContext(); @@ -143,12 +152,35 @@ export function UpdatePage({ template, onUpdate, onBack }: Props): VNode { help="" tooltip={i18n.str`How much time has the customer to complete the payment once the order was created.`} /> - <Input<Entity> - name="pos_key" - label={i18n.str`Point-of-sale key`} - help="" - tooltip={i18n.str`Useful to validate the purchase`} + <InputSelector<Entity> + name="pos_algorithm" + label={i18n.str`Veritifaction algorithm`} + tooltip={i18n.str`Algorithm to use to verify transaction in offline mode`} + values={algorithms} + toStr={(v) => algorithmsNames[v]} + convert={(v) => Number(v)} /> + {state.pos_algorithm && state.pos_algorithm > 0 ? ( + <Input<Entity> + name="pos_key" + label={i18n.str`Point-of-sale key`} + help="" + tooltip={i18n.str`Useful to validate the purchase`} + side={ + <span data-tooltip={i18n.str`generate random secret key`}> + <button + class="button is-info mr-3" + onClick={(e) => { + const pos_key = randomBase32Key(); + setState((s) => ({ ...s, pos_key })); + }} + > + <i18n.Translate>random</i18n.Translate> + </button> + </span> + } + /> + ) : undefined} </FormProvider> <div class="buttons is-right mt-5"> |