Skip to content

Commit

Permalink
✨ Feat: month, chart 컴포넌트 연결
Browse files Browse the repository at this point in the history
  • Loading branch information
alwn8918 committed Sep 17, 2024
1 parent 8709298 commit d86e34f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
10 changes: 7 additions & 3 deletions acoountbook/src/components/home/month/Month.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,22 @@ import { useState } from "react";
import * as M from "./Month.style";
import MonthItem from "./MonthItem";

export default function Month() {
const months = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];
export default function Month({ months, onMonthSelect }) {
const [selected, setSelected] = useState();

const handleClick = (month) => {
setSelected(month);
onMonthSelect(month);
};

return (
<M.Container>
{months.map((month) => (
<MonthItem
key={month}
month={month.toString()}
isSelected={selected === month}
onClick={() => setSelected(month)}
onClick={() => handleClick(month)}
/>
))}
</M.Container>
Expand Down
12 changes: 10 additions & 2 deletions acoountbook/src/pages/Home.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,21 @@ import Menu from "../components/home/menu/Menu";
import Month from "../components/home/month/Month";
import Chart from "../components/home/chart/Chart";
import Content from "../components/home/content/Content";
import { useState } from "react";

export default function Home() {
const months = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];
const [selectedMonth, setSelectedMonth] = useState();

const handleMonthSelect = (month) => {
setSelectedMonth(month);
};

return (
<H.Container>
<Menu />
<Month />
<Chart />
<Month months={months} onMonthSelect={handleMonthSelect} />
<Chart month={selectedMonth} total={0} />
<Content />
</H.Container>
);
Expand Down

0 comments on commit d86e34f

Please sign in to comment.