Add documentation, clean repository templating

This commit is contained in:
2025-07-18 01:38:43 -04:00
parent 1a503d818b
commit 4f8402c5e6
33 changed files with 8178 additions and 152 deletions

View File

@@ -1,50 +0,0 @@
"use client";
import { useState } from "react";
import { api } from "~/trpc/react";
export function LatestPost() {
const [latestPost] = api.post.getLatest.useSuspenseQuery();
const utils = api.useUtils();
const [name, setName] = useState("");
const createPost = api.post.create.useMutation({
onSuccess: async () => {
await utils.post.invalidate();
setName("");
},
});
return (
<div className="w-full max-w-xs">
{latestPost ? (
<p className="truncate">Your most recent post: {latestPost.name}</p>
) : (
<p>You have no posts yet.</p>
)}
<form
onSubmit={(e) => {
e.preventDefault();
createPost.mutate({ name });
}}
className="flex flex-col gap-2"
>
<input
type="text"
placeholder="Title"
value={name}
onChange={(e) => setName(e.target.value)}
className="w-full rounded-full bg-white/10 px-4 py-2 text-white"
/>
<button
type="submit"
className="rounded-full bg-white/10 px-10 py-3 font-semibold transition hover:bg-white/20"
disabled={createPost.isPending}
>
{createPost.isPending ? "Submitting..." : "Submit"}
</button>
</form>
</div>
);
}

View File

@@ -0,0 +1,131 @@
"use client";
import { useState } from "react";
import Link from "next/link";
import { signIn } from "next-auth/react";
import { useRouter } from "next/navigation";
import { Button } from "~/components/ui/button";
import {
Card,
CardContent,
CardDescription,
CardHeader,
CardTitle,
} from "~/components/ui/card";
import { Input } from "~/components/ui/input";
import { Label } from "~/components/ui/label";
export default function SignInPage() {
const [email, setEmail] = useState("");
const [password, setPassword] = useState("");
const [isLoading, setIsLoading] = useState(false);
const [error, setError] = useState("");
const router = useRouter();
const handleSubmit = async (e: React.FormEvent) => {
e.preventDefault();
setIsLoading(true);
setError("");
try {
const result = await signIn("credentials", {
email,
password,
redirect: false,
});
if (result?.error) {
setError("Invalid email or password");
} else {
router.push("/");
router.refresh();
}
} catch (error) {
setError("An error occurred. Please try again.");
} finally {
setIsLoading(false);
}
};
return (
<div className="flex min-h-screen items-center justify-center bg-gradient-to-br from-slate-50 to-slate-100 px-4">
<div className="w-full max-w-md">
{/* Header */}
<div className="mb-8 text-center">
<Link href="/" className="inline-block">
<h1 className="text-3xl font-bold text-slate-900">HRIStudio</h1>
</Link>
<p className="mt-2 text-slate-600">
Sign in to your research account
</p>
</div>
{/* Sign In Card */}
<Card>
<CardHeader>
<CardTitle>Welcome back</CardTitle>
<CardDescription>
Enter your credentials to access your account
</CardDescription>
</CardHeader>
<CardContent>
<form onSubmit={handleSubmit} className="space-y-4">
{error && (
<div className="rounded-md bg-red-50 p-3 text-sm text-red-700">
{error}
</div>
)}
<div className="space-y-2">
<Label htmlFor="email">Email</Label>
<Input
id="email"
type="email"
placeholder="your.email@example.com"
value={email}
onChange={(e) => setEmail(e.target.value)}
required
disabled={isLoading}
/>
</div>
<div className="space-y-2">
<Label htmlFor="password">Password</Label>
<Input
id="password"
type="password"
placeholder="Enter your password"
value={password}
onChange={(e) => setPassword(e.target.value)}
required
disabled={isLoading}
/>
</div>
<Button type="submit" className="w-full" disabled={isLoading}>
{isLoading ? "Signing in..." : "Sign In"}
</Button>
</form>
<div className="mt-6 text-center text-sm text-slate-600">
Don't have an account?{" "}
<Link
href="/auth/signup"
className="font-medium text-blue-600 hover:text-blue-500"
>
Sign up here
</Link>
</div>
</CardContent>
</Card>
{/* Footer */}
<div className="mt-8 text-center text-xs text-slate-500">
<p>
© 2024 HRIStudio. A platform for Human-Robot Interaction research.
</p>
</div>
</div>
</div>
);
}

