summaryrefslogtreecommitdiff
path: root/packages/taler-wallet-webextension/src/components/ErrorMessage.tsx
blob: 4aef66d36fdeaa1d77a089feb7d40d406fc6e169 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import { VNode, h } from "preact";
import { useState } from "preact/hooks";
import arrowDown from '../../static/img/chevron-down.svg';
import { ErrorBox } from "./styled";

export function ErrorMessage({ title, description }: { title?: string|VNode; description?: string; }) {
  const [showErrorDetail, setShowErrorDetail] = useState(false);
  if (!title)
    return null;
  return <ErrorBox>
    <div>
      <p>{title}</p>
      { description && <button onClick={() => { setShowErrorDetail(v => !v); }}>
        <img style={{ height: '1.5em' }} src={arrowDown} />
      </button> }
    </div>
    {showErrorDetail && <p>{description}</p>}
  </ErrorBox>;
}