mirror of
https://github.com/ramvignesh-b/pi-ku.git
synced 2026-05-04 19:10:52 +00:00
refactor: centralize route configuration
This commit is contained in:
@@ -70,15 +70,9 @@ export default function Activate() {
|
||||
{status === "error" && (
|
||||
<div className="flex flex-col items-center gap-6 animate-in fade-in zoom-in duration-500">
|
||||
<div className="bg-error/10 p-4 rounded-full">
|
||||
<XCircleIcon
|
||||
size={64}
|
||||
weight="duotone"
|
||||
className="text-error-content"
|
||||
/>
|
||||
<XCircleIcon size={64} weight="duotone" className="text-error" />
|
||||
</div>
|
||||
<h2 className="font-display text-xl text-error-content">
|
||||
Activation Failed
|
||||
</h2>
|
||||
<h2 className="font-display text-xl text-error">Activation Failed</h2>
|
||||
<p className="opacity-70 mb-8 leading-relaxed">
|
||||
The link might be expired or already used. Please try registering
|
||||
again.
|
||||
|
||||
@@ -6,6 +6,7 @@ import { useNavigate } from "react-router-dom";
|
||||
import { z } from "zod";
|
||||
import Logo from "../components/Logo";
|
||||
import FormField from "../components/ui/FormField";
|
||||
import { ROUTES } from "../config/routes";
|
||||
import { useAuth } from "../store/useAuth";
|
||||
|
||||
const loginSchema = z.object({
|
||||
@@ -34,7 +35,7 @@ export default function Login() {
|
||||
setApiError(null);
|
||||
try {
|
||||
await login(data);
|
||||
navigate("/drawer");
|
||||
navigate(ROUTES.DRAWER);
|
||||
} catch (err) {
|
||||
console.error("Login error:", err);
|
||||
let message = "Invalid email or password";
|
||||
@@ -48,62 +49,59 @@ export default function Login() {
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="flex min-h-screen items-center justify-center bg-base-200">
|
||||
<div className="glass-card w-full max-w-sm p-2 transition-all duration-500 hover:shadow-2xl fade-zoom">
|
||||
<form onSubmit={handleSubmit(onSubmit)} className="card-body gap-4">
|
||||
<h2 className="card-title font-display text-2xl font-bold justify-center text-primary tracking-tight">
|
||||
Sign in to <Logo />
|
||||
</h2>
|
||||
<div className="glass-card w-full max-w-sm p-2 transition-all duration-500 hover:shadow-2xl fade-zoom">
|
||||
<form onSubmit={handleSubmit(onSubmit)} className="card-body gap-4">
|
||||
<h1 className="card-title font-display text-2xl font-bold justify-center text-primary tracking-tight">
|
||||
Sign in to <Logo />
|
||||
</h1>
|
||||
|
||||
{apiError && (
|
||||
<div className="alert alert-error text-xs py-2 rounded-md">
|
||||
<span>{apiError}</span>
|
||||
</div>
|
||||
{apiError && (
|
||||
<div className="alert alert-error text-xs py-2 rounded-md">
|
||||
<span>{apiError}</span>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<FormField
|
||||
label="Email"
|
||||
type="email"
|
||||
placeholder="you@email.com"
|
||||
registration={register("email")}
|
||||
error={errors.email?.message}
|
||||
/>
|
||||
|
||||
<FormField
|
||||
label="Password"
|
||||
type="password"
|
||||
placeholder="••••••••"
|
||||
registration={register("password")}
|
||||
error={errors.password?.message}
|
||||
/>
|
||||
|
||||
<div className="card-actions mt-4">
|
||||
<button
|
||||
type="submit"
|
||||
disabled={isLoading}
|
||||
aria-label="Sign In"
|
||||
className="btn btn-primary w-full shadow-lg"
|
||||
>
|
||||
{isLoading ? (
|
||||
<span className="loading loading-spinner loading-sm" />
|
||||
) : (
|
||||
"Sign In"
|
||||
)}
|
||||
|
||||
<FormField
|
||||
label="Email"
|
||||
type="email"
|
||||
placeholder="you@email.com"
|
||||
registration={register("email")}
|
||||
error={errors.email?.message}
|
||||
/>
|
||||
|
||||
<FormField
|
||||
label="Password"
|
||||
type="password"
|
||||
placeholder="••••••••"
|
||||
registration={register("password")}
|
||||
error={errors.password?.message}
|
||||
/>
|
||||
|
||||
<div className="card-actions mt-4">
|
||||
<button
|
||||
type="submit"
|
||||
disabled={isLoading}
|
||||
className="btn btn-primary w-full shadow-lg"
|
||||
>
|
||||
{isLoading ? (
|
||||
<span className="loading loading-spinner loading-sm" />
|
||||
) : (
|
||||
"Sign In"
|
||||
)}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div className="text-center text-sm opacity-70">
|
||||
Don't have an account?{" "}
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => navigate("/register")}
|
||||
className="link link-primary text-primary-content no-underline hover:underline"
|
||||
>
|
||||
Register
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
<div className="text-center text-sm font-medium text-base-content/70">
|
||||
Don't have an account?{" "}
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => navigate(ROUTES.ONBOARD)}
|
||||
className="link link-primary no-underline hover:underline font-bold"
|
||||
>
|
||||
Register
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>;
|
||||
}
|
||||
|
||||
@@ -62,9 +62,9 @@ export default function Register() {
|
||||
return (
|
||||
<div className="glass-card w-full max-w-sm p-2 transition-all duration-500 hover:shadow-2xl fade-zoom">
|
||||
<form onSubmit={handleSubmit(onSubmit)} className="card-body gap-4">
|
||||
<h2 className="card-title font-display text-2xl font-bold justify-center text-primary tracking-tight">
|
||||
<h1 className="card-title font-display text-2xl font-bold justify-center text-primary tracking-tight">
|
||||
Create a <Logo /> Account
|
||||
</h2>
|
||||
</h1>
|
||||
|
||||
{apiError && (
|
||||
<div className="alert alert-error text-xs py-2 rounded-md">
|
||||
@@ -104,15 +104,11 @@ export default function Register() {
|
||||
/>
|
||||
|
||||
{/* Warning */}
|
||||
<div className="bg-warning/10 border-l-2 border-warning p-3 rounded-r-md flex gap-2">
|
||||
<InfoIcon
|
||||
size={20}
|
||||
weight="duotone"
|
||||
className="text-warning mt-0.5 shrink-0"
|
||||
/>
|
||||
<p className="text-sm text-warning-content font-medium opacity-90">
|
||||
<div className="alert alert-warning items-start text-left p-3 gap-2 rounded-md border-warning/20">
|
||||
<InfoIcon size={20} weight="duotone" className="mt-0.5 shrink-0" />
|
||||
<p className="text-sm font-semibold">
|
||||
Choose a password you won't forget. <br />
|
||||
<span className="font-semibold underline">There is no reset.</span>{" "}
|
||||
<span className="underline decoration-2">There is no reset.</span>{" "}
|
||||
If you lose it, your letters cannot be recovered.
|
||||
</p>
|
||||
</div>
|
||||
@@ -121,6 +117,7 @@ export default function Register() {
|
||||
<button
|
||||
type="submit"
|
||||
disabled={isLoading}
|
||||
aria-label="Register"
|
||||
className="btn btn-primary w-full shadow-lg"
|
||||
>
|
||||
{isLoading ? (
|
||||
|
||||
@@ -22,7 +22,7 @@ export default function VerifyEmail() {
|
||||
|
||||
<div className="divider opacity-10"></div>
|
||||
|
||||
<div className="bg-base-200/50 p-4 rounded-lg text-xs leading-relaxed text-left opacity-70">
|
||||
<div className="alert bg-base-200/50 p-4 rounded-lg text-xs leading-relaxed text-left opacity-70">
|
||||
<p>
|
||||
Didn't receive it? Check your spam folder or wait for a few minutes.
|
||||
The link will expire in 24 hours.
|
||||
|
||||
Reference in New Issue
Block a user