diff options
author | Sebastian <sebasjm@gmail.com> | 2024-02-15 17:00:46 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2024-02-15 17:00:46 -0300 |
commit | 53497d03bb329b05caf3a64fdd47ca3c5bc298f7 (patch) | |
tree | 6371fe72f91e51a2f3e0708af43c332bbda012ef /packages/taler-wallet-webextension/src/components/ErrorMessage.tsx | |
parent | fd45d189259cef0a3a51683bb12412cd8c6fb9eb (diff) | |
download | wallet-core-53497d03bb329b05caf3a64fdd47ca3c5bc298f7.tar.xz |
fix #8395
Diffstat (limited to 'packages/taler-wallet-webextension/src/components/ErrorMessage.tsx')
-rw-r--r-- | packages/taler-wallet-webextension/src/components/ErrorMessage.tsx | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/packages/taler-wallet-webextension/src/components/ErrorMessage.tsx b/packages/taler-wallet-webextension/src/components/ErrorMessage.tsx index 0a53d33ba..06c8a81ef 100644 --- a/packages/taler-wallet-webextension/src/components/ErrorMessage.tsx +++ b/packages/taler-wallet-webextension/src/components/ErrorMessage.tsx @@ -18,15 +18,18 @@ import { h, VNode } from "preact"; import { useState } from "preact/hooks"; import arrowDown from "../svg/chevron-down.inline.svg"; import { ErrorBox } from "./styled/index.js"; +import { useTranslationContext } from "@gnu-taler/web-util/browser"; export function ErrorMessage({ title, description, }: { title: TranslatedString; - description?: string | VNode; + description?: string | VNode | Error; }): VNode | null { const [showErrorDetail, setShowErrorDetail] = useState(false); + const [showMore, setShowMore] = useState(false); + const { i18n } = useTranslationContext(); return ( <ErrorBox style={{ paddingTop: 0, paddingBottom: 0 }}> <div> @@ -44,7 +47,14 @@ export function ErrorMessage({ </button> )} </div> - {showErrorDetail && <p>{description}</p>} + {showErrorDetail && description && <p> + {description instanceof Error && !showMore ? description.message : description.toString()} + {description instanceof Error && <div> + <a href="#" onClick={(e) => { + setShowMore(!showMore) + e.preventDefault() + }}>{showMore ? i18n.str`show less` : i18n.str`show more`} </a> </div>} + </p>} </ErrorBox> ); } |