Monthly.js 899 Bytes
Newer Older
1
import React, { useState, useEffect } from 'react';
Choi Ga Young's avatar
Choi Ga Young committed
2
import Calendar from './components/Calendar';
Choi Ga Young's avatar
Choi Ga Young committed
3
import calApi from './db/calendarInfo.api';
Choi Ga Young's avatar
Choi Ga Young committed
4

Choi Ga Young's avatar
Choi Ga Young committed
5
const Montly = ({ navigation }) => {
6
7
8
9
10
11
12
  const date = new Date();
  const [year, setYear] = useState(date.getFullYear());
  const [month, setMonth] = useState(date.getMonth());
  const todayM = date.getMonth();
  const todayY = date.getFullYear();
  const [totalM, setTotalM] = useState([]);

Choi Ga Young's avatar
Choi Ga Young committed
13
14
  const getData = async () => {
    try {
15
16
      const resDBdata = await calApi.getFullData({ year: year, month: month })
      setTotalM(resDBdata)
Choi Ga Young's avatar
Choi Ga Young committed
17
18
19
20
21
22
    } catch (error) {
      console.log('error in getData', error)
    }
  }
  useEffect(() => {
    getData()
23
  }, [month])
Choi Ga Young's avatar
Choi Ga Young committed
24
  return (
25
    <Calendar navigation={navigation} MData={totalM} year={year} setYear={setYear} month={month} setMonth={setMonth} todayM={todayM} todayY={todayY} />
Choi Ga Young's avatar
Choi Ga Young committed
26
27
  )
}
Choi Ga Young's avatar
Choi Ga Young committed
28

Choi Ga Young's avatar
Choi Ga Young committed
29
export default Montly;