- Remove tab system entirely (tab-store, tab-bar, tab-link) - Split monolithic AuthContext into zustand auth + workspace stores - Move issue components/config to features/issues/ - Move WebSocket provider to features/realtime/ - Move api.ts to shared/ - Migrate all consumers from useAuth() to direct store imports - Simplify sidebar: replace hand-built dropdown with shadcn DropdownMenu, replace custom layout wrapper with SidebarInset - Remove unused @multica/store and @multica/hooks dependencies - Add @/ path alias and zustand dependency - Update CLAUDE.md with feature-based architecture conventions Net change: +293 / -2435 lines Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
107 lines
3.2 KiB
TypeScript
107 lines
3.2 KiB
TypeScript
"use client";
|
|
|
|
import { Suspense, useState } from "react";
|
|
import { useSearchParams, useRouter } from "next/navigation";
|
|
import { useAuthStore } from "@/features/auth";
|
|
import { useWorkspaceStore } from "@/features/workspace";
|
|
import { api } from "@/shared/api";
|
|
import {
|
|
Card,
|
|
CardHeader,
|
|
CardTitle,
|
|
CardDescription,
|
|
CardContent,
|
|
CardFooter,
|
|
} from "@multica/ui/components/ui/card";
|
|
import { Input } from "@multica/ui/components/ui/input";
|
|
import { Button } from "@multica/ui/components/ui/button";
|
|
import { Label } from "@multica/ui/components/ui/label";
|
|
|
|
function LoginPageContent() {
|
|
const router = useRouter();
|
|
const login = useAuthStore((s) => s.login);
|
|
const isLoading = useAuthStore((s) => s.isLoading);
|
|
const hydrateWorkspace = useWorkspaceStore((s) => s.hydrateWorkspace);
|
|
const searchParams = useSearchParams();
|
|
const [email, setEmail] = useState("");
|
|
const [name, setName] = useState("");
|
|
const [error, setError] = useState("");
|
|
const [submitting, setSubmitting] = useState(false);
|
|
|
|
const handleSubmit = async (e: React.FormEvent) => {
|
|
e.preventDefault();
|
|
if (!email) {
|
|
setError("Email is required");
|
|
return;
|
|
}
|
|
setError("");
|
|
setSubmitting(true);
|
|
try {
|
|
await login(email, name || undefined);
|
|
const wsList = await api.listWorkspaces();
|
|
await hydrateWorkspace(wsList);
|
|
router.push(searchParams.get("next") || "/issues");
|
|
} catch (err) {
|
|
setError("Login failed. Make sure the server is running.");
|
|
setSubmitting(false);
|
|
}
|
|
};
|
|
|
|
return (
|
|
<div className="flex min-h-screen items-center justify-center">
|
|
<Card className="w-full max-w-sm">
|
|
<CardHeader className="text-center">
|
|
<CardTitle className="text-2xl">Multica</CardTitle>
|
|
<CardDescription>AI-native task management</CardDescription>
|
|
</CardHeader>
|
|
<CardContent>
|
|
<form id="login-form" onSubmit={handleSubmit} className="space-y-4">
|
|
<div className="space-y-2">
|
|
<Label htmlFor="name">Name</Label>
|
|
<Input
|
|
id="name"
|
|
type="text"
|
|
placeholder="Your name"
|
|
value={name}
|
|
onChange={(e) => setName(e.target.value)}
|
|
/>
|
|
</div>
|
|
<div className="space-y-2">
|
|
<Label htmlFor="email">Email</Label>
|
|
<Input
|
|
id="email"
|
|
type="email"
|
|
placeholder="you@example.com"
|
|
value={email}
|
|
onChange={(e) => setEmail(e.target.value)}
|
|
required
|
|
/>
|
|
</div>
|
|
{error && (
|
|
<p className="text-sm text-destructive">{error}</p>
|
|
)}
|
|
</form>
|
|
</CardContent>
|
|
<CardFooter>
|
|
<Button
|
|
type="submit"
|
|
form="login-form"
|
|
disabled={submitting || isLoading}
|
|
className="w-full"
|
|
size="lg"
|
|
>
|
|
{submitting ? "Signing in..." : "Sign in"}
|
|
</Button>
|
|
</CardFooter>
|
|
</Card>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
export default function LoginPage() {
|
|
return (
|
|
<Suspense fallback={null}>
|
|
<LoginPageContent />
|
|
</Suspense>
|
|
);
|
|
}
|