Schedule.js 2.69 KB
Newer Older
Kim, Subin's avatar
Kim, Subin committed
1
import React, { useState, useEffect, useRef } from 'react';
Lee Jin Ju's avatar
Lee Jin Ju committed
2
3
4
5
import Calendar from '@toast-ui/react-calendar';
import "tui-calendar/dist/tui-calendar.css";
import "tui-date-picker/dist/tui-date-picker.css";
import "tui-time-picker/dist/tui-time-picker.css";
6
  
Kim, Subin's avatar
Kim, Subin committed
7
8
9
function Cal(calledday) {
  const calendarRef = useRef();
  const [day, setDay] = useState(calledday + "15:00:00");
Lee Jin Ju's avatar
Lee Jin Ju committed
10
11
12
  const [myTheme, setMyTheme] = useState({
    'common.dayname.color': '#333',
    'common.today.color': '#333',
Kim, Subin's avatar
Kim, Subin committed
13
14
15
    // 'common.creationGuide.color': 'white',
    'common.creationGuide.backgroundColor': 'gray',
    // Theme object to extends default dark theme.
Lee Jin Ju's avatar
Lee Jin Ju committed
16
17
  });

Kim, Subin's avatar
Kim, Subin committed
18
  useEffect(() => {
Lee Jin Ju's avatar
오앙    
Lee Jin Ju committed
19
20
21
    // const cal = calendarRef.current.getInstance();
    // cal.setDate(new Date(day));
    // cal.changeView('week', false);
Kim, Subin's avatar
Kim, Subin committed
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
    // cal.today(new Date(day));

    // calendar.on('clickSchedule', function (event) {
    //   const schedule = event.schedule;

    //   if (lastClickSchedule) {
    //     calendar.updateSchedule(lastClickSchedule.id, lastClickSchedule.calendarId, {
    //       isFocused: false,
    //     });
    //   }
    //   calendar.updateSchedule(schedule.id, schedule.calendarId, {
    //     isFocused: true,
    //   });

    //   lastClickSchedule = schedule;
    //   // open detail view

    //   return (console.log(isFocused))
    // });

  }, [day])
Lee Jin Ju's avatar
Lee Jin Ju committed
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59

  return (
    <Calendar
      height="100%"
      calendars={[
        {
          id: 'Subject',
          bgColor: '#a9a9a9',
          borderColor: '#a9a9a9',
          isReadOnly: 'true'
        }
      ]}
      
      view="week"
      disableDblClick={false}
      disableClick={true}
      isReadOnly={false}
60
            // template={
Kim, Subin's avatar
Kim, Subin committed
61
62
63
64
      //   popupIsAllDay=function {
      //     return display: "none"
      //   }
      // }
Lee Jin Ju's avatar
Lee Jin Ju committed
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
      schedules={[
        {
          id: '1',
          calendarId: 'Subject',
          category: 'time',
          start: '2020-10-05T11:00:00',
          end: '2020-10-05T12:00:00',
        },
        {
          id: '2',
          calendarId: 'Subject',
          category: 'time',
          start: '2020-10-09T10:00:00',
          end: '2020-10-09T11:00:00',
        },
        {
          id: '3',
          calendarId: 'Subject',
          category: 'time',
          start: '2020-10-08T11:00:00',
          end: '2020-10-08T15:00:00',
        }
      ]}

      scheduleView={['time']}
      taskView={false}
      theme={myTheme}
      timezones={[
        {
          timezoneOffset: 540,
          displayLabel: 'GMT+09:00',
          tooltip: 'Seoul'
        },
      ]}
      useDetailPopup
      useCreationPopup
Kim, Subin's avatar
Kim, Subin committed
101
      view={"week"}
Lee Jin Ju's avatar
Lee Jin Ju committed
102
      week={{
Kim, Subin's avatar
Kim, Subin committed
103
        workweek: true,
Lee Jin Ju's avatar
Lee Jin Ju committed
104
        hourStart: 8,
Kim, Subin's avatar
Kim, Subin committed
105
        hourEnd: 23
Lee Jin Ju's avatar
Lee Jin Ju committed
106
107
108
109
110
111
      }}
    />
  )
}

export default Cal