diff options
Diffstat (limited to 'packages/merchant-backoffice-ui/src/paths/instance/orders/create')
-rw-r--r-- | packages/merchant-backoffice-ui/src/paths/instance/orders/create/CreatePage.tsx | 74 |
1 files changed, 55 insertions, 19 deletions
diff --git a/packages/merchant-backoffice-ui/src/paths/instance/orders/create/CreatePage.tsx b/packages/merchant-backoffice-ui/src/paths/instance/orders/create/CreatePage.tsx index ea2cf849a..52ee9d351 100644 --- a/packages/merchant-backoffice-ui/src/paths/instance/orders/create/CreatePage.tsx +++ b/packages/merchant-backoffice-ui/src/paths/instance/orders/create/CreatePage.tsx @@ -143,7 +143,7 @@ export function CreatePage({ const instance_default = with_defaults(instanceConfig, config.currency) const [value, valueHandler] = useState(instance_default); const zero = Amounts.zeroOfCurrency(config.currency); - const [settings] = useSettings() + const [settings, updateSettings] = useSettings() const inventoryList = Object.values(value.inventoryProducts || {}); const productList = Object.values(value.products || {}); @@ -184,7 +184,7 @@ export function CreatePage({ ? i18n.str`wire transfer deadline cannot be before refund deadline` : undefined, pay_deadline: !value.payments?.pay_deadline - ? undefined + ? i18n.str`required` : !isFuture(value.payments.pay_deadline) ? i18n.str`should be in the future` : value.payments.wire_transfer_deadline && @@ -194,6 +194,11 @@ export function CreatePage({ ) ? i18n.str`wire transfer deadline cannot be before pay deadline` : undefined, + wire_transfer_deadline: !value.payments?.wire_transfer_deadline + ? i18n.str`required` + : !isFuture(value.payments.wire_transfer_deadline) + ? i18n.str`should be in the future` + : undefined, auto_refund_deadline: !value.payments?.auto_refund_deadline ? undefined : !isFuture(value.payments.auto_refund_deadline) @@ -354,9 +359,39 @@ export function CreatePage({ !prev.minimum_age || cur > prev.minimum_age ? cur : prev.minimum_age, 0, ); + + const noDefault_payDeadline = !instance_default.payments || !instance_default.payments.pay_deadline + const noDefault_wireDeadline = !instance_default.payments || !instance_default.payments.wire_transfer_deadline + const requiresSomeTalerOptions = noDefault_payDeadline || noDefault_wireDeadline + return ( <div> + <section class="section is-main-section"> + <div class="tabs is-toggle is-fullwidth is-small"> + <ul> + <li class={!settings.advanceOrderMode ? "is-active" : ""} onClick={() => { + updateSettings({ + ...settings, + advanceOrderMode: false + }) + }}> + <a > + <span><i18n.Translate>Simple</i18n.Translate></span> + </a> + </li> + <li class={settings.advanceOrderMode ? "is-active" : ""} onClick={() => { + updateSettings({ + ...settings, + advanceOrderMode: true + }) + }}> + <a > + <span><i18n.Translate>Advanced</i18n.Translate></span> + </a> + </li> + </ul> + </div> <div class="columns"> <div class="column" /> <div class="column is-four-fifths"> @@ -481,33 +516,34 @@ export function CreatePage({ </InputGroup> } - {settings.advanceOrderMode && + {(settings.advanceOrderMode || requiresSomeTalerOptions) && <InputGroup name="payments" label={i18n.str`Taler payment options`} tooltip={i18n.str`Override default Taler payment settings for this order`} > - <InputDate + {(settings.advanceOrderMode || noDefault_payDeadline) && <InputDate name="payments.pay_deadline" label={i18n.str`Payment deadline`} tooltip={i18n.str`Deadline for the customer to pay for the offer before it expires. Inventory products will be reserved until this deadline.`} side={ <span> <button class="button" onClick={() => { - valueHandler({ + const c = { ...value, payments: { ...(value.payments ?? {}), pay_deadline: instance_default.payments?.pay_deadline } - }) + } + valueHandler(c) }}> <i18n.Translate>default</i18n.Translate> </button> </span> } - /> - <InputDate + />} + {settings.advanceOrderMode && <InputDate name="payments.refund_deadline" label={i18n.str`Refund deadline`} tooltip={i18n.str`Time until which the order can be refunded by the merchant.`} @@ -526,8 +562,8 @@ export function CreatePage({ </button> </span> } - /> - <InputDate + />} + {(settings.advanceOrderMode || noDefault_wireDeadline) && <InputDate name="payments.wire_transfer_deadline" label={i18n.str`Wire transfer deadline`} tooltip={i18n.str`Deadline for the exchange to make the wire transfer.`} @@ -546,24 +582,24 @@ export function CreatePage({ </button> </span> } - /> - <InputDate + />} + {settings.advanceOrderMode && <InputDate name="payments.auto_refund_deadline" label={i18n.str`Auto-refund deadline`} tooltip={i18n.str`Time until which the wallet will automatically check for refunds without user interaction.`} - /> + />} - <InputCurrency + {settings.advanceOrderMode && <InputCurrency name="payments.max_fee" label={i18n.str`Maximum fee`} tooltip={i18n.str`Maximum fees the merchant is willing to cover for this order. Higher deposit fees must be covered in full by the consumer.`} - /> - <InputToggle + />} + {settings.advanceOrderMode && <InputToggle name="payments.createToken" label={i18n.str`Create token`} tooltip={i18n.str`If the order ID is easy to guess the token will prevent user to steal orders from others.`} - /> - <InputNumber + />} + {settings.advanceOrderMode && <InputNumber name="payments.minimum_age" label={i18n.str`Minimum age required`} tooltip={i18n.str`Any value greater than 0 will limit the coins able be used to pay this contract. If empty the age restriction will be defined by the products`} @@ -572,7 +608,7 @@ export function CreatePage({ ? i18n.str`Min age defined by the producs is ${minAgeByProducts}` : i18n.str`No product with age restriction in this order` } - /> + />} </InputGroup> } |