From 72b429321553841ac1ff48cf974bfc65da01bb06 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Mon, 19 Dec 2022 12:23:39 -0300 Subject: pretty --- .../src/paths/instance/details/DetailPage.tsx | 84 +++++++++++----------- .../src/paths/instance/details/Details.stories.tsx | 2 +- .../src/paths/instance/details/index.tsx | 68 ++++++++++-------- 3 files changed, 82 insertions(+), 72 deletions(-) (limited to 'packages/merchant-backoffice-ui/src/paths/instance/details') diff --git a/packages/merchant-backoffice-ui/src/paths/instance/details/DetailPage.tsx b/packages/merchant-backoffice-ui/src/paths/instance/details/DetailPage.tsx index 01e7771cf..59aa7a1d2 100644 --- a/packages/merchant-backoffice-ui/src/paths/instance/details/DetailPage.tsx +++ b/packages/merchant-backoffice-ui/src/paths/instance/details/DetailPage.tsx @@ -15,9 +15,9 @@ */ /** -* -* @author Sebastian Javier Marchano (sebasjm) -*/ + * + * @author Sebastian Javier Marchano (sebasjm) + */ import { h, VNode } from "preact"; import { useState } from "preact/hooks"; @@ -33,55 +33,57 @@ interface Props { selected: MerchantBackend.Instances.QueryInstancesResponse; } -function convert(from: MerchantBackend.Instances.QueryInstancesResponse): Entity { - const { accounts, ...rest } = from - const payto_uris = accounts.filter(a => a.active).map(a => a.payto_uri) +function convert( + from: MerchantBackend.Instances.QueryInstancesResponse, +): Entity { + const { accounts, ...rest } = from; + const payto_uris = accounts.filter((a) => a.active).map((a) => a.payto_uri); const defaults = { default_wire_fee_amortization: 1, default_pay_delay: { d_us: 1000 * 60 * 60 }, //one hour default_wire_transfer_delay: { d_us: 1000 * 60 * 60 * 2 }, //two hours - } + }; return { ...defaults, ...rest, payto_uris }; } export function DetailPage({ selected }: Props): VNode { - const [value, valueHandler] = useState>(convert(selected)) + const [value, valueHandler] = useState>(convert(selected)); + + const i18n = useTranslator(); - const i18n = useTranslator() - - return
-
-
-
-
-
-

- Here goes the instance description -

+ return ( +
+
+
+
+
+
+

Here goes the instance description

+
+
+ - -
-
- -
-
-
-
- object={value} valueHandler={valueHandler} > +
- name="name" readonly label={i18n`Name`} /> - name="payto_uris" readonly label={i18n`Account address`} /> - - +
+
+
+
+ object={value} valueHandler={valueHandler}> + name="name" readonly label={i18n`Name`} /> + + name="payto_uris" + readonly + label={i18n`Account address`} + /> + +
+
-
-
-
- -
- -} \ No newline at end of file +
+
+ ); +} diff --git a/packages/merchant-backoffice-ui/src/paths/instance/details/Details.stories.tsx b/packages/merchant-backoffice-ui/src/paths/instance/details/Details.stories.tsx index f7772895f..9ac1c4381 100644 --- a/packages/merchant-backoffice-ui/src/paths/instance/details/Details.stories.tsx +++ b/packages/merchant-backoffice-ui/src/paths/instance/details/Details.stories.tsx @@ -33,7 +33,7 @@ export default { function createExample( Component: FunctionalComponent, - props: Partial + props: Partial, ) { const r = (args: any) => ; r.args = props; diff --git a/packages/merchant-backoffice-ui/src/paths/instance/details/index.tsx b/packages/merchant-backoffice-ui/src/paths/instance/details/index.tsx index 09b692e00..49b64262b 100644 --- a/packages/merchant-backoffice-ui/src/paths/instance/details/index.tsx +++ b/packages/merchant-backoffice-ui/src/paths/instance/details/index.tsx @@ -30,36 +30,44 @@ interface Props { onDelete: () => void; } -export default function Detail({ onUpdate, onLoadError, onUnauthorized, onDelete, onNotFound }: Props): VNode { - const { id } = useInstanceContext() - const result = useInstanceDetails() - const [deleting, setDeleting] = useState(false) +export default function Detail({ + onUpdate, + onLoadError, + onUnauthorized, + onDelete, + onNotFound, +}: Props): VNode { + const { id } = useInstanceContext(); + const result = useInstanceDetails(); + const [deleting, setDeleting] = useState(false); - const { deleteInstance } = useInstanceAPI() + const { deleteInstance } = useInstanceAPI(); - if (result.clientError && result.isUnauthorized) return onUnauthorized() - if (result.clientError && result.isNotfound) return onNotFound() - if (result.loading) return - if (!result.ok) return onLoadError(result) + if (result.clientError && result.isUnauthorized) return onUnauthorized(); + if (result.clientError && result.isNotfound) return onNotFound(); + if (result.loading) return ; + if (!result.ok) return onLoadError(result); - return - setDeleting(true)} - /> - {deleting && setDeleting(false)} - onConfirm={async (): Promise => { - try { - await deleteInstance() - onDelete() - } catch (error) { - } - setDeleting(false) - }} - />} - - -} \ No newline at end of file + return ( + + setDeleting(true)} + /> + {deleting && ( + setDeleting(false)} + onConfirm={async (): Promise => { + try { + await deleteInstance(); + onDelete(); + } catch (error) {} + setDeleting(false); + }} + /> + )} + + ); +} -- cgit v1.2.3