AWS SES preview

This commit is contained in:
pulipakaa24
2026-03-19 19:59:01 -05:00
parent 0193240048
commit 0b4b1a6ff5
16 changed files with 2298 additions and 65 deletions

118
components/Onboarding.tsx Normal file
View File

@@ -0,0 +1,118 @@
import { useState } from 'react';
import { Button } from './ui/button';
import { Card, CardContent } from './ui/card';
import { Input } from './ui/input';
import { Label } from './ui/label';
import { useSession } from '../lib/auth-client';
const logo = '/logo.png';
interface Props {
onComplete: () => void;
}
export function Onboarding({ onComplete }: Props) {
const { data: session } = useSession();
const [piFirstName, setPiFirstName] = useState('');
const [bldgCode, setBldgCode] = useState('');
const [lab, setLab] = useState('');
const [contact, setContact] = useState('');
const [error, setError] = useState('');
const [loading, setLoading] = useState(false);
async function handleSubmit(e: React.FormEvent) {
e.preventDefault();
setError('');
setLoading(true);
const res = await fetch('/api/profile', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
credentials: 'include',
body: JSON.stringify({
pi_first_name: piFirstName,
bldg_code: bldgCode,
lab,
contact: contact || undefined,
}),
});
setLoading(false);
if (res.ok) {
onComplete();
} else {
const data = await res.json();
setError(data.error || 'Failed to save profile');
}
}
return (
<div className="flex h-screen items-center justify-center bg-secondary">
<Card className="w-full max-w-sm">
<CardContent className="p-8 space-y-6">
<div className="flex justify-center">
<img src={logo} alt="LabWise" className="h-12" />
</div>
<div className="space-y-1">
<h2 className="font-semibold text-lg">
Welcome{session?.user.name ? `, ${session.user.name.split(' ')[0]}` : ''}!
</h2>
<p className="text-sm text-muted-foreground">
Set up your lab details. These will be used as defaults when adding inventory.
</p>
</div>
<form onSubmit={handleSubmit} className="space-y-4">
<div className="space-y-1">
<Label htmlFor="pi">PI first name</Label>
<Input
id="pi"
type="text"
value={piFirstName}
onChange={e => setPiFirstName(e.target.value)}
required
placeholder="e.g. Smith"
/>
</div>
<div className="space-y-1">
<Label htmlFor="bldg">Building code</Label>
<Input
id="bldg"
type="text"
value={bldgCode}
onChange={e => setBldgCode(e.target.value)}
required
placeholder="e.g. EER"
/>
</div>
<div className="space-y-1">
<Label htmlFor="lab">Lab</Label>
<Input
id="lab"
type="text"
value={lab}
onChange={e => setLab(e.target.value)}
required
placeholder="e.g. 3.822"
/>
</div>
<div className="space-y-1">
<Label htmlFor="contact">
Contact <span className="text-muted-foreground font-normal">(optional)</span>
</Label>
<Input
id="contact"
type="text"
value={contact}
onChange={e => setContact(e.target.value)}
placeholder="Phone or email"
/>
</div>
{error && <p className="text-sm text-red-600">{error}</p>}
<Button type="submit" className="w-full" disabled={loading}>
{loading ? 'Saving…' : 'Get started'}
</Button>
</form>
</CardContent>
</Card>
</div>
);
}

View File

@@ -0,0 +1,73 @@
import { useState } from 'react';
import { Button } from '../ui/button';
import { Card, CardContent } from '../ui/card';
import { sendVerificationEmail, signOut } from '../../lib/auth-client';
import { Mail } from 'lucide-react';
const logo = '/logo.png';
interface Props {
email: string;
}
export function EmailVerification({ email }: Props) {
const [resent, setResent] = useState(false);
const [loading, setLoading] = useState(false);
async function handleResend() {
setLoading(true);
await sendVerificationEmail({
email,
callbackURL: window.location.origin,
});
setLoading(false);
setResent(true);
}
function handleCheckStatus() {
window.location.reload();
}
return (
<div className="flex h-screen items-center justify-center bg-secondary">
<Card className="w-full max-w-sm">
<CardContent className="p-8 space-y-6 text-center">
<div className="flex justify-center">
<img src={logo} alt="LabWise" className="h-12" />
</div>
<div className="flex justify-center">
<div className="rounded-full bg-accent p-4">
<Mail className="h-8 w-8 text-primary" />
</div>
</div>
<div className="space-y-2">
<h2 className="font-semibold text-lg">Check your email</h2>
<p className="text-sm text-muted-foreground">
We sent a verification link to <span className="font-medium text-foreground">{email}</span>.
Click the link to activate your account.
</p>
</div>
<div className="space-y-2">
<Button className="w-full" onClick={handleCheckStatus}>
I've verified — continue
</Button>
<Button
variant="outline"
className="w-full"
onClick={handleResend}
disabled={loading || resent}
>
{resent ? 'Email sent!' : loading ? 'Sending' : 'Resend email'}
</Button>
</div>
<button
onClick={() => signOut()}
className="text-xs text-muted-foreground hover:text-foreground transition-colors"
>
Use a different account
</button>
</CardContent>
</Card>
</div>
);
}

