diff options
Diffstat (limited to 'packages/merchant-backoffice-ui/src/paths/instance/otp_devices/update')
-rw-r--r-- | packages/merchant-backoffice-ui/src/paths/instance/otp_devices/update/index.tsx | 24 |
1 files changed, 21 insertions, 3 deletions
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<Notification | undefined>(undefined); + const [keyUpdated, setKeyUpdated] = useState<MerchantBackend.OTP.OtpDeviceAddDetails | null>(null) const { i18n } = useTranslationContext(); @@ -73,6 +75,10 @@ export default function UpdateValidator({ return onLoadError(result); } + if (keyUpdated) { + return <CreatedSuccessfully entity={keyUpdated} onConfirm={onConfirm} /> + } + return ( <Fragment> <NotificationCard notification={notif} /> @@ -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`, |