bugfix: the whole theming structure overhauled. light/dark mode icon added.
This commit is contained in:
@@ -107,8 +107,8 @@
|
||||
// }
|
||||
'use client';
|
||||
|
||||
import { useState, useEffect } from 'react'; // ← added useEffect
|
||||
import { useRouter } from 'next/navigation'; // ← added this
|
||||
import { useState, useEffect } from 'react';
|
||||
import { useRouter } from 'next/navigation';
|
||||
import { useForm } from 'react-hook-form';
|
||||
import { zodResolver } from '@hookform/resolvers/zod';
|
||||
import * as z from 'zod';
|
||||
@@ -127,15 +127,14 @@ const loginSchema = z.object({
|
||||
type LoginForm = z.infer<typeof loginSchema>;
|
||||
|
||||
export default function LoginPage() {
|
||||
const { login, isLoading, user, isAuthReady } = useAuth(); // ← added user + isAuthReady
|
||||
const router = useRouter(); // ← added
|
||||
const { login, isLoading, user, isAuthReady } = useAuth();
|
||||
const router = useRouter();
|
||||
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
|
||||
// ✅ Redirect if user is already logged in (prevents loop & improves UX)
|
||||
useEffect(() => {
|
||||
if (isAuthReady && user) {
|
||||
router.push('/today'); // Change to '/select-organization' if you want
|
||||
router.push('/today');
|
||||
}
|
||||
}, [user, isAuthReady, router]);
|
||||
|
||||
@@ -156,34 +155,33 @@ export default function LoginPage() {
|
||||
}
|
||||
};
|
||||
|
||||
// Optional: Show loading state while checking auth
|
||||
if (!isAuthReady) {
|
||||
return (
|
||||
<div className="min-h-screen flex items-center justify-center">
|
||||
<p>Loading...</p>
|
||||
<div className="min-h-screen app-web-bg flex items-center justify-center">
|
||||
<p className="text-text-secondary">Loading...</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="min-h-screen bg-gray-50 flex flex-col justify-center py-12 sm:px-6 lg:px-8">
|
||||
<div className="min-h-screen app-web-bg flex flex-col justify-center py-12 sm:px-6 lg:px-8">
|
||||
<div className="sm:mx-auto sm:w-full sm:max-w-md">
|
||||
<Link href="/" className="flex justify-center">
|
||||
<span className="text-3xl font-bold text-primary-600">DyoLink</span>
|
||||
<span className="text-3xl font-semibold text-text-primary">DyoLink</span>
|
||||
</Link>
|
||||
<h2 className="mt-6 text-center text-3xl font-exbol text-gray-900">
|
||||
<h2 className="mt-6 text-center text-3xl font-semibold text-text-primary">
|
||||
Sign in to your account
|
||||
</h2>
|
||||
<p className="mt-2 text-center text-sm text-gray-600">
|
||||
<p className="mt-2 text-center text-sm text-text-secondary">
|
||||
Or{' '}
|
||||
<Link href="/register" className="font-medium text-primary-600 hover:text-primary-500">
|
||||
<Link href="/register" className="font-medium text-primary hover:opacity-90">
|
||||
start your free trial
|
||||
</Link>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className="mt-8 sm:mx-auto sm:w-full sm:max-w-md">
|
||||
<div className="bg-white py-8 px-4 shadow sm:rounded-lg sm:px-10">
|
||||
<div className="surface-card py-8 px-4 sm:px-10">
|
||||
<form className="space-y-6" onSubmit={handleSubmit(onSubmit)}>
|
||||
<Input
|
||||
label="Email address"
|
||||
@@ -191,7 +189,7 @@ export default function LoginPage() {
|
||||
type="email"
|
||||
placeholder="you@example.com"
|
||||
error={errors.email?.message}
|
||||
icon={<Mail className="h-5 w-5 text-gray-400" />}
|
||||
icon={<Mail className="h-5 w-5 icon-flat" />}
|
||||
/>
|
||||
<Input
|
||||
label="Password"
|
||||
@@ -199,7 +197,7 @@ export default function LoginPage() {
|
||||
type="password"
|
||||
placeholder="••••••••"
|
||||
error={errors.password?.message}
|
||||
icon={<Lock className="h-5 w-5 text-gray-400" />}
|
||||
icon={<Lock className="h-5 w-5 icon-flat" />}
|
||||
/>
|
||||
|
||||
<div className="flex items-center justify-between">
|
||||
@@ -208,14 +206,14 @@ export default function LoginPage() {
|
||||
id="remember-me"
|
||||
name="remember-me"
|
||||
type="checkbox"
|
||||
className="h-4 w-4 text-primary-600 focus:ring-primary-500 border-gray-300 rounded"
|
||||
className="h-4 w-4 rounded border-border bg-background-secondary text-primary focus:ring-primary/40"
|
||||
/>
|
||||
<label htmlFor="remember-me" className="ml-2 block text-sm text-gray-900">
|
||||
<label htmlFor="remember-me" className="ml-2 block text-sm text-text-secondary">
|
||||
Remember me
|
||||
</label>
|
||||
</div>
|
||||
<div className="text-sm">
|
||||
<Link href="/forgot-password" className="font-medium text-primary-600 hover:text-primary-500">
|
||||
<Link href="/forgot-password" className="font-medium text-primary hover:opacity-90">
|
||||
Forgot your password?
|
||||
</Link>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user