feat: Add visual feedback and polish (Task 15)
- Implement toast notification system for success/error messages - Add loading states with skeleton loaders for async operations - Create smooth CSS transitions and animations - Enhance empty states with EmptyState component - Add loading.tsx files for Next.js loading states - Integrate toast notifications across all CRUD operations - Add fade-in and scale-in animations for better UX - Improve visual feedback for user actions
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
import { useState } from 'react'
|
||||
import { useRouter } from 'next/navigation'
|
||||
import { updateItem, createItem } from '@/lib/actions'
|
||||
import { useToast } from './ToastContainer'
|
||||
|
||||
interface ItemFormProps {
|
||||
listId: string
|
||||
@@ -20,6 +21,7 @@ interface ItemFormProps {
|
||||
|
||||
export default function ItemForm({ listId, item, mode = 'edit' }: ItemFormProps) {
|
||||
const router = useRouter()
|
||||
const { showToast } = useToast()
|
||||
const [isSubmitting, setIsSubmitting] = useState(false)
|
||||
const [errors, setErrors] = useState<Record<string, string>>({})
|
||||
|
||||
@@ -79,14 +81,17 @@ export default function ItemForm({ listId, item, mode = 'edit' }: ItemFormProps)
|
||||
tags: data.tags,
|
||||
notes: data.notes,
|
||||
})
|
||||
showToast('Task created successfully', 'success')
|
||||
router.push(`/list/${listId}`)
|
||||
} else if (item) {
|
||||
await updateItem(item.id, data)
|
||||
showToast('Task updated successfully', 'success')
|
||||
router.push(`/list/${listId}/item/${item.id}`)
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error saving item:', error)
|
||||
setErrors({ submit: 'Failed to save item. Please try again.' })
|
||||
showToast('Failed to save task', 'error')
|
||||
} finally {
|
||||
setIsSubmitting(false)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user