View File

@@ -0,0 +1,170 @@
"use client";
import { useState } from "react";
import Link from "next/link";
import { useRouter } from "next/navigation";
import { Button } from "~/components/ui/button";
import {
Card,
CardContent,
CardDescription,
CardHeader,
CardTitle,
} from "~/components/ui/card";
import { Input } from "~/components/ui/input";
import { Label } from "~/components/ui/label";
import { api } from "~/trpc/react";
export default function SignUpPage() {
const [name, setName] = useState("");
const [email, setEmail] = useState("");
const [password, setPassword] = useState("");
const [confirmPassword, setConfirmPassword] = useState("");
const [error, setError] = useState("");
const router = useRouter();
const createUser = api.auth.register.useMutation({
onSuccess: () => {
router.push("/auth/signin?message=Account created successfully");
},
onError: (error) => {
setError(error.message);
},
});
const handleSubmit = async (e: React.FormEvent) => {
e.preventDefault();
setError("");
// Basic validation
if (password !== confirmPassword) {
setError("Passwords do not match");
return;
}
if (password.length < 6) {
setError("Password must be at least 6 characters long");
return;
}
createUser.mutate({
name,
email,
password,
});
};
return (
<div className="flex min-h-screen items-center justify-center bg-gradient-to-br from-slate-50 to-slate-100 px-4">
<div className="w-full max-w-md">
{/* Header */}
<div className="mb-8 text-center">
<Link href="/" className="inline-block">
<h1 className="text-3xl font-bold text-slate-900">HRIStudio</h1>
</Link>
<p className="mt-2 text-slate-600">
Create your research account
</p>
</div>
{/* Sign Up Card */}
<Card>
<CardHeader>
<CardTitle>Get started</CardTitle>
<CardDescription>
Create your account to begin your HRI research
</CardDescription>
</CardHeader>
<CardContent>
<form onSubmit={handleSubmit} className="space-y-4">
{error && (
<div className="rounded-md bg-red-50 p-3 text-sm text-red-700">
{error}
</div>
)}
<div className="space-y-2">
<Label htmlFor="name">Full Name</Label>
<Input
id="name"
type="text"
placeholder="Your full name"
value={name}
onChange={(e) => setName(e.target.value)}
required
disabled={createUser.isPending}
/>
</div>
<div className="space-y-2">
<Label htmlFor="email">Email</Label>
<Input
id="email"
type="email"
placeholder="your.email@example.com"
value={email}
onChange={(e) => setEmail(e.target.value)}
required
disabled={createUser.isPending}
/>
</div>
<div className="space-y-2">
<Label htmlFor="password">Password</Label>
<Input
id="password"
type="password"
placeholder="Create a password"
value={password}
onChange={(e) => setPassword(e.target.value)}
required
disabled={createUser.isPending}
minLength={6}
/>
</div>
<div className="space-y-2">
<Label htmlFor="confirmPassword">Confirm Password</Label>
<Input
id="confirmPassword"
type="password"
placeholder="Confirm your password"
value={confirmPassword}
onChange={(e) => setConfirmPassword(e.target.value)}
required
disabled={createUser.isPending}
minLength={6}
/>
</div>
<Button
type="submit"
className="w-full"
disabled={createUser.isPending}
>
{createUser.isPending ? "Creating account..." : "Create Account"}
</Button>
</form>
<div className="mt-6 text-center text-sm text-slate-600">
Already have an account?{" "}
<Link
href="/auth/signin"
className="font-medium text-blue-600 hover:text-blue-500"
>
Sign in here
</Link>
</div>
</CardContent>
</Card>
{/* Footer */}
<div className="mt-8 text-center text-xs text-slate-500">
<p>
© 2024 HRIStudio. A platform for Human-Robot Interaction research.
</p>
</div>
</div>
</div>
);
}

View File

