Calendar.js 1.67 KB
Newer Older
Lee Jin Ju's avatar
Lee Jin Ju committed
1
2
3
import React, { useState, useEffect } from 'react';
import Calendar from 'tui-calendar';
import "tui-calendar/dist/tui-calendar.css";
Lee Jin Ju's avatar
.    
Lee Jin Ju committed
4
import styled from 'styled-components';
Lee Jin Ju's avatar
Lee Jin Ju committed
5

Lee Jin Ju's avatar
.    
Lee Jin Ju committed
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
const cal = styled.div`
  position: absolute;
  left: 0;
  right: 0;
  bottom: 5px;
  top: 64px;
`

// const container = document.getElementById('calendar');
const options = {
  defaultView: 'week',
  taskView: false,
  week: {
    workweek: true
  },
  useCreationPopup: true,
  useDetailPopup: true
};

const calendar = new Calendar('#calendar', options);

calendar.setCalendars([
  {
    id: 'Major Subject',
    name: '전공 필수',
    color: '#ffffff',
    bgColor: '#ff5583',
    dragBgColor: '#ff5583',
    borderColor: '#ff5583'
  },
  {
    id: 'Elective Subject',
    name: '전공 선택',
    color: '#ffffff',
    bgColor: '#ffbb3b',
    dragBgColor: '#ffbb3b',
    borderColor: '#ffbb3b'
  },
  {
    id: 'General Subject',
    name: '일반 교양',
    color: '#ffffff',
    bgColor: '#03bd9e',
    dragBgColor: '#03bd9e',
    borderColor: '#03bd9e'
  }
]);

calendar.createSchedules([
  {
    id: '1',
    calendarId: 'Major Subject',
    title: '자료구조론',
    category: 'time',             
    start: '2020-10-05T11:00:00',
    end: '2020-10-05T12:00:00',
    isReadOnly : true
  },
  {
    id: '2',
    calendarId: 'Elective Subject',
    title: '웹 프로그래밍',
    category: 'allday',
    start: '2020-10-5T10:00:00',
    end: '2020-10-9T11:00:00',
    isReadOnly : true
  },
  {
    id: '3',
    calendarId: 'General Subject',
    title: '영양과 건강',
    category: 'time',
    start: '2020-10-8T11:00:00',
    end: '2020-10-8T15:00:00',
    isReadOnly : true
  }
]);
Lee Jin Ju's avatar
Lee Jin Ju committed
83
84

export default Calendar