Enhances data handling and geographic mapping

Refactors dashboard to use actual metrics for country data,
removing dummy data for improved accuracy. Integrates the
country-code-lookup package for geographic mapping, adding
comprehensive country coordinates. Increases performance and
data validation across API endpoints and adjusts WordCloud
component size for better visualization.

Enhances session handling with improved validation logic,
and updates configuration for allowed origins.
This commit is contained in:
2025-05-22 12:48:15 +02:00
parent 3bbb20d889
commit a17b66c078
11 changed files with 316 additions and 251 deletions

View File

@ -142,24 +142,22 @@ function DashboardContent() {
return metrics.wordCloudData;
};
// Function to prepare country data for the map - using simulated/dummy data
// Function to prepare country data for the map using actual metrics
const getCountryData = () => {
return {
US: 42,
GB: 25,
DE: 18,
FR: 15,
CA: 12,
AU: 10,
JP: 8,
BR: 6,
IN: 5,
ZA: 3,
ES: 7,
NL: 9,
IT: 6,
SE: 4,
};
if (!metrics || !metrics.countries) return {};
// Convert the countries object from metrics to the format expected by GeographicMap
const result = Object.entries(metrics.countries).reduce(
(acc, [code, count]) => {
if (code && count) {
acc[code] = count;
}
return acc;
},
{} as Record<string, number>
);
return result;
};
// Function to prepare response time distribution data
@ -378,7 +376,7 @@ function DashboardContent() {
<h3 className="font-bold text-lg text-gray-800 mb-4">
Transcript Word Cloud
</h3>
<WordCloud words={getWordCloudData()} width={500} height={300} />
<WordCloud words={getWordCloudData()} width={400} height={300} />
</div>
<div className="bg-white p-6 rounded-xl shadow">
<h3 className="font-bold text-lg text-gray-800 mb-4">

View File

@ -40,6 +40,7 @@ export default function SessionsPage() {
// Pagination states
const [currentPage, setCurrentPage] = useState(1);
const [totalPages, setTotalPages] = useState(0);
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const [pageSize, setPageSize] = useState(10); // Or make this configurable
useEffect(() => {