View File

@@ -0,0 +1,93 @@
import { useState } from 'react';
import { Button } from '../ui/button';
import { Card, CardContent } from '../ui/card';
import { Input } from '../ui/input';
import { Label } from '../ui/label';
import { forgetPassword } from '../../lib/auth-client';
import { ArrowLeft } from 'lucide-react';
const logo = '/logo.png';
interface Props {
onBack: () => void;
}
export function ForgotPassword({ onBack }: Props) {
const [email, setEmail] = useState('');
const [sent, setSent] = useState(false);
const [loading, setLoading] = useState(false);
const [error, setError] = useState('');
async function handleSubmit(e: React.FormEvent) {
e.preventDefault();
setError('');
setLoading(true);
const res = await forgetPassword({
email,
redirectTo: `${window.location.origin}/reset-password`,
});
setLoading(false);
if (res.error) {
setError(res.error.message || 'Something went wrong');
} else {
setSent(true);
}
}
return (
<div className="flex h-screen items-center justify-center bg-secondary">
<Card className="w-full max-w-sm">
<CardContent className="p-8 space-y-6">
<div className="flex justify-center">
<img src={logo} alt="LabWise" className="h-12" />
</div>
{sent ? (
<div className="space-y-4 text-center">
<h2 className="font-semibold text-lg">Check your email</h2>
<p className="text-sm text-muted-foreground">
If an account exists for <span className="font-medium text-foreground">{email}</span>,
we've sent a password reset link.
</p>
<Button variant="outline" className="w-full" onClick={onBack}>
Back to sign in
</Button>
</div>
) : (
<>
<div className="space-y-1">
<h2 className="font-semibold text-lg">Forgot password?</h2>
<p className="text-sm text-muted-foreground">
Enter your email and we'll send you a reset link.
</p>
</div>
<form onSubmit={handleSubmit} className="space-y-4">
<div className="space-y-1">
<Label htmlFor="email">Email</Label>
<Input
id="email"
type="email"
value={email}
onChange={e => setEmail(e.target.value)}
required
autoComplete="email"
/>
</div>
{error && <p className="text-sm text-red-600">{error}</p>}
<Button type="submit" className="w-full" disabled={loading}>
{loading ? 'Sending…' : 'Send reset link'}
</Button>
</form>
<button
onClick={onBack}
className="flex items-center gap-1 text-sm text-muted-foreground hover:text-foreground transition-colors"
>
<ArrowLeft className="h-3 w-3" /> Back to sign in
</button>
</>
)}
</CardContent>
</Card>
</div>
);
}

View File

