Monthly.js 935 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
      const resDBdata = await calApi.getFullData({ year: year, month: month })
Choi Ga Young's avatar
Choi Ga Young committed
16
      console.log('db res', totalM)
17
      setTotalM(resDBdata)
Choi Ga Young's avatar
Choi Ga Young committed
18
19
20
21
22
23
    } catch (error) {
      console.log('error in getData', error)
    }
  }
  useEffect(() => {
    getData()
24
  }, [month])
Choi Ga Young's avatar
Choi Ga Young committed
25
  return (
26
    <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
27
28
  )
}
Choi Ga Young's avatar
Choi Ga Young committed
29

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