From 98013322db6b912ac50d72353dbd8b5f7fbc0435 Mon Sep 17 00:00:00 2001
From: Sebastian <sebasjm@gmail.com>
Date: Fri, 6 Oct 2023 10:38:09 -0300
Subject: backoffice ui

---
 .../src/paths/instance/transfers/list/index.tsx               | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

(limited to 'packages/merchant-backoffice-ui/src/paths/instance/transfers/list/index.tsx')

diff --git a/packages/merchant-backoffice-ui/src/paths/instance/transfers/list/index.tsx b/packages/merchant-backoffice-ui/src/paths/instance/transfers/list/index.tsx
index 1bc1673ba..0fdbb9bc3 100644
--- a/packages/merchant-backoffice-ui/src/paths/instance/transfers/list/index.tsx
+++ b/packages/merchant-backoffice-ui/src/paths/instance/transfers/list/index.tsx
@@ -21,7 +21,7 @@
 
 import { ErrorType, HttpError } from "@gnu-taler/web-util/browser";
 import { h, VNode } from "preact";
-import { useState } from "preact/hooks";
+import { useEffect, useState } from "preact/hooks";
 import { Loading } from "../../../../components/exception/loading.js";
 import { MerchantBackend } from "../../../../declaration.js";
 import { useInstanceDetails } from "../../../../hooks/instance.js";
@@ -47,7 +47,6 @@ export default function ListTransfer({
   onCreate,
   onNotFound,
 }: Props): VNode {
-  const [form, setForm] = useState<Form>({ payto_uri: "" });
   const setFilter = (s?: "yes" | "no") => setForm({ ...form, verified: s });
 
   const [position, setPosition] = useState<string | undefined>(undefined);
@@ -56,6 +55,14 @@ export default function ListTransfer({
   const accounts = !instance.ok
     ? []
     : instance.data.accounts.map((a) => a.payto_uri);
+  const [form, setForm] = useState<Form>({ payto_uri: "" });
+
+  const shoulUseDefaultAccount = accounts.length === 1
+  useEffect(() => {
+    if (shoulUseDefaultAccount) {
+      setForm({...form, payto_uri: accounts[0]})
+    }
+  }, [shoulUseDefaultAccount])
 
   const isVerifiedTransfers = form.verified === "yes";
   const isNonVerifiedTransfers = form.verified === "no";
-- 
cgit v1.2.3

