summaryrefslogtreecommitdiff
path: root/src/components/ResultDisplay.tsx
blob: 0f58f0e6853d2cb3ad0a5f3c68ebf8b8b7df4d69 (plain)
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
import { PanelSectionRow } from "@decky/ui";
import { FC } from "react";
import { STYLES } from "../utils/constants";
import { ApiResponse } from "../types/index";

export type OperationResult = ApiResponse;

interface ResultDisplayProps {
  result: OperationResult | null;
}

export const ResultDisplay: FC<ResultDisplayProps> = ({ result }) => {
  if (!result) return null;

  return (
    <PanelSectionRow>
      <div>
        <strong>Status:</strong>{" "}
        <span style={result.status === "success" ? STYLES.statusSuccess : STYLES.statusError}>
          {result.status === "success" ? "Success" : "Error"}
        </span>
        <br />
        {result.output ? (
          <>
            <strong>Output:</strong>
            <pre style={STYLES.preWrap}>{result.output}</pre>
          </>
        ) : null}
        {result.message ? (
          <>
            <strong>Error:</strong> {result.message}
          </>
        ) : null}
      </div>
    </PanelSectionRow>
  );
};