feat: Add bulk import from ISEN excel

This commit is contained in:
2025-11-20 18:00:29 +01:00
parent 1ce9055491
commit eb8132b20f
15 changed files with 1397 additions and 2017 deletions

View File

@@ -0,0 +1,117 @@
'use client';
import { useEffect, useState } from 'react';
import { useSession, signOut } from 'next-auth/react';
import { useRouter } from 'next/navigation';
import { Button } from '@/components/ui/button';
import { Input } from '@/components/ui/input';
import { Label } from '@/components/ui/label';
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
import { toast } from 'sonner';
export default function ChangePasswordPage() {
const { data: session, update, status } = useSession();
const router = useRouter();
const [newPassword, setNewPassword] = useState('');
const [confirmPassword, setConfirmPassword] = useState('');
const [loading, setLoading] = useState(false);
useEffect(() => {
if (status === 'authenticated' && !session?.user.passwordResetRequired) {
router.push('/dashboard');
}
}, [session, status, router]);
const handleSubmit = async (e: React.FormEvent) => {
e.preventDefault();
if (newPassword !== confirmPassword) {
toast.error('Passwords do not match');
return;
}
if (newPassword.length < 6) {
toast.error('Password must be at least 6 characters long');
return;
}
setLoading(true);
try {
const response = await fetch('/api/change-password', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ newPassword }),
});
if (!response.ok) {
throw new Error('Failed to change password');
}
toast.success('Password changed successfully');
await update({ passwordResetRequired: false }); // Update the session
router.push('/dashboard');
} catch (error) {
toast.error('Error changing password');
console.error(error);
} finally {
setLoading(false);
}
};
if (status === 'loading') {
return <div className="min-h-screen flex items-center justify-center">Loading...</div>;
}
if (!session?.user.passwordResetRequired) {
return null; // Will redirect via useEffect
}
return (
<div className="min-h-screen flex items-center justify-center bg-background">
<Card className="w-full max-w-md">
<CardHeader>
<CardTitle>Change Your Password</CardTitle>
</CardHeader>
<CardContent>
<p className="text-sm text-muted-foreground mb-4">
For security reasons, you must change your password before continuing.
</p>
<form onSubmit={handleSubmit} className="space-y-4">
<div>
<Label htmlFor="newPassword">New Password</Label>
<Input
id="newPassword"
type="password"
value={newPassword}
onChange={(e) => setNewPassword(e.target.value)}
required
/>
</div>
<div>
<Label htmlFor="confirmPassword">Confirm New Password</Label>
<Input
id="confirmPassword"
type="password"
value={confirmPassword}
onChange={(e) => setConfirmPassword(e.target.value)}
required
/>
</div>
<Button type="submit" className="w-full" disabled={loading}>
{loading ? 'Changing...' : 'Change Password'}
</Button>
</form>
<Button
variant="outline"
className="w-full mt-4"
onClick={() => signOut({ callbackUrl: '/login' })}
>
Logout
</Button>
</CardContent>
</Card>
</div>
);
}