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 { toggleItem } from '@/lib/actions'
|
||||
import { CheckCircle2, Circle } from 'lucide-react'
|
||||
import { useToast } from './ToastContainer'
|
||||
|
||||
interface ToggleItemButtonProps {
|
||||
itemId: string
|
||||
@@ -11,6 +12,7 @@ interface ToggleItemButtonProps {
|
||||
}
|
||||
|
||||
export default function ToggleItemButton({ itemId, completed, variant = 'full' }: ToggleItemButtonProps) {
|
||||
const { showToast } = useToast()
|
||||
const [isToggling, setIsToggling] = useState(false)
|
||||
|
||||
const handleToggle = async (e: React.MouseEvent) => {
|
||||
@@ -19,8 +21,10 @@ export default function ToggleItemButton({ itemId, completed, variant = 'full' }
|
||||
setIsToggling(true)
|
||||
try {
|
||||
await toggleItem(itemId)
|
||||
showToast(completed ? 'Task marked incomplete' : 'Task completed', 'success')
|
||||
} catch (error) {
|
||||
console.error('Error toggling item:', error)
|
||||
showToast('Failed to update task', 'error')
|
||||
} finally {
|
||||
setIsToggling(false)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user