Spaces:
Sleeping
Sleeping
Create components/DocumentCheckerResults.jsx
Browse files
components/DocumentCheckerResults.jsx
ADDED
@@ -0,0 +1,142 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import React from 'react';
|
2 |
+
import { AlertTriangle, CheckCircle, XCircle } from 'lucide-react';
|
3 |
+
|
4 |
+
const DocumentCheckerResults = ({ results }) => {
|
5 |
+
if (!results) {
|
6 |
+
return (
|
7 |
+
<div className="p-4 text-gray-600">
|
8 |
+
Results will appear here after processing...
|
9 |
+
</div>
|
10 |
+
);
|
11 |
+
}
|
12 |
+
|
13 |
+
// Parse the markdown-style results into sections
|
14 |
+
const sections = results.split('■').filter(Boolean);
|
15 |
+
const headerSection = sections[0];
|
16 |
+
const issuesSections = sections.slice(1);
|
17 |
+
|
18 |
+
return (
|
19 |
+
<div className="max-w-4xl mx-auto p-4 space-y-6">
|
20 |
+
{/* Header Section */}
|
21 |
+
<div className="border-b border-gray-200 pb-4">
|
22 |
+
<h1 className="text-2xl font-bold text-gray-800 mb-4">
|
23 |
+
Document Check Results Summary
|
24 |
+
</h1>
|
25 |
+
{headerSection.includes("All checks passed") ? (
|
26 |
+
<div className="flex items-center gap-2 text-green-600">
|
27 |
+
<CheckCircle className="w-5 h-5" />
|
28 |
+
<span className="font-medium">All checks passed successfully!</span>
|
29 |
+
</div>
|
30 |
+
) : (
|
31 |
+
<div className="flex items-center gap-2 text-amber-600">
|
32 |
+
<AlertTriangle className="w-5 h-5" />
|
33 |
+
<span className="font-medium">
|
34 |
+
{headerSection.match(/Found (\d+) categories/)?.[0] || "Issues found"}
|
35 |
+
</span>
|
36 |
+
</div>
|
37 |
+
)}
|
38 |
+
</div>
|
39 |
+
|
40 |
+
{/* Issues Sections */}
|
41 |
+
<div className="space-y-6">
|
42 |
+
{issuesSections.map((section, index) => {
|
43 |
+
const [title, ...content] = section.split('\n').filter(Boolean);
|
44 |
+
const [description, howToFix, ...examples] = content;
|
45 |
+
|
46 |
+
return (
|
47 |
+
<div key={index} className="bg-white rounded-lg border border-gray-200 overflow-hidden">
|
48 |
+
{/* Section Header */}
|
49 |
+
<div className="bg-gray-50 px-4 py-3 border-b border-gray-200">
|
50 |
+
<h2 className="text-lg font-semibold text-gray-800">{title.trim()}</h2>
|
51 |
+
<p className="text-sm text-gray-600 mt-1">{description?.trim()}</p>
|
52 |
+
</div>
|
53 |
+
|
54 |
+
{/* How to Fix */}
|
55 |
+
<div className="px-4 py-3 bg-green-50">
|
56 |
+
<div className="flex items-start gap-2">
|
57 |
+
<div className="mt-1">
|
58 |
+
<CheckCircle className="w-4 h-4 text-green-600" />
|
59 |
+
</div>
|
60 |
+
<div>
|
61 |
+
<span className="font-medium text-green-800">How to fix: </span>
|
62 |
+
<span className="text-green-700">{howToFix?.replace('How to fix:', '').trim()}</span>
|
63 |
+
</div>
|
64 |
+
</div>
|
65 |
+
</div>
|
66 |
+
|
67 |
+
{/* Examples */}
|
68 |
+
<div className="px-4 py-3 border-t border-gray-200">
|
69 |
+
<h3 className="font-medium text-gray-800 mb-2">Example Fix:</h3>
|
70 |
+
<div className="space-y-2 ml-4">
|
71 |
+
<div className="flex items-start gap-2">
|
72 |
+
<XCircle className="w-4 h-4 text-red-500 mt-1" />
|
73 |
+
<div className="text-red-600">
|
74 |
+
Incorrect: {examples[1]?.replace('❌ Incorrect:', '').trim()}
|
75 |
+
</div>
|
76 |
+
</div>
|
77 |
+
<div className="flex items-start gap-2">
|
78 |
+
<CheckCircle className="w-4 h-4 text-green-600 mt-1" />
|
79 |
+
<div className="text-green-600">
|
80 |
+
Correct: {examples[2]?.replace('✓ Correct :', '').trim()}
|
81 |
+
</div>
|
82 |
+
</div>
|
83 |
+
</div>
|
84 |
+
</div>
|
85 |
+
|
86 |
+
{/* Issues Found */}
|
87 |
+
<div className="px-4 py-3 border-t border-gray-200">
|
88 |
+
<h3 className="font-medium text-gray-800 mb-2">Issues found in your document:</h3>
|
89 |
+
<ul className="space-y-1 ml-4">
|
90 |
+
{examples.slice(4).map((issue, i) => {
|
91 |
+
if (issue.includes('more similar issues')) {
|
92 |
+
return (
|
93 |
+
<li key={i} className="text-gray-500 italic mt-2">
|
94 |
+
{issue.trim()}
|
95 |
+
</li>
|
96 |
+
);
|
97 |
+
}
|
98 |
+
return (
|
99 |
+
<li key={i} className="text-gray-600">
|
100 |
+
• {issue.replace('•', '').trim()}
|
101 |
+
</li>
|
102 |
+
);
|
103 |
+
})}
|
104 |
+
</ul>
|
105 |
+
</div>
|
106 |
+
</div>
|
107 |
+
);
|
108 |
+
})}
|
109 |
+
</div>
|
110 |
+
|
111 |
+
{/* Summary Section */}
|
112 |
+
{!headerSection.includes("All checks passed") && (
|
113 |
+
<div className="mt-8 border-t border-gray-200 pt-6">
|
114 |
+
<h2 className="text-xl font-bold text-gray-800 mb-4">Summary and Recommendations</h2>
|
115 |
+
|
116 |
+
<div className="space-y-4">
|
117 |
+
<div>
|
118 |
+
<h3 className="font-medium text-gray-800 mb-2">Priority Order for Fixes:</h3>
|
119 |
+
<ul className="space-y-1 ml-4">
|
120 |
+
<li className="text-red-600">1. Critical: Heading formats, required content, and document structure</li>
|
121 |
+
<li className="text-amber-600">2. Important: Terminology, acronyms, and references</li>
|
122 |
+
<li className="text-green-600">3. Standard: Formatting, spacing, and style consistency</li>
|
123 |
+
</ul>
|
124 |
+
</div>
|
125 |
+
|
126 |
+
<div>
|
127 |
+
<h3 className="font-medium text-gray-800 mb-2">Next Steps:</h3>
|
128 |
+
<ul className="space-y-1 ml-4 text-gray-600">
|
129 |
+
<li>1. Address issues in priority order</li>
|
130 |
+
<li>2. Use search/replace for consistent fixes</li>
|
131 |
+
<li>3. Re-run checker after making changes</li>
|
132 |
+
<li>4. Update your document template if needed</li>
|
133 |
+
</ul>
|
134 |
+
</div>
|
135 |
+
</div>
|
136 |
+
</div>
|
137 |
+
)}
|
138 |
+
</div>
|
139 |
+
);
|
140 |
+
};
|
141 |
+
|
142 |
+
export default DocumentCheckerResults;
|