Corin1998 commited on
Commit
11af141
·
verified ·
1 Parent(s): b834652

Create OutputPanel.tsx

Browse files
frontend/src/components/OutputPanel.tsx ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import React from "react";
2
+
3
+ type Props = {
4
+ data: any | null;
5
+ };
6
+
7
+ export default function OutputPanel({ data }: Props) {
8
+ if (!data) return null;
9
+ if (data.error) return <div style={{ color: "crimson" }}>Error: {data.error}</div>;
10
+
11
+ return (
12
+ <div style={{ marginTop: 16, padding: 16, border: "1px solid #eee", borderRadius: 12 }}>
13
+ <h3 style={{ marginTop: 0 }}>結果</h3>
14
+ <div><strong>件名:</strong> {data.subject}</div>
15
+ <div style={{ whiteSpace: "pre-wrap", marginTop: 8 }}>{data.body}</div>
16
+ <div style={{ marginTop: 12, opacity: 0.8 }}>
17
+ <div>toxicity: {data.quality?.toxicity?.toFixed?.(3)}</div>
18
+ <div>sentiment: {data.quality?.sentiment?.toFixed?.(3)}</div>
19
+ {data.warnings?.length ? (
20
+ <ul>{data.warnings.map((w: string, i: number) => <li key={i}>{w}</li>)}</ul>
21
+ ) : null}
22
+ {data.lint?.issues?.length ? (
23
+ <>
24
+ <div style={{ marginTop: 8 }}><strong>Lint:</strong></div>
25
+ <ul>{data.lint.issues.map((w: string, i: number) => <li key={i}>{w}</li>)}</ul>
26
+ </>
27
+ ) : null}
28
+ </div>
29
+ </div>
30
+ );
31
+ }