From 8055f8834974773170f83c7013174e141ced53cb Mon Sep 17 00:00:00 2001 From: Sebastian Date: Fri, 9 Feb 2024 11:11:34 -0300 Subject: fix #8354: show import key after updating --- .../merchant-backoffice-ui/src/declaration.d.ts | 4 ---- .../instance/orders/details/Detail.stories.tsx | 2 -- .../otp_devices/create/CreatedSuccessfully.tsx | 4 ---- .../src/paths/instance/otp_devices/list/Table.tsx | 2 +- .../paths/instance/otp_devices/update/index.tsx | 24 +++++++++++++++++++--- 5 files changed, 22 insertions(+), 14 deletions(-) diff --git a/packages/merchant-backoffice-ui/src/declaration.d.ts b/packages/merchant-backoffice-ui/src/declaration.d.ts index 38ab9d254..d716fe132 100644 --- a/packages/merchant-backoffice-ui/src/declaration.d.ts +++ b/packages/merchant-backoffice-ui/src/declaration.d.ts @@ -912,10 +912,6 @@ export namespace MerchantBackend { // available, otherwise empty array. wire_details: TransactionWireTransfer[]; - // Reports about trouble obtaining wire transfer details, - // empty array if no trouble were encountered. - wire_reports: TransactionWireReport[]; - // The refund details for this order. One entry per // refunded coin; empty array if there are no refunds. refund_details: RefundDetails[]; diff --git a/packages/merchant-backoffice-ui/src/paths/instance/orders/details/Detail.stories.tsx b/packages/merchant-backoffice-ui/src/paths/instance/orders/details/Detail.stories.tsx index 6e73a01a5..8b892e122 100644 --- a/packages/merchant-backoffice-ui/src/paths/instance/orders/details/Detail.stories.tsx +++ b/packages/merchant-backoffice-ui/src/paths/instance/orders/details/Detail.stories.tsx @@ -91,7 +91,6 @@ export const PaidNotRefundable = createExample(TestedComponent, { refund_details: [], refund_pending: false, wire_details: [], - wire_reports: [], wired: false, }, }); @@ -115,7 +114,6 @@ export const PaidRefundable = createExample(TestedComponent, { refund_details: [], refund_pending: false, wire_details: [], - wire_reports: [], wired: false, }, }); diff --git a/packages/merchant-backoffice-ui/src/paths/instance/otp_devices/create/CreatedSuccessfully.tsx b/packages/merchant-backoffice-ui/src/paths/instance/otp_devices/create/CreatedSuccessfully.tsx index db3842711..45939c19d 100644 --- a/packages/merchant-backoffice-ui/src/paths/instance/otp_devices/create/CreatedSuccessfully.tsx +++ b/packages/merchant-backoffice-ui/src/paths/instance/otp_devices/create/CreatedSuccessfully.tsx @@ -29,10 +29,6 @@ interface Props { onConfirm: () => void; } -function isNotUndefined(x: X | undefined): x is X { - return !!x; -} - export function CreatedSuccessfully({ entity, onConfirm, diff --git a/packages/merchant-backoffice-ui/src/paths/instance/otp_devices/list/Table.tsx b/packages/merchant-backoffice-ui/src/paths/instance/otp_devices/list/Table.tsx index 0c28027fe..b7c22c17f 100644 --- a/packages/merchant-backoffice-ui/src/paths/instance/otp_devices/list/Table.tsx +++ b/packages/merchant-backoffice-ui/src/paths/instance/otp_devices/list/Table.tsx @@ -161,7 +161,7 @@ function Table({ onClick={(): void => onSelect(i)} style={{ cursor: "pointer" }} > - {i.otp_device_id} + {i.device_description}
diff --git a/packages/merchant-backoffice-ui/src/paths/instance/otp_devices/update/index.tsx b/packages/merchant-backoffice-ui/src/paths/instance/otp_devices/update/index.tsx index 52f6c6c29..7c7092a4e 100644 --- a/packages/merchant-backoffice-ui/src/paths/instance/otp_devices/update/index.tsx +++ b/packages/merchant-backoffice-ui/src/paths/instance/otp_devices/update/index.tsx @@ -33,6 +33,7 @@ import { Notification } from "../../../../utils/types.js"; import { UpdatePage } from "./UpdatePage.js"; import { HttpStatusCode } from "@gnu-taler/taler-util"; import { useOtpDeviceAPI, useOtpDeviceDetails } from "../../../../hooks/otp.js"; +import { CreatedSuccessfully } from "../create/CreatedSuccessfully.js"; export type Entity = MerchantBackend.OTP.OtpDevicePatchDetails & WithId; @@ -55,6 +56,7 @@ export default function UpdateValidator({ const { updateOtpDevice } = useOtpDeviceAPI(); const result = useOtpDeviceDetails(vid); const [notif, setNotif] = useState(undefined); + const [keyUpdated, setKeyUpdated] = useState(null) const { i18n } = useTranslationContext(); @@ -73,6 +75,10 @@ export default function UpdateValidator({ return onLoadError(result); } + if (keyUpdated) { + return + } + return ( @@ -85,9 +91,21 @@ export default function UpdateValidator({ otp_ctr: result.data.otp_ctr }} onBack={onBack} - onUpdate={(data) => { - return updateOtpDevice(vid, data) - .then(onConfirm) + onUpdate={async (newInfo) => { + return updateOtpDevice(vid, newInfo) + .then((d) => { + if (newInfo.otp_key) { + setKeyUpdated({ + otp_algorithm: newInfo.otp_algorithm, + otp_device_description: newInfo.otp_device_description, + otp_device_id: newInfo.id, + otp_key: newInfo.otp_key, + otp_ctr: newInfo.otp_ctr, + }) + } else { + onConfirm() + } + }) .catch((error) => { setNotif({ message: i18n.str`could not update template`, -- cgit v1.2.3