2021-08-23 21:51:49 +02:00
|
|
|
import { VNode, h } from "preact";
|
2021-07-12 19:47:13 +02:00
|
|
|
import { useState } from "preact/hooks";
|
|
|
|
import arrowDown from '../../static/img/chevron-down.svg';
|
|
|
|
import { ErrorBox } from "./styled";
|
|
|
|
|
2021-07-12 19:47:59 +02:00
|
|
|
export function ErrorMessage({ title, description }: { title?: string|VNode; description?: string; }) {
|
2021-07-12 19:47:13 +02:00
|
|
|
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>;
|
|
|
|
}
|