import { Button, Result } from "antd";
import React from "react";
import ipcTypes from "../../../ipc.types";

const { ipcRenderer } = window;
export default function ErrorResultAtom({
  title,
  errorMessage,
  tryAgainCallback,
}) {
  ipcRenderer.send(ipcTypes.default.app.toMain.track, {
    event: "ERROR_RESULT_ATOM_DISPLAYED",
    title,
    errorMessage,
  });

  return (
    <Result
      status="500"
      title={title}
      subTitle={errorMessage}
      extra={
        tryAgainCallback ? (
          <Button type="primary" onClick={() => tryAgainCallback()}>
            Try Again
          </Button>
        ) : null
      }
    />
  );
}
