feat: update package dependencies and improve session handling

- Added @tailwindcss/postcss to devDependencies for better PostCSS integration.
- Enhanced session import logic in refresh-sessions.ts to ensure proper data mapping and type safety.
- Updated postcss.config.js to use the correct plugin name for Tailwind CSS.
- Modified tsconfig.json to temporarily disable strict mode and allow implicit any types for smoother development.
This commit is contained in:
2025-05-21 21:14:48 +02:00
parent cdaa3ea19d
commit b6b67dcd78
11 changed files with 898 additions and 99 deletions

View File

@ -6,6 +6,7 @@ import { signOut, useSession } from 'next-auth/react';
import { SessionsLineChart, CategoriesBarChart } from '../../components/Charts';
import DashboardSettings from './settings';
import UserManagement from './users';
import { Company, MetricsResult } from '../../lib/types';
interface MetricsCardProps {
label: string;
@ -22,9 +23,9 @@ function MetricsCard({ label, value }: MetricsCardProps) {
}
export default function DashboardPage() {
const { data: session } = useSession();
const [metrics, setMetrics] = useState<Record<string, unknown> | null>(null);
const [company, setCompany] = useState<Record<string, unknown> | null>(null);
const { data: session } = useSession() || { data: null };
const [metrics, setMetrics] = useState<MetricsResult | null>(null);
const [company, setCompany] = useState<Company | null>(null);
// Loading state used in the fetchData function
const [, setLoading] = useState<boolean>(false);
const [csvUrl, setCsvUrl] = useState<string>('');
@ -120,26 +121,31 @@ export default function DashboardPage() {
<MetricsCard label="Escalated" value={metrics?.escalatedCount} />
<MetricsCard
label="Avg. Sentiment"
value={metrics?.avgSentiment?.toFixed(2)}
value={
metrics?.avgSentiment !== undefined ?
metrics.avgSentiment.toFixed(2)
: undefined
}
/>
<MetricsCard
label="Total Tokens (€)"
value={metrics?.totalTokensEur?.toFixed(2)}
value={
metrics?.totalTokensEur !== undefined ?
metrics.totalTokensEur.toFixed(2)
: undefined
}
/>
<MetricsCard
label="Below Sentiment Threshold"
value={metrics?.belowSentimentThreshold}
value={metrics?.belowThresholdCount}
/>
</div>
<div className="grid grid-cols-1 md:grid-cols-2 gap-8">
<div>
<h2 className="font-bold mb-2">Sessions Per Day</h2>
{(
metrics?.sessionsPerDay &&
Object.keys(metrics.sessionsPerDay).length > 0
) ?
<SessionsLineChart sessionsPerDay={metrics.sessionsPerDay} />
{metrics?.days && Object.keys(metrics.days).length > 0 ?
<SessionsLineChart sessionsPerDay={metrics.days} />
: <span>No data</span>}
</div>
<div>

View File

@ -1,10 +1,11 @@
'use client';
import { useState } from 'react';
import { useState, Suspense } from 'react';
import { useRouter, useSearchParams } from 'next/navigation';
export default function ResetPasswordPage() {
// Component that uses useSearchParams wrapped in Suspense
function ResetPasswordForm() {
const searchParams = useSearchParams();
const token = searchParams.get('token');
const token = searchParams?.get('token');
const [password, setPassword] = useState<string>('');
const [message, setMessage] = useState<string>('');
const router = useRouter();
@ -22,23 +23,36 @@ export default function ResetPasswordPage() {
} else setMessage('Invalid or expired link.');
}
return (
<form onSubmit={handleSubmit} className="flex flex-col gap-4">
<input
className="border px-3 py-2 rounded"
type="password"
placeholder="New Password"
value={password}
onChange={(e) => setPassword(e.target.value)}
required
/>
<button className="bg-blue-600 text-white rounded py-2" type="submit">
Reset Password
</button>
<div className="mt-4 text-green-700">{message}</div>
</form>
);
}
// Loading fallback component
function LoadingForm() {
return <div className="text-center py-4">Loading...</div>;
}
export default function ResetPasswordPage() {
return (
<div className="max-w-md mx-auto mt-24 bg-white rounded-xl p-8 shadow">
<h1 className="text-2xl font-bold mb-6">Reset Password</h1>
<form onSubmit={handleSubmit} className="flex flex-col gap-4">
<input
className="border px-3 py-2 rounded"
type="password"
placeholder="New Password"
value={password}
onChange={(e) => setPassword(e.target.value)}
required
/>
<button className="bg-blue-600 text-white rounded py-2" type="submit">
Reset Password
</button>
</form>
<div className="mt-4 text-green-700">{message}</div>
<Suspense fallback={<LoadingForm />}>
<ResetPasswordForm />
</Suspense>
</div>
);
}