Residential platform - New schema: residentialClients, residentialInterests (separate from marina/yacht clients) with migration 0010 - Service layer with CRUD + audit + sockets + per-port portal toggle - v1 + public API routes (/api/v1/residential/*, /api/public/residential-inquiries) - List + detail pages with inline editing for clients and interests - Per-user residentialAccess toggle on userPortRoles (migration 0011) - Permission keys: residential_clients, residential_interests - Sidebar nav + role form integration - Smoke spec covering page loads, UI create flow, public endpoint Admin & shared UI - Admin → Forms (form templates CRUD) with validators + service - Notification preferences page (in-app + email per type) - Email composition + accounts list + threads view - Branded auth shell shared across CRM + portal auth surfaces - Inline editing extended to yacht/company/interest detail pages - InlineTagEditor + per-entity tags endpoints (yachts, companies) - Notes service polymorphic across clients/interests/yachts/companies - Client list columns: yachtCount + companyCount badges - Reservation file-download via presigned URL (replaces stale <a href>) Route handler refactor - Extracted yachts/companies/berths reservation handlers to sibling handlers.ts files (Next.js 15 route.ts only allows specific exports) Reliability fixes - apiFetch double-stringify bug fixed across 13 components (apiFetch already JSON.stringifies its body; passing a stringified body produced double-encoded JSON which failed zod validation) - SocketProvider gated behind useSyncExternalStore-based mount check to avoid useSession() SSR crashes under React 19 + Next 15 - apiFetch falls back to URL-pathname → port-id resolution when the Zustand store hasn't hydrated yet (fresh contexts, e2e tests) - CRM invite flow (schema, service, route, email, dev script) - Dashboard route → [portSlug]/dashboard/page.tsx + redirect - Document the dev-server restart-after-migration gotcha in CLAUDE.md Tests - 5-case residential smoke spec - Integration test updates for new service signatures Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
104 lines
3.3 KiB
TypeScript
104 lines
3.3 KiB
TypeScript
'use client';
|
|
|
|
import { useState } from 'react';
|
|
import Link from 'next/link';
|
|
import { useForm } from 'react-hook-form';
|
|
import { zodResolver } from '@hookform/resolvers/zod';
|
|
import { z } from 'zod';
|
|
import { toast } from 'sonner';
|
|
import { Button } from '@/components/ui/button';
|
|
import { Input } from '@/components/ui/input';
|
|
import { Label } from '@/components/ui/label';
|
|
import { BrandedAuthShell } from '@/components/shared/branded-auth-shell';
|
|
import { cn } from '@/lib/utils';
|
|
|
|
const resetSchema = z.object({
|
|
email: z.string().email('Please enter a valid email address'),
|
|
});
|
|
|
|
type ResetFormData = z.infer<typeof resetSchema>;
|
|
|
|
export default function ResetPasswordPage() {
|
|
const [submitted, setSubmitted] = useState(false);
|
|
const [isLoading, setIsLoading] = useState(false);
|
|
|
|
const {
|
|
register,
|
|
handleSubmit,
|
|
formState: { errors },
|
|
} = useForm<ResetFormData>({
|
|
resolver: zodResolver(resetSchema),
|
|
});
|
|
|
|
async function onSubmit(data: ResetFormData) {
|
|
setIsLoading(true);
|
|
try {
|
|
// Always show the same success message regardless of whether the email exists.
|
|
await fetch('/api/auth/reset-password', {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({ email: data.email }),
|
|
});
|
|
|
|
setSubmitted(true);
|
|
} catch {
|
|
toast.error('Something went wrong. Please try again.');
|
|
} finally {
|
|
setIsLoading(false);
|
|
}
|
|
}
|
|
|
|
return (
|
|
<BrandedAuthShell>
|
|
<div className="text-center mb-6">
|
|
<h1 className="text-xl font-semibold text-gray-900">Reset your password</h1>
|
|
<p className="text-sm text-gray-500 mt-1">We'll email you a link</p>
|
|
</div>
|
|
|
|
{submitted ? (
|
|
<div className="space-y-4 text-center">
|
|
<p className="font-medium text-gray-900">Check your email</p>
|
|
<p className="text-sm text-gray-500">
|
|
If an account exists for that email address, we have sent a password reset link. Please
|
|
check your inbox and spam folder.
|
|
</p>
|
|
<Link href="/login" className="inline-block text-sm text-[#007bff] hover:underline">
|
|
Back to sign in
|
|
</Link>
|
|
</div>
|
|
) : (
|
|
<form onSubmit={handleSubmit(onSubmit)} className="space-y-4" noValidate>
|
|
<div className="space-y-1.5">
|
|
<Label htmlFor="email">Email</Label>
|
|
<Input
|
|
id="email"
|
|
type="email"
|
|
autoComplete="email"
|
|
placeholder="you@example.com"
|
|
disabled={isLoading}
|
|
className={cn(errors.email && 'border-destructive focus-visible:ring-destructive')}
|
|
{...register('email')}
|
|
/>
|
|
{errors.email && <p className="text-sm text-destructive">{errors.email.message}</p>}
|
|
</div>
|
|
|
|
<Button
|
|
type="submit"
|
|
className="w-full bg-[#007bff] hover:bg-[#0069d9] text-white"
|
|
disabled={isLoading}
|
|
>
|
|
{isLoading ? 'Sending…' : 'Send reset link'}
|
|
</Button>
|
|
|
|
<p className="text-center text-sm text-gray-500">
|
|
Remember your password?{' '}
|
|
<Link href="/login" className="text-[#007bff] hover:underline">
|
|
Sign in
|
|
</Link>
|
|
</p>
|
|
</form>
|
|
)}
|
|
</BrandedAuthShell>
|
|
);
|
|
}
|