diff options
Diffstat (limited to 'src/components/ResultDisplay.tsx')
| -rw-r--r-- | src/components/ResultDisplay.tsx | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/components/ResultDisplay.tsx b/src/components/ResultDisplay.tsx new file mode 100644 index 0000000..0f58f0e --- /dev/null +++ b/src/components/ResultDisplay.tsx @@ -0,0 +1,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> + ); +}; |