@@ -4,10 +4,12 @@ import { type Metadata } from "next";
import { Geist } from "next/font/google";
import { TRPCReactProvider } from "~/trpc/react";
import { SessionProvider } from "next-auth/react";
export const metadata: Metadata = {
title: "Create T3 App",
description: "Generated by create-t3-app",
title: "HRIStudio",
description:
"Web-based platform for standardizing Wizard of Oz studies in Human-Robot Interaction research",
icons: [{ rel: "icon", url: "/favicon.ico" }],
};
@@ -22,7 +24,9 @@ export default function RootLayout({
return (
<html lang="en" className={`${geist.variable}`}>
<body>
<TRPCReactProvider>{children}</TRPCReactProvider>
<SessionProvider>
<TRPCReactProvider>{children}</TRPCReactProvider>
</SessionProvider>
</body>
</html>
);

View File

@@ -1,69 +1,197 @@
import Link from "next/link";
import { LatestPost } from "~/app/_components/post";
import { auth } from "~/server/auth";
import { api, HydrateClient } from "~/trpc/server";
import { Button } from "~/components/ui/button";
import {
Card,
CardContent,
CardDescription,
CardHeader,
CardTitle,
} from "~/components/ui/card";
export default async function Home() {
const hello = await api.post.hello({ text: "from tRPC" });
const session = await auth();
if (session?.user) {
void api.post.getLatest.prefetch();
}
return (
<HydrateClient>
<main className="flex min-h-screen flex-col items-center justify-center bg-gradient-to-b from-[#2e026d] to-[#15162c] text-white">
<div className="container flex flex-col items-center justify-center gap-12 px-4 py-16">
<h1 className="text-5xl font-extrabold tracking-tight sm:text-[5rem]">
Create <span className="text-[hsl(280,100%,70%)]">T3</span> App
</h1>
<div className="grid grid-cols-1 gap-4 sm:grid-cols-2 md:gap-8">
<Link
className="flex max-w-xs flex-col gap-4 rounded-xl bg-white/10 p-4 hover:bg-white/20"
href="https://create.t3.gg/en/usage/first-steps"
target="_blank"
>
<h3 className="text-2xl font-bold">First Steps </h3>
<div className="text-lg">
Just the basics - Everything you need to know to set up your
database and authentication.
</div>
</Link>
<Link
className="flex max-w-xs flex-col gap-4 rounded-xl bg-white/10 p-4 hover:bg-white/20"
href="https://create.t3.gg/en/introduction"
target="_blank"
>
<h3 className="text-2xl font-bold">Documentation </h3>
<div className="text-lg">
Learn more about Create T3 App, the libraries it uses, and how
to deploy it.
</div>
</Link>
</div>
<div className="flex flex-col items-center gap-2">
<p className="text-2xl text-white">
{hello ? hello.greeting : "Loading tRPC query..."}
<main className="min-h-screen bg-gradient-to-br from-slate-50 to-slate-100">
<div className="container mx-auto px-4 py-16">
{/* Header */}
<div className="mb-16 flex items-center justify-between">
<div>
<h1 className="mb-2 text-4xl font-bold text-slate-900">
HRIStudio
</h1>
<p className="text-lg text-slate-600">
Web-based platform for Human-Robot Interaction research
</p>
<div className="flex flex-col items-center justify-center gap-4">
<p className="text-center text-2xl text-white">
{session && <span>Logged in as {session.user?.name}</span>}
</p>
<Link
href={session ? "/api/auth/signout" : "/api/auth/signin"}
className="rounded-full bg-white/10 px-10 py-3 font-semibold no-underline transition hover:bg-white/20"
>
{session ? "Sign out" : "Sign in"}
</Link>
</div>
</div>
{session?.user && <LatestPost />}
<div className="flex items-center gap-4">
{session?.user ? (
<div className="flex items-center gap-4">
<span className="text-sm text-slate-600">
Welcome, {session.user.name || session.user.email}
</span>
<Button asChild variant="outline">
<Link href="/api/auth/signout">Sign Out</Link>
</Button>
</div>
) : (
<div className="flex gap-2">
<Button asChild variant="outline">
<Link href="/auth/signin">Sign In</Link>
</Button>
<Button asChild>
<Link href="/auth/signup">Get Started</Link>
</Button>
</div>
)}
</div>
</div>
</main>
</HydrateClient>
{/* Main Content */}
<div className="mx-auto max-w-4xl">
{session?.user ? (
// Authenticated user dashboard
<div className="grid grid-cols-1 gap-6 md:grid-cols-2 lg:grid-cols-3">
<Card>
<CardHeader>
<CardTitle>Experiments</CardTitle>
<CardDescription>
Design and manage your HRI experiments
</CardDescription>
</CardHeader>
<CardContent>
<Button className="w-full" asChild>
<Link href="/experiments">View Experiments</Link>
</Button>
</CardContent>
</Card>
<Card>
<CardHeader>
<CardTitle>Wizard Interface</CardTitle>
<CardDescription>
Control robots during live trials
</CardDescription>
</CardHeader>
<CardContent>
<Button className="w-full" asChild>
<Link href="/wizard">Open Wizard</Link>
</Button>
</CardContent>
</Card>
<Card>
<CardHeader>
<CardTitle>Data & Analytics</CardTitle>
<CardDescription>
Analyze trial results and performance
</CardDescription>
</CardHeader>
<CardContent>
<Button className="w-full" asChild>
<Link href="/analytics">View Data</Link>
</Button>
</CardContent>
</Card>
</div>
) : (
// Public landing page
<div className="text-center">
<div className="mx-auto mb-12 max-w-3xl">
<h2 className="mb-6 text-3xl font-bold text-slate-900">
Standardize Your Wizard of Oz Studies
</h2>
<p className="mb-8 text-xl text-slate-600">
HRIStudio provides a comprehensive platform for designing,
executing, and analyzing Human-Robot Interaction experiments
with standardized Wizard of Oz methodologies.
</p>
<div className="mb-12 grid grid-cols-1 gap-8 md:grid-cols-3">
<div className="text-center">
<div className="mx-auto mb-4 flex h-16 w-16 items-center justify-center rounded-lg bg-blue-100">
<svg
className="h-8 w-8 text-blue-600"
fill="none"
stroke="currentColor"
viewBox="0 0 24 24"
>
<path
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth={2}
d="M9.663 17h4.673M12 3v1m6.364 1.636l-.707.707M21 12h-1M4 12H3m3.343-5.657l-.707-.707m2.828 9.9a5 5 0 117.072 0l-.548.547A3.374 3.374 0 0014 18.469V19a2 2 0 11-4 0v-.531c0-.895-.356-1.754-.988-2.386l-.548-.547z"
/>
</svg>
</div>
<h3 className="mb-2 text-lg font-semibold text-slate-900">
Visual Experiment Designer
</h3>
<p className="text-slate-600">
Drag-and-drop interface for creating complex interaction
scenarios
</p>
</div>
<div className="text-center">
<div className="mx-auto mb-4 flex h-16 w-16 items-center justify-center rounded-lg bg-green-100">
<svg
className="h-8 w-8 text-green-600"
fill="none"
stroke="currentColor"
viewBox="0 0 24 24"
>
<path
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth={2}
d="M13 10V3L4 14h7v7l9-11h-7z"
/>
</svg>
</div>
<h3 className="mb-2 text-lg font-semibold text-slate-900">
Real-time Control
</h3>
<p className="text-slate-600">
Live robot control with responsive wizard interface
</p>
</div>
<div className="text-center">
<div className="mx-auto mb-4 flex h-16 w-16 items-center justify-center rounded-lg bg-purple-100">
<svg
className="h-8 w-8 text-purple-600"
fill="none"
stroke="currentColor"
viewBox="0 0 24 24"
>
<path
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth={2}
d="M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"
/>
</svg>
</div>
<h3 className="mb-2 text-lg font-semibold text-slate-900">
Advanced Analytics
</h3>
<p className="text-slate-600">
Comprehensive data capture and analysis tools
</p>
</div>
</div>
<Button size="lg" asChild>
<Link href="/auth/signup">Start Your Research</Link>
</Button>
</div>
</div>
)}
</div>
</div>
</main>
);
}