taler-typescript-core

Wallet core logic and WebUIs for various components
Log | Files | Refs | Submodules | README | LICENSE

commit 41b06846b48bdf540896e636ff8f69859ec22109
parent 7190993954333bbd427cae2262096428c551a532
Author: Sebastian <sebasjm@gmail.com>
Date:   Mon, 12 May 2025 17:12:25 -0300

fix #9943

Diffstat:
Mpackages/merchant-backoffice-ui/src/paths/instance/webhooks/create/CreatePage.tsx | 4++--
Mpackages/merchant-backoffice-ui/src/paths/instance/webhooks/update/UpdatePage.tsx | 42++++++++++++++++++++++++++++++++++++++----
2 files changed, 40 insertions(+), 6 deletions(-)

diff --git a/packages/merchant-backoffice-ui/src/paths/instance/webhooks/create/CreatePage.tsx b/packages/merchant-backoffice-ui/src/paths/instance/webhooks/create/CreatePage.tsx @@ -223,12 +223,12 @@ export function CreatePage({ onCreate, onBack }: Props): VNode { )} </ul> </div> - {/* <Input<Entity> + <Input<Entity> name="header_template" label={i18n.str`Http header`} inputType="multiline" tooltip={i18n.str`Header template of the webhook`} - /> */} + /> <Input<Entity> name="body_template" inputType="multiline" diff --git a/packages/merchant-backoffice-ui/src/paths/instance/webhooks/update/UpdatePage.tsx b/packages/merchant-backoffice-ui/src/paths/instance/webhooks/update/UpdatePage.tsx @@ -19,7 +19,7 @@ * @author Sebastian Javier Marchano (sebasjm) */ -import { TalerMerchantApi } from "@gnu-taler/taler-util"; +import { assertUnreachable, TalerMerchantApi } from "@gnu-taler/taler-util"; import { useTranslationContext } from "@gnu-taler/web-util/browser"; import { h, VNode } from "preact"; import { useState } from "preact/hooks"; @@ -40,7 +40,17 @@ interface Props { onBack?: () => void; webhook: Entity; } -const validType = ["pay", "refund"]; +const validType = [ + "pay", + "refund", + "order_settled", + "category_added", + "category_updated", + "category_deleted", + "inventory_added", + "inventory_updated", + "inventory_deleted", +] as const; const validMethod = ["GET", "POST", "PUT", "PATCH", "HEAD"]; export function UpdatePage({ webhook, onUpdate, onBack }: Props): VNode { @@ -51,7 +61,8 @@ export function UpdatePage({ webhook, onUpdate, onBack }: Props): VNode { const errors = undefinedIfEmpty<FormErrors<Entity>>({ event_type: !state.event_type ? i18n.str`Required` - : validType.indexOf(state.event_type) === -1 + : // @ts-ignore checking if event type is on the valid list + validType.indexOf(state.event_type) === -1 ? i18n.str`Must be one of '${validType.join(", ")}'` : undefined, http_method: !state.http_method @@ -106,7 +117,30 @@ export function UpdatePage({ webhook, onUpdate, onBack }: Props): VNode { toStr={(v) => { const idx = validType.indexOf(v); if (idx === -1) return i18n.str`Choose one...`; - return [i18n.str`Pay`, i18n.str`Refund`][idx]; + const d = validType[idx]; + switch (d) { + case "pay": + return i18n.str`Payment`; + case "refund": + return i18n.str`Refund`; + case "order_settled": + return i18n.str`Order settled`; + case "category_added": + return i18n.str`Category added`; + case "category_updated": + return i18n.str`Category updated`; + case "category_deleted": + return i18n.str`Category deleted`; + case "inventory_added": + return i18n.str`Inventory added`; + case "inventory_updated": + return i18n.str`Inventory updated`; + case "inventory_deleted": + return i18n.str`Inventory deleted`; + default: { + assertUnreachable(d); + } + } }} tooltip={i18n.str`The event of the webhook: why the webhook is used`} />