diff options
author | Sebastian <sebasjm@gmail.com> | 2024-01-14 18:29:42 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2024-01-14 18:29:42 -0300 |
commit | 68f3bcdc6cece62176849ab065e82630ebc4deae (patch) | |
tree | 5134525092e72c2e76e9389974d3cbcc61a8dfcb /packages/merchant-backoffice-ui | |
parent | ad22420fbb0ea02469b54975e430c65dd19868e7 (diff) |
Fixes #8084
updating the reference state creates an invalid duration value which breaks the component
Diffstat (limited to 'packages/merchant-backoffice-ui')
-rw-r--r-- | packages/merchant-backoffice-ui/src/paths/admin/create/CreatePage.tsx | 18 |
1 files changed, 10 insertions, 8 deletions
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<void> => { // 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) { |