* refactor: adopt shared Input/Textarea components across 15 files Replace 42 raw <input>/<textarea> elements with <Input>/<Textarea> from components/ui/. Consistent focus states, error handling, and styling across all form fields. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * refactor: replace hardcoded rgba/hex colors with Tailwind tokens - rgba(255,255,255,0.xx) → bg-white/[0.xx], border-white/[0.xx] - rgba(6,182,212,0.3) → border-primary/30 (focus states) - #0a0a0a → bg-background - Inline style hex colors → var(--color-primary), var(--color-brand-gradient-to) - 28 files updated, zero hardcoded rgba() patterns remaining Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * feat: add PageMeta to 16 pages for SEO and proper browser tab titles Public pages (Login, Register, Forgot/Reset Password, Verify Email, Survey Thank You) get descriptions for SEO. Authenticated pages (Dashboard, Flow Library, My Flows, Session History, AI Assistant, Account Settings, Step Library, My Shares, Feedback, Guides) get proper tab titles. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * feat: add page transitions and staggered list animations - ViewTransitionOutlet: wraps Outlet with fade-in-up animation keyed to route path. Sidebar/topbar stay still, only content area animates. - StaggerList: reusable component that cascades children with incremental delay (50ms default). Pure CSS via @utility stagger-item. - Applied stagger to TreeGridView, MyTreesPage cards, SessionHistoryPage. - New stagger-fade-in keyframe in @theme block. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: ViewTransitionOutlet needs h-full for React Flow canvas The wrapper div broke the height chain needed by TreeEditorPage's h-full layout, causing React Flow canvas to collapse to zero height. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: main-content flex layout for tree editor + scrollable pages Main content area is now flex-col so the ViewTransitionOutlet wrapper gets an explicit computed height via flex-1 min-h-0. This makes h-full resolve correctly in the tree editor (React Flow canvas) while still allowing overflow-y-auto scrolling for normal pages. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: resolve ESLint errors in Button and Skeleton components - Button: suppress react-refresh/only-export-components for buttonVariants re-export - Skeleton: replace empty interface with type alias, replace Math.random() with static widths array Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * feat: add PageMeta, animation classes, and layout fixes to remaining pages Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
141 lines
3.7 KiB
TypeScript
141 lines
3.7 KiB
TypeScript
import { useState } from 'react'
|
|
import type { StepCategoryListItem } from '@/types'
|
|
import { Modal } from '@/components/common/Modal'
|
|
import { Button } from '@/components/ui/Button'
|
|
import { Input } from '@/components/ui/Input'
|
|
import { Textarea } from '@/components/ui/Textarea'
|
|
|
|
interface EditCategoryModalProps {
|
|
isOpen: boolean
|
|
onClose: () => void
|
|
onSubmit: (data: { name: string; description: string }) => Promise<void>
|
|
category: StepCategoryListItem | null
|
|
isSaving?: boolean
|
|
}
|
|
|
|
export function EditCategoryModal({
|
|
isOpen,
|
|
onClose,
|
|
onSubmit,
|
|
category,
|
|
isSaving = false
|
|
}: EditCategoryModalProps) {
|
|
const [name, setName] = useState('')
|
|
const [description, setDescription] = useState('')
|
|
const [error, setError] = useState('')
|
|
const [prevCategoryId, setPrevCategoryId] = useState<string | null>(null)
|
|
|
|
// Pre-populate form when category changes (state-based tracking)
|
|
if (category && category.id !== prevCategoryId) {
|
|
setPrevCategoryId(category.id)
|
|
setName(category.name)
|
|
setDescription(category.description || '')
|
|
}
|
|
if (!category && prevCategoryId !== null) {
|
|
setPrevCategoryId(null)
|
|
}
|
|
|
|
if (!category) return null
|
|
|
|
const handleSubmit = async (e: React.FormEvent) => {
|
|
e.preventDefault()
|
|
setError('')
|
|
|
|
if (!name.trim()) {
|
|
setError('Category name is required')
|
|
return
|
|
}
|
|
|
|
if (name.length > 100) {
|
|
setError('Category name must be 100 characters or less')
|
|
return
|
|
}
|
|
|
|
try {
|
|
await onSubmit({
|
|
name: name.trim(),
|
|
description: description.trim()
|
|
})
|
|
} catch {
|
|
setError('Failed to update category')
|
|
}
|
|
}
|
|
|
|
const handleClose = () => {
|
|
if (!isSaving) {
|
|
setError('')
|
|
onClose()
|
|
}
|
|
}
|
|
|
|
return (
|
|
<Modal
|
|
isOpen={isOpen}
|
|
onClose={handleClose}
|
|
title="Edit Category"
|
|
size="sm"
|
|
footer={
|
|
<div className="flex justify-end gap-2">
|
|
<Button
|
|
type="button"
|
|
variant="secondary"
|
|
onClick={handleClose}
|
|
disabled={isSaving}
|
|
>
|
|
Cancel
|
|
</Button>
|
|
<Button
|
|
type="submit"
|
|
form="edit-category-form"
|
|
disabled={!name.trim()}
|
|
loading={isSaving}
|
|
>
|
|
Save Changes
|
|
</Button>
|
|
</div>
|
|
}
|
|
>
|
|
<form id="edit-category-form" onSubmit={handleSubmit} className="space-y-4">
|
|
{error && (
|
|
<div className="rounded-md bg-red-400/10 p-3 text-sm text-red-400">
|
|
{error}
|
|
</div>
|
|
)}
|
|
|
|
<div>
|
|
<label htmlFor="edit-name" className="mb-1 block text-sm font-medium text-foreground">
|
|
Category Name <span className="text-red-400">*</span>
|
|
</label>
|
|
<Input
|
|
id="edit-name"
|
|
type="text"
|
|
value={name}
|
|
onChange={(e) => setName(e.target.value)}
|
|
disabled={isSaving}
|
|
maxLength={100}
|
|
placeholder="e.g., Network Troubleshooting"
|
|
required
|
|
/>
|
|
<p className="mt-1 text-xs text-muted-foreground">
|
|
{name.length}/100 characters
|
|
</p>
|
|
</div>
|
|
|
|
<div>
|
|
<label htmlFor="edit-description" className="mb-1 block text-sm font-medium text-foreground">
|
|
Description <span className="text-muted-foreground">(optional)</span>
|
|
</label>
|
|
<Textarea
|
|
id="edit-description"
|
|
value={description}
|
|
onChange={(e) => setDescription(e.target.value)}
|
|
disabled={isSaving}
|
|
rows={3}
|
|
placeholder="Brief description of this category..."
|
|
/>
|
|
</div>
|
|
</form>
|
|
</Modal>
|
|
)
|
|
}
|