All files / Error ErrorRender.tsx

0% Statements 0/45
0% Branches 0/1
0% Functions 0/1
0% Lines 0/45

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46                                                                                           
import React, { useContext, useState } from "react";
//import Localize, { LocalizeContext } from "Controllers/Shared/Components/Localize";
import styled from "@emotion/styled";
import { FaSurprise } from "react-icons/fa";
import Alert from "reactstrap/lib/Alert";

interface Props {
  error: any;
  customMessage?: string;
}

const defaultStrings = {
  SomethingWentWrongText: "SomethingWentWrongText",
};

function ErrorRender({ error, customMessage }: Props) {
  const ErrorContainer = styled(Alert)`
    height: 400px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 32px;
  `;

  if (customMessage) {
    //do nothing
    //} else if (localizedStrings) {
    //    customMessage = localizedStrings.SomethingWentWrongText;
  } else {
    customMessage = "Something went wrong";
  }

  return (
    <ErrorContainer color="danger" data-testid="error">
      <FaSurprise /> {customMessage}
      {error && (
        <div>
          <br />
          <p style={{ maxHeight: "10em;", overflowY: "auto" }}>{JSON.stringify(error)}</p>
        </div>
      )}
    </ErrorContainer>
  );
}
export default ErrorRender;