@@ -0,0 +1,261 @@
import { useRef, useState } from 'react';
import { Button } from '../ui/button';
import { Card, CardContent } from '../ui/card';
import { Input } from '../ui/input';
import { Label } from '../ui/label';
import { signIn } from '../../lib/auth-client';
import {
Package,
FileCheck,
MessageSquare,
Camera,
AlertTriangle,
ChevronDown,
} from 'lucide-react';
const logo = '/logo.png';
interface Props {
onSignUp: () => void;
onForgotPassword: () => void;
}
const features = [
{
icon: Package,
title: 'Smart Chemical Inventory',
description:
'Track every chemical in your lab with detailed records — storage locations, CAS numbers, container counts, and expiration dates. Get instant alerts before stock runs low or chemicals expire.',
},
{
icon: FileCheck,
title: 'AI Protocol Checker',
description:
'Paste or upload any lab protocol and receive instant AI-powered safety feedback with citations to OSHA standards. Catch PPE gaps, ventilation requirements, and hazard oversights before they become incidents.',
},
{
icon: MessageSquare,
title: 'Lab Safety Assistant',
description:
'Ask anything about chemical handling, disposal, compatibility, or regulatory compliance. Get sourced answers drawn from OSHA, EPA, and lab safety literature — available the moment you need them.',
},
{
icon: Camera,
title: 'Photo Label Scanning',
description:
'Point your camera at any chemical label and LabWise auto-fills the inventory entry for you. Reduce manual entry errors and get new chemicals logged in seconds.',
},
];
export function LoginForm({ onSignUp, onForgotPassword }: Props) {
const [email, setEmail] = useState('');
const [password, setPassword] = useState('');
const [error, setError] = useState('');
const [loading, setLoading] = useState(false);
const aboutRef = useRef<HTMLElement>(null);
const heroRef = useRef<HTMLElement>(null);
async function handleSubmit(e: React.FormEvent) {
e.preventDefault();
setError('');
setLoading(true);
const res = await signIn.email({
email,
password,
callbackURL: window.location.origin,
});
setLoading(false);
if (res.error) {
setError(res.error.message || 'Invalid email or password');
}
}
async function handleGoogle() {
await signIn.social({ provider: 'google', callbackURL: window.location.origin });
}
function scrollToAbout() {
aboutRef.current?.scrollIntoView({ behavior: 'smooth' });
}
function scrollToLogin() {
heroRef.current?.scrollIntoView({ behavior: 'smooth' });
}
return (
<div className="min-h-screen bg-secondary">
{/* Sticky Navbar */}
<nav className="sticky top-0 z-50 bg-card border-b border-border">
<div className="max-w-6xl mx-auto px-6 h-14 flex items-center justify-between">
<img src={logo} alt="LabWise" className="h-7" />
<div className="flex items-center gap-2">
<Button variant="ghost" size="sm" onClick={scrollToAbout}>
About
</Button>
<Button variant="outline" size="sm" onClick={scrollToLogin}>
Login
</Button>
</div>
</div>
</nav>
{/* Hero — login card */}
<section
ref={heroRef}
className="min-h-[calc(100vh-3.5rem)] flex flex-col items-center justify-center px-4 py-16"
>
<div className="text-center mb-8">
<p className="text-muted-foreground text-sm tracking-wide uppercase font-medium">
AI-powered lab management
</p>
<h1 className="text-3xl font-bold text-foreground mt-1">
Your lab, under control.
</h1>
</div>
<Card className="w-full max-w-sm">
<CardContent className="p-8 space-y-6">
<div className="flex justify-center">
<img src={logo} alt="LabWise" className="h-12" />
</div>
<p className="text-center text-muted-foreground text-sm">
Sign in to access your lab inventory and protocols.
</p>
<form onSubmit={handleSubmit} className="space-y-4">
<div className="space-y-1">
<Label htmlFor="email">Email</Label>
<Input
id="email"
type="email"
value={email}
onChange={e => setEmail(e.target.value)}
required
autoComplete="email"
/>
</div>
<div className="space-y-1">
<Label htmlFor="password">Password</Label>
<Input
id="password"
type="password"
value={password}
onChange={e => setPassword(e.target.value)}
required
autoComplete="current-password"
/>
</div>
{error && <p className="text-sm text-red-600">{error}</p>}
<Button type="submit" className="w-full" disabled={loading}>
{loading ? 'Signing in…' : 'Sign in'}
</Button>
</form>
<div className="flex items-center gap-3">
<div className="flex-1 border-t border-border" />
<span className="text-xs text-muted-foreground">or</span>
<div className="flex-1 border-t border-border" />
</div>
<Button
variant="outline"
className="w-full flex items-center gap-3"
onClick={handleGoogle}
>
<svg viewBox="0 0 24 24" className="h-4 w-4" xmlns="http://www.w3.org/2000/svg">
<path d="M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z" fill="#4285F4"/>
<path d="M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z" fill="#34A853"/>
<path d="M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l3.66-2.84z" fill="#FBBC05"/>
<path d="M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z" fill="#EA4335"/>
</svg>
Sign in with Google
</Button>
<div className="flex justify-between text-sm">
<button
onClick={onForgotPassword}
className="text-muted-foreground hover:text-foreground transition-colors"
>
Forgot password?
</button>
<button
onClick={onSignUp}
className="text-primary hover:underline font-medium"
>
Create account
</button>
</div>
</CardContent>
</Card>
{/* Scroll hint */}
<button
onClick={scrollToAbout}
className="mt-12 flex flex-col items-center gap-1 text-muted-foreground hover:text-foreground transition-colors group"
>
<span className="text-xs tracking-wide">Learn more</span>
<ChevronDown className="h-4 w-4 animate-bounce group-hover:text-primary" />
</button>
</section>
{/* About Section */}
<section ref={aboutRef} id="about" className="bg-card border-t border-border">
<div className="max-w-5xl mx-auto px-6 py-20">
{/* Intro */}
<div className="text-center mb-16">
<div className="inline-flex items-center gap-2 bg-accent text-primary text-xs font-medium px-3 py-1 rounded-full mb-4">
<AlertTriangle className="h-3 w-3" />
Built for research labs
</div>
<h2 className="text-3xl font-bold text-foreground mb-4">
Lab management, made easy.
</h2>
<p className="text-muted-foreground max-w-2xl mx-auto leading-relaxed">
LabWise brings together chemical inventory tracking, AI-powered protocol review, and real-time
safety alerts in one place so your team spends less time on paperwork and more time on research.
Whether you're managing a single lab or multiple rooms across a department, LabWise keeps
everything organized, compliant, and accessible.
</p>
</div>
{/* Feature grid */}
<div className="grid grid-cols-1 md:grid-cols-2 gap-6 mb-16">
{features.map(({ icon: Icon, title, description }) => (
<div
key={title}
className="flex gap-4 p-6 rounded-xl border border-border bg-secondary hover:shadow-md transition-shadow"
>
<div className="shrink-0 p-3 bg-accent rounded-lg h-fit">
<Icon className="h-5 w-5 text-primary" />
</div>
<div>
<h3 className="font-semibold text-foreground mb-1">{title}</h3>
<p className="text-sm text-muted-foreground leading-relaxed">{description}</p>
</div>
</div>
))}
</div>
{/* CTA */}
<div className="text-center space-y-4">
<h3 className="text-xl font-semibold text-foreground">Ready to get started?</h3>
<div className="flex items-center justify-center gap-3">
<Button onClick={scrollToLogin}>Sign in</Button>
<Button variant="outline" onClick={onSignUp}>
Create account
</Button>
</div>
</div>
</div>
{/* Footer */}
<div className="border-t border-border">
<div className="max-w-5xl mx-auto px-6 py-6 flex items-center justify-between text-xs text-muted-foreground">
<span>© {new Date().getFullYear()} LabWise</span>
<span>Built for research labs</span>
</div>
</div>
</section>
</div>
);
}

