* chore: run Tailwind v4 upgrade tool (Phase 1) - Upgraded tailwindcss v3 → v4.2.1, postcss plugin to @tailwindcss/postcss - Deleted tailwind.config.js, migrated theme to CSS @theme block in index.css - Replaced @tailwind directives with @import 'tailwindcss' - Added @custom-variant dark, @utility blocks for custom utilities - Updated class names across 128 files (shadow-sm → shadow-xs, etc.) - Removed autoprefixer (built into v4) - Added migration plan doc Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * chore: switch from @tailwindcss/postcss to @tailwindcss/vite (Phase 2) - Replaced @tailwindcss/postcss with @tailwindcss/vite plugin - Deleted postcss.config.js (no longer needed) - Tailwind now runs as a native Vite plugin for faster HMR Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * refactor: convert to OKLCH colors, move keyframes into @theme (Phase 3-4) - Replaced all HSL color indirection with direct OKLCH values in @theme - Moved all keyframes inside @theme block (v4 pattern) - Eliminated hsl(var(--x)) double-indirection across 17 component files - Replaced hsl() inline styles with var(--color-*) theme references - Cleaned up redundant rdp-* utility blocks - Fixed @custom-variant dark syntax to use :where() - Added sidebar/glass/shadow vars as OKLCH in :root Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
90 lines
2.8 KiB
TypeScript
90 lines
2.8 KiB
TypeScript
import { useState } from 'react'
|
|
import { X } from 'lucide-react'
|
|
import { stepsApi } from '@/api/steps'
|
|
import { StepForm } from './StepForm'
|
|
import type { Step, StepCreate } from '@/types/step'
|
|
|
|
interface StepFormModalProps {
|
|
isOpen: boolean
|
|
onClose: () => void
|
|
onSuccess: (step: Step) => void
|
|
editingStep?: Step | null // full Step (parent fetches before opening), null/undefined = create mode
|
|
}
|
|
|
|
export function StepFormModal({ isOpen, onClose, onSuccess, editingStep }: StepFormModalProps) {
|
|
const [isSubmitting, setIsSubmitting] = useState(false)
|
|
const [error, setError] = useState<string | null>(null)
|
|
|
|
if (!isOpen) return null
|
|
|
|
const isEditMode = !!editingStep
|
|
|
|
const handleSubmit = async (data: StepCreate) => {
|
|
setIsSubmitting(true)
|
|
setError(null)
|
|
try {
|
|
let result: Step
|
|
if (isEditMode && editingStep) {
|
|
result = await stepsApi.update(editingStep.id, data)
|
|
} else {
|
|
result = await stepsApi.create(data)
|
|
}
|
|
onSuccess(result)
|
|
} catch (err) {
|
|
console.error('Failed to save step:', err)
|
|
setError('Failed to save step. Please try again.')
|
|
} finally {
|
|
setIsSubmitting(false)
|
|
}
|
|
}
|
|
|
|
// Build initialData from full Step including content
|
|
const initialData = editingStep ? {
|
|
title: editingStep.title,
|
|
step_type: editingStep.step_type,
|
|
content: editingStep.content,
|
|
visibility: editingStep.visibility,
|
|
category_id: editingStep.category_id,
|
|
tags: editingStep.tags,
|
|
} : undefined
|
|
|
|
return (
|
|
<div className="fixed inset-0 z-50 flex items-center justify-center bg-black/80 backdrop-blur-xs p-4">
|
|
<div className="relative flex h-[90vh] w-full max-w-2xl flex-col bg-card border border-border rounded-2xl shadow-lg">
|
|
{/* Header */}
|
|
<div className="flex items-center justify-between border-b border-border p-6 pb-4">
|
|
<h2 className="text-lg font-semibold text-foreground">
|
|
{isEditMode ? 'Edit Step' : 'Create Step'}
|
|
</h2>
|
|
<button
|
|
onClick={onClose}
|
|
disabled={isSubmitting}
|
|
className="rounded-md p-1.5 text-muted-foreground hover:bg-accent hover:text-foreground disabled:opacity-50"
|
|
aria-label="Close"
|
|
>
|
|
<X className="h-5 w-5" />
|
|
</button>
|
|
</div>
|
|
|
|
{/* Error */}
|
|
{error && (
|
|
<div className="mx-6 mt-4 rounded-lg border border-red-400/20 bg-red-400/10 p-3 text-sm text-red-400">
|
|
{error}
|
|
</div>
|
|
)}
|
|
|
|
{/* Body */}
|
|
<div className="flex-1 overflow-y-auto p-6">
|
|
<StepForm
|
|
onSubmit={handleSubmit}
|
|
onCancel={onClose}
|
|
initialData={initialData}
|
|
submitLabel={isEditMode ? 'Save Changes' : 'Create Step'}
|
|
isSubmitting={isSubmitting}
|
|
/>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|