ui: Update user management pages

This commit is contained in:
Dries Augustyns
2026-04-17 11:03:12 +02:00
parent 5e62f517fc
commit 03a058ad48
6 changed files with 315 additions and 246 deletions
+77 -62
View File
@@ -14,6 +14,7 @@ import {
} from '@plunk/ui';
import {AnimatePresence, motion} from 'framer-motion';
import {NextSeo} from 'next-seo';
import Image from 'next/image';
import Link from 'next/link';
import {useRouter} from 'next/router';
import React, {useEffect, useState} from 'react';
@@ -22,6 +23,32 @@ import type {z} from 'zod';
import {network} from '../../lib/network';
const dotGrid = {
backgroundColor: '#fafafa',
backgroundImage: 'radial-gradient(#e5e7eb 1px, transparent 1px)',
backgroundSize: '20px 20px',
};
const Spinner = () => (
<svg className="h-4 w-4 animate-spin" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
<circle className="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" strokeWidth="4" />
<path
className="opacity-75"
fill="currentColor"
d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
/>
</svg>
);
const Wordmark = () => (
<div className="flex items-center justify-center gap-2.5">
<div className="h-8 w-8 rounded-lg bg-white shadow-sm border border-neutral-200 flex items-center justify-center p-1">
<Image src="/assets/logo.svg" alt="" aria-hidden width={24} height={24} />
</div>
<span className="text-lg font-bold tracking-tight text-neutral-900">Plunk</span>
</div>
);
export default function ResetPassword() {
const router = useRouter();
const {token} = router.query;
@@ -37,7 +64,6 @@ export default function ResetPassword() {
},
});
// Update form token when router is ready
useEffect(() => {
if (token && typeof token === 'string') {
form.setValue('token', token);
@@ -71,22 +97,25 @@ export default function ResetPassword() {
return (
<>
<NextSeo title="Reset Password" />
<div className="min-h-screen flex items-center justify-center bg-neutral-50 py-12">
<div className="min-h-screen flex items-center justify-center py-12" style={dotGrid}>
<div className="flex flex-col gap-6 max-w-md w-full px-4">
<Wordmark />
<Card>
<CardContent className="p-8">
<div className="flex flex-col items-center gap-4 text-center">
<div className="h-16 w-16 rounded-full bg-red-100 flex items-center justify-center">
<svg className="h-8 w-8 text-red-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<div className="h-12 w-12 rounded-full bg-neutral-100 flex items-center justify-center">
<svg className="h-6 w-6 text-neutral-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M6 18L18 6M6 6l12 12" />
</svg>
</div>
<h1 className="text-2xl font-bold tracking-tight text-red-600">Invalid reset link</h1>
<p className="text-neutral-600">
This password reset link is invalid. Please request a new one from the login page.
</p>
<Link href="/auth/login">
<Button className="w-full mt-4">Back to login</Button>
<div className="flex flex-col gap-1.5">
<h1 className="text-xl font-bold tracking-tight">Invalid reset link</h1>
<p className="text-sm text-neutral-500">
This link is invalid or has expired. Request a new one from the login page.
</p>
</div>
<Link href="/auth/login" className="mt-2">
<Button>Back to login</Button>
</Link>
</div>
</CardContent>
@@ -100,29 +129,31 @@ export default function ResetPassword() {
return (
<>
<NextSeo title="Reset Password" />
<div className="min-h-screen flex items-center justify-center bg-neutral-50 py-12">
<div className="min-h-screen flex items-center justify-center py-12" style={dotGrid}>
<div className="flex flex-col gap-6 max-w-md w-full px-4">
<Wordmark />
<Card>
<CardContent className="p-0">
<AnimatePresence mode="wait">
{status === 'success' ? (
<motion.div
key="success"
initial={{opacity: 0, scale: 0.95}}
initial={{opacity: 0, scale: 0.97}}
animate={{opacity: 1, scale: 1}}
exit={{opacity: 0}}
transition={{duration: 0.2}}
className="p-8"
>
<div className="flex flex-col items-center gap-4 text-center">
<div className="h-16 w-16 rounded-full bg-green-100 flex items-center justify-center">
<svg className="h-8 w-8 text-green-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<div className="h-12 w-12 rounded-full bg-neutral-100 flex items-center justify-center">
<svg className="h-6 w-6 text-neutral-700" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M5 13l4 4L19 7" />
</svg>
</div>
<h1 className="text-2xl font-bold tracking-tight text-green-600">Password reset!</h1>
<p className="text-neutral-600">
Your password has been successfully reset. Redirecting to login...
</p>
<div className="flex flex-col gap-1.5">
<h1 className="text-xl font-bold tracking-tight">Password updated</h1>
<p className="text-sm text-neutral-500">Redirecting you to login...</p>
</div>
</div>
</motion.div>
) : (
@@ -135,34 +166,33 @@ export default function ResetPassword() {
}}
>
<div className="flex flex-col gap-6">
<div className="flex flex-col gap-2">
<h1 className="text-3xl font-bold tracking-tight">Reset your password</h1>
<p className="text-neutral-600">Enter your new password below</p>
<div className="flex flex-col gap-1.5">
<h1 className="text-2xl font-bold tracking-tight">Reset your password</h1>
<p className="text-sm text-neutral-500">Enter your new password below</p>
</div>
<div className="grid gap-2">
<FormField
control={form.control}
name="newPassword"
render={({field}) => (
<FormItem>
<FormLabel>New Password</FormLabel>
<FormControl>
<Input placeholder="Enter new password" type="password" {...field} />
</FormControl>
<FormMessage />
</FormItem>
)}
/>
</div>
<FormField
control={form.control}
name="newPassword"
render={({field}) => (
<FormItem>
<FormLabel>New password</FormLabel>
<FormControl>
<Input placeholder="At least 6 characters" type="password" autoFocus {...field} />
</FormControl>
<FormMessage />
</FormItem>
)}
/>
<AnimatePresence>
{status === 'error' && (
<motion.p
initial={{opacity: 0, y: -10}}
initial={{opacity: 0, y: -8}}
animate={{opacity: 1, y: 0}}
exit={{opacity: 0, y: -10}}
className="text-sm font-medium text-red-500"
exit={{opacity: 0, y: -8}}
transition={{duration: 0.15}}
className="text-sm text-red-500"
>
{errorMessage}
</motion.p>
@@ -172,38 +202,23 @@ export default function ResetPassword() {
<Button type="submit" className="w-full" disabled={form.formState.isSubmitting}>
{form.formState.isSubmitting ? (
<>
<svg
className="h-4 w-4 animate-spin"
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
>
<circle
className="opacity-25"
cx="12"
cy="12"
r="10"
stroke="currentColor"
strokeWidth="4"
/>
<path
className="opacity-75"
fill="currentColor"
d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
/>
</svg>
<Spinner />
Resetting...
</>
) : (
'Reset password'
)}
</Button>
<div className="text-center text-sm text-neutral-500">
<p className="text-center text-sm text-neutral-500">
Remember your password?{' '}
<Link href="/auth/login" className="underline underline-offset-4 hover:text-neutral-900">
<Link
href="/auth/login"
className="text-neutral-900 underline underline-offset-4 hover:text-neutral-600 transition-colors"
>
Back to login
</Link>
</div>
</p>
</div>
</form>
</Form>