View File

@@ -0,0 +1,98 @@
import { useState } from 'react';
import { Button } from '../ui/button';
import { Card, CardContent } from '../ui/card';
import { Input } from '../ui/input';
import { Label } from '../ui/label';
import { resetPassword } from '../../lib/auth-client';
const logo = '/logo.png';
interface Props {
onSuccess: () => void;
}
export function ResetPassword({ onSuccess }: Props) {
const token = new URLSearchParams(window.location.search).get('token') || '';
const [password, setPassword] = useState('');
const [confirm, setConfirm] = useState('');
const [error, setError] = useState('');
const [loading, setLoading] = useState(false);
const [done, setDone] = useState(false);
async function handleSubmit(e: React.FormEvent) {
e.preventDefault();
setError('');
if (password.length < 8) {
setError('Password must be at least 8 characters');
return;
}
if (password !== confirm) {
setError('Passwords do not match');
return;
}
setLoading(true);
const res = await resetPassword({ newPassword: password, token });
setLoading(false);
if (res.error) {
setError(res.error.message || 'Failed to reset password. The link may have expired.');
} else {
setDone(true);
setTimeout(onSuccess, 2000);
}
}
return (
<div className="flex h-screen items-center justify-center bg-secondary">
<Card className="w-full max-w-sm">
<CardContent className="p-8 space-y-6">
<div className="flex justify-center">
<img src={logo} alt="LabWise" className="h-12" />
</div>
{done ? (
<div className="text-center space-y-2">
<h2 className="font-semibold text-lg">Password reset!</h2>
<p className="text-sm text-muted-foreground">Redirecting you to sign in</p>
</div>
) : (
<>
<div className="space-y-1">
<h2 className="font-semibold text-lg">Set new password</h2>
<p className="text-sm text-muted-foreground">Choose a new password for your account.</p>
</div>
<form onSubmit={handleSubmit} className="space-y-4">
<div className="space-y-1">
<Label htmlFor="password">New password</Label>
<Input
id="password"
type="password"
value={password}
onChange={e => setPassword(e.target.value)}
required
autoComplete="new-password"
placeholder="Min. 8 characters"
/>
</div>
<div className="space-y-1">
<Label htmlFor="confirm">Confirm password</Label>
<Input
id="confirm"
type="password"
value={confirm}
onChange={e => setConfirm(e.target.value)}
required
autoComplete="new-password"
/>
</div>
{error && <p className="text-sm text-red-600">{error}</p>}
<Button type="submit" className="w-full" disabled={loading}>
{loading ? 'Resetting…' : 'Reset password'}
</Button>
</form>
</>
)}
</CardContent>
</Card>
</div>
);
}

