feat: update date range calculations and improve UI components for better consistency and readability

This commit is contained in:
Max Kowalski
2025-06-28 01:12:52 +02:00
parent c4cfe2f389
commit a002d5ef76
11 changed files with 314 additions and 220 deletions

View File

@ -11,9 +11,9 @@ interface TopQuestionsChartProps {
export default function TopQuestionsChart({ data, title = "Top 5 Asked Questions" }: TopQuestionsChartProps) {
if (!data || data.length === 0) {
return (
<div className="bg-white p-6 rounded-lg shadow-sm border border-gray-200">
<h3 className="text-lg font-semibold text-gray-900 mb-4">{title}</h3>
<div className="text-center py-8 text-gray-500">
<div className="bg-white p-6 rounded-2xl shadow-sm border border-gray-100">
<h3 className="text-lg font-semibold text-gray-900 mb-6">{title}</h3>
<div className="text-center py-12 text-gray-500">
No questions data available
</div>
</div>
@ -24,36 +24,38 @@ export default function TopQuestionsChart({ data, title = "Top 5 Asked Questions
const maxCount = Math.max(...data.map(q => q.count));
return (
<div className="bg-white p-6 rounded-lg shadow-sm border border-gray-200">
<h3 className="text-lg font-semibold text-gray-900 mb-4">{title}</h3>
<div className="bg-white p-6 rounded-2xl shadow-sm border border-gray-100">
<h3 className="text-lg font-semibold text-gray-900 mb-6">{title}</h3>
<div className="space-y-4">
<div className="space-y-6">
{data.map((question, index) => {
const percentage = maxCount > 0 ? (question.count / maxCount) * 100 : 0;
return (
<div key={index} className="relative">
{/* Question text */}
<div className="flex justify-between items-start mb-2">
<p className="text-sm text-gray-700 font-medium leading-tight pr-4 flex-1">
{question.question}
</p>
<span className="text-sm font-semibold text-gray-900 bg-gray-100 px-2 py-1 rounded-md whitespace-nowrap">
{question.count}
</span>
</div>
{/* Progress bar */}
<div className="w-full bg-gray-200 rounded-full h-2">
<div
className="bg-blue-600 h-2 rounded-full transition-all duration-300 ease-in-out"
style={{ width: `${percentage}%` }}
/>
</div>
{/* Rank indicator */}
<div className="absolute -left-2 top-0 w-6 h-6 bg-blue-600 text-white text-xs font-bold rounded-full flex items-center justify-center">
{index + 1}
<div key={index} className="group">
{/* Rank and Question */}
<div className="flex items-start gap-4 mb-3">
<div className="flex-shrink-0 w-8 h-8 bg-gray-100 text-gray-900 text-sm font-semibold rounded-full flex items-center justify-center">
{index + 1}
</div>
<div className="flex-1 min-w-0">
<p className="text-sm font-medium text-gray-900 leading-relaxed mb-2">
{question.question}
</p>
<div className="flex items-center justify-between">
<div className="flex-1 mr-4">
<div className="w-full bg-gray-100 rounded-full h-2">
<div
className="bg-blue-600 h-2 rounded-full transition-all duration-500 ease-out"
style={{ width: `${percentage}%` }}
/>
</div>
</div>
<span className="text-sm font-semibold text-gray-900 min-w-0">
{question.count} times
</span>
</div>
</div>
</div>
</div>
);
@ -61,10 +63,10 @@ export default function TopQuestionsChart({ data, title = "Top 5 Asked Questions
</div>
{/* Summary */}
<div className="mt-6 pt-4 border-t border-gray-200">
<div className="flex justify-between text-sm text-gray-600">
<span>Total questions analyzed</span>
<span className="font-medium">
<div className="mt-8 pt-6 border-t border-gray-100">
<div className="flex justify-between items-center">
<span className="text-sm text-gray-600">Total questions analyzed</span>
<span className="text-sm font-semibold text-gray-900">
{data.reduce((sum, q) => sum + q.count, 0)}
</span>
</div>