From 68f3bcdc6cece62176849ab065e82630ebc4deae Mon Sep 17 00:00:00 2001 From: Sebastian Date: Sun, 14 Jan 2024 18:29:42 -0300 Subject: Fixes #8084 updating the reference state creates an invalid duration value which breaks the component --- .../src/paths/admin/create/CreatePage.tsx | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'packages/merchant-backoffice-ui') diff --git a/packages/merchant-backoffice-ui/src/paths/admin/create/CreatePage.tsx b/packages/merchant-backoffice-ui/src/paths/admin/create/CreatePage.tsx index d13b7e929..f95beba19 100644 --- a/packages/merchant-backoffice-ui/src/paths/admin/create/CreatePage.tsx +++ b/packages/merchant-backoffice-ui/src/paths/admin/create/CreatePage.tsx @@ -118,21 +118,23 @@ export function CreatePage({ onCreate, onBack, forceId }: Props): VNode { const submit = (): Promise => { // use conversion instead of this - const newToken = value.auth_token; - value.auth_token = undefined; - value.auth = newToken === null || newToken === undefined + const newValue = structuredClone(value); + + const newToken = newValue.auth_token; + newValue.auth_token = undefined; + newValue.auth = newToken === null || newToken === undefined ? { method: "external" } : { method: "token", token: `secret-token:${newToken}` }; - if (!value.address) value.address = {}; - if (!value.jurisdiction) value.jurisdiction = {}; + if (!newValue.address) newValue.address = {}; + if (!newValue.jurisdiction) newValue.jurisdiction = {}; // remove above use conversion // schema.validateSync(value, { abortEarly: false }) - value.default_pay_delay = Duration.toTalerProtocolDuration(value.default_pay_delay!) as any - value.default_wire_transfer_delay = Duration.toTalerProtocolDuration(value.default_wire_transfer_delay!) as any + newValue.default_pay_delay = Duration.toTalerProtocolDuration(newValue.default_pay_delay!) as any + newValue.default_wire_transfer_delay = Duration.toTalerProtocolDuration(newValue.default_wire_transfer_delay!) as any // delete value.default_pay_delay; // delete value.default_wire_transfer_delay; - return onCreate(value as any as MerchantBackend.Instances.InstanceConfigurationMessage); + return onCreate(newValue as any as MerchantBackend.Instances.InstanceConfigurationMessage); }; function updateToken(token: string | null) { -- cgit v1.2.3