summaryrefslogtreecommitdiff
path: root/packages/taler-wallet-webextension/src/components/ErrorMessage.tsx
blob: 6bbdd26dcd34b46b33c75835f69d4da6940ecaa5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import { VNode } 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>;
}