# 予定をカレンダーに反映させる2

では、`dateList`に格納した`schedules`を表示していきます。

予定はボタン形式で押せるようにしたいので、コンポーネントとして切り出します。

`atoms`配下に`ScheduleBtn.tsx`を作成しましょう。`props`として、`children`を受け取れるようにします。

<pre class="language-tsx" data-title="atoms/ScheduleBtn.tsx◎"><code class="lang-tsx"><strong>import { ReactNode } from "react"
</strong><strong>
</strong><strong>type PropsType = {
</strong><strong>  children: ReactNode
</strong><strong>}
</strong><strong>
</strong><strong>export const ScheduleBtn = ({ children }: PropsType) => {
</strong><strong>  return (
</strong><strong>    &#x3C;button className="block bg-lime-800 text-white rounded-sm w-[94%] px-2">
</strong><strong>      {children}
</strong><strong>    &#x3C;/button>
</strong><strong>  )
</strong><strong>}
</strong>
</code></pre>

では、ScheduleBtnを使用して、予定を表示します。

`item.schedules`に配列の形で格納されているので、mapで表示します。

<pre class="language-tsx" data-title="organisms/CalendarBody.tsx◎"><code class="lang-tsx">import { getDate } from "date-fns";
import { dateColor } from "../../libs/date";
import { DateList } from "../../types/calendar";
import { ScheduleBtn } from "../atoms/ScheduleBtn";

type PropsType = {
  currentDate: Date;
  dateList: DateList
};

export const CalendarBody = ({ currentDate, dateList }: PropsType) => {
  return (
    &#x3C;tbody>
      {dateList.map((oneWeek) => (
        &#x3C;tr key={`week-${getDate(oneWeek[0].date)}`} className="mx-10">
          {oneWeek.map((item) => (
            &#x3C;td
              key={`day-${getDate(oneWeek[0].date)}`}
              className="bg-white h-[10vh] border-2 border-solid border-lime-800"
            >
              &#x3C;span
                className={`inline-block w-[20px] leading-[20px] text-center ${dateColor(
                  item.date,
                  currentDate
                )}`}
              >
                {getDate(item.date)}
              &#x3C;/span>
<strong>              &#x3C;div className="flex flex-col items-center gap-1 pb-2">
</strong><strong>                {item.schedules.map((schedule) => (
</strong><strong>                  &#x3C;ScheduleBtn
</strong><strong>                    key={schedule.id}
</strong><strong>                  >
</strong><strong>                    {schedule.title}
</strong><strong>                  &#x3C;/ScheduleBtn>
</strong><strong>                ))}
</strong><strong>              &#x3C;/div>
</strong>            &#x3C;/td>
          ))}
        &#x3C;/tr>
      ))}
    &#x3C;/tbody>
  );
}

</code></pre>

これでカレンダーに予定が表示されるようになったかと思います。

<figure><img src="https://1869761657-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FcUBbYqol4PMzZJggiMqV%2Fuploads%2FINdldFat5a4Vs5BjNa1K%2Fkka.png?alt=media&#x26;token=b22a365e-deb2-471b-b767-2e2f75ac2c44" alt=""><figcaption></figcaption></figure>

ここまでの作業をcommitしましょう。

```bash
git add .
```

```bash
git commit
```

commitメッセージは

```
feat: 予定をカレンダーに表示するようにした
```

としましょう。
