diff options
author | Sebastian <sebasjm@gmail.com> | 2024-03-29 16:52:25 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2024-03-29 16:52:40 -0300 |
commit | c3cba95a9fd88eb77fd18263287d3a63a9f757e2 (patch) | |
tree | 5d05bc48742c0984d8d0aff3a4c2a94c54332803 /packages/merchant-backoffice-ui/src/components/form | |
parent | 81f87ede72ada7e7f313b9a4212e0c75c5f54ac9 (diff) | |
download | wallet-core-c3cba95a9fd88eb77fd18263287d3a63a9f757e2.tar.xz |
wip #8655
Diffstat (limited to 'packages/merchant-backoffice-ui/src/components/form')
-rw-r--r-- | packages/merchant-backoffice-ui/src/components/form/JumpToElementById.tsx | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/packages/merchant-backoffice-ui/src/components/form/JumpToElementById.tsx b/packages/merchant-backoffice-ui/src/components/form/JumpToElementById.tsx index a0e1d6ae4..f5f9d5b4f 100644 --- a/packages/merchant-backoffice-ui/src/components/form/JumpToElementById.tsx +++ b/packages/merchant-backoffice-ui/src/components/form/JumpToElementById.tsx @@ -3,7 +3,7 @@ import { useTranslationContext } from "@gnu-taler/web-util/browser"; import { h, VNode } from "preact"; import { useState } from "preact/hooks"; -export function JumpToElementById({ testIfExist, onSelect, placeholder, description }: { placeholder: TranslatedString, description: TranslatedString, testIfExist: (id: string) => Promise<any>, onSelect: (id: string) => void }): VNode { +export function JumpToElementById({ testIfExist, onSelect, placeholder, description }: { placeholder: TranslatedString, description: TranslatedString, testIfExist: (id: string) => Promise<boolean>, onSelect: (id: string) => void }): VNode { const { i18n } = useTranslationContext() const [error, setError] = useState<string | undefined>( @@ -17,9 +17,13 @@ export function JumpToElementById({ testIfExist, onSelect, placeholder, descript return; } try { - await testIfExist(currentId); - onSelect(currentId); - setError(undefined); + const exi = await testIfExist(currentId); + if (exi) { + onSelect(currentId); + setError(undefined); + } else { + setError(i18n.str`not found`); + } } catch { setError(i18n.str`not found`); } |