View File

@@ -0,0 +1,122 @@
import { useState } from 'react';
import { Button } from '../ui/button';
import { Card, CardContent } from '../ui/card';
import { Input } from '../ui/input';
import { Label } from '../ui/label';
import { signUp } from '../../lib/auth-client';
const logo = '/logo.png';
interface Props {
onLogin: () => void;
onVerify: () => void;
}
export function SignUpForm({ onLogin, onVerify }: Props) {
const [name, setName] = useState('');
const [email, setEmail] = useState('');
const [password, setPassword] = useState('');
const [confirm, setConfirm] = useState('');
const [error, setError] = useState('');
const [loading, setLoading] = useState(false);
async function handleSubmit(e: React.FormEvent) {
e.preventDefault();
setError('');
if (password.length < 8) {
setError('Password must be at least 8 characters');
return;
}
if (password !== confirm) {
setError('Passwords do not match');
return;
}
setLoading(true);
const res = await signUp.email({
name,
email,
password,
callbackURL: window.location.origin,
});
setLoading(false);
if (res.error) {
setError(res.error.message || 'Failed to create account');
} else {
onVerify();
}
}
return (
<div className="flex h-screen items-center justify-center bg-secondary">
<Card className="w-full max-w-sm">
<CardContent className="p-8 space-y-6">
<div className="flex justify-center">
<img src={logo} alt="LabWise" className="h-12" />
</div>
<p className="text-center text-muted-foreground text-sm">
Create your LabWise account.
</p>
<form onSubmit={handleSubmit} className="space-y-4">
<div className="space-y-1">
<Label htmlFor="name">Full name</Label>
<Input
id="name"
type="text"
value={name}
onChange={e => setName(e.target.value)}
required
autoComplete="name"
/>
</div>
<div className="space-y-1">
<Label htmlFor="email">Email</Label>
<Input
id="email"
type="email"
value={email}
onChange={e => setEmail(e.target.value)}
required
autoComplete="email"
/>
</div>
<div className="space-y-1">
<Label htmlFor="password">Password</Label>
<Input
id="password"
type="password"
value={password}
onChange={e => setPassword(e.target.value)}
required
autoComplete="new-password"
placeholder="Min. 8 characters"
/>
</div>
<div className="space-y-1">
<Label htmlFor="confirm">Confirm password</Label>
<Input
id="confirm"
type="password"
value={confirm}
onChange={e => setConfirm(e.target.value)}
required
autoComplete="new-password"
/>
</div>
{error && <p className="text-sm text-red-600">{error}</p>}
<Button type="submit" className="w-full" disabled={loading}>
{loading ? 'Creating account…' : 'Create account'}
</Button>
</form>
<p className="text-center text-sm text-muted-foreground">
Already have an account?{' '}
<button onClick={onLogin} className="text-primary hover:underline font-medium">
Sign in
</button>
</p>
</CardContent>
</Card>
</div>
);
}