|
| 1 | +'use client'; |
| 2 | + |
| 3 | +import { useState } from 'react'; |
| 4 | +import Card from './Card'; |
| 5 | +import CheckList, { ChecklistItem } from './CheckList'; |
| 6 | + |
| 7 | +interface BottomSectionProps { |
| 8 | + className?: string; |
| 9 | +} |
| 10 | + |
| 11 | +const TODAY_DUMMY = [ |
| 12 | + { id: 't1', text: 'React Hooks 정리', checked: false }, |
| 13 | + { id: 't2', text: 'GSAP ScrollTrigger 복습', checked: true }, |
| 14 | + { id: 't3', text: '알고리즘 1문제 풀기', checked: false }, |
| 15 | +]; |
| 16 | + |
| 17 | +const UPCOMING_DUMMY = [ |
| 18 | + { id: 'u1', text: 'Next.js App Router 정리', checked: false }, |
| 19 | + { id: 'u2', text: '포트폴리오 리팩토링', checked: false }, |
| 20 | +]; |
| 21 | + |
| 22 | +export default function BottomSection({ className }: BottomSectionProps) { |
| 23 | + const [today, setToday] = useState<ChecklistItem[]>(TODAY_DUMMY); |
| 24 | + const [upcoming, setUpcoming] = useState<ChecklistItem[]>(UPCOMING_DUMMY); |
| 25 | + |
| 26 | + const toggleToday = (id: string) => { |
| 27 | + setToday((prev) => |
| 28 | + prev.map((it) => (it.id === id ? { ...it, checked: !it.checked } : it)) |
| 29 | + ); |
| 30 | + }; |
| 31 | + |
| 32 | + const toggleUpcoming = (id: string) => { |
| 33 | + setUpcoming((prev) => |
| 34 | + prev.map((it) => (it.id === id ? { ...it, checked: !it.checked } : it)) |
| 35 | + ); |
| 36 | + }; |
| 37 | + |
| 38 | + return ( |
| 39 | + <div className={className}> |
| 40 | + <Card title="오늘 할 일"> |
| 41 | + <CheckList |
| 42 | + items={today} |
| 43 | + onToggle={toggleToday} |
| 44 | + emptyText="오늘 할 일이 없습니다" |
| 45 | + /> |
| 46 | + </Card> |
| 47 | + |
| 48 | + <Card title="다가오는 일정"> |
| 49 | + <CheckList |
| 50 | + items={upcoming} |
| 51 | + onToggle={toggleUpcoming} |
| 52 | + emptyText="다가오는 일정이 없습니다" |
| 53 | + /> |
| 54 | + </Card> |
| 55 | + </div> |
| 56 | + ); |
| 57 | +} |
0 commit comments