sapp-common-package-test-final 1.0.9 → 1.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -60,7 +60,6 @@ var useEffectAfterMounted = function useEffectAfterMounted(callback, dependencie
60
60
  }, dependencies);
61
61
  };
62
62
 
63
- var HOURS_PER_DAY = 24;
64
63
  var MINUTES_PER_HOUR = 60;
65
64
  var TIME_FORMAT = 'HH:mm';
66
65
  var DAYS_OF_WEEK;
@@ -73,6 +72,27 @@ var DAYS_OF_WEEK;
73
72
  DAYS_OF_WEEK["Saturday"] = "Saturday";
74
73
  DAYS_OF_WEEK["Sunday"] = "Sunday";
75
74
  })(DAYS_OF_WEEK || (DAYS_OF_WEEK = {}));
75
+ var HOUR_OF_DAY;
76
+ (function (HOUR_OF_DAY) {
77
+ HOUR_OF_DAY["07:00"] = "07:00";
78
+ HOUR_OF_DAY["08:00"] = "08:00";
79
+ HOUR_OF_DAY["09:00"] = "09:00";
80
+ HOUR_OF_DAY["10:00"] = "10:00";
81
+ HOUR_OF_DAY["11:00"] = "11:00";
82
+ HOUR_OF_DAY["12:00"] = "12:00";
83
+ HOUR_OF_DAY["13:00"] = "13:00";
84
+ HOUR_OF_DAY["14:00"] = "14:00";
85
+ HOUR_OF_DAY["15:00"] = "15:00";
86
+ HOUR_OF_DAY["16:00"] = "16:00";
87
+ HOUR_OF_DAY["17:00"] = "17:00";
88
+ HOUR_OF_DAY["18:00"] = "18:00";
89
+ HOUR_OF_DAY["19:00"] = "19:00";
90
+ HOUR_OF_DAY["20:00"] = "20:00";
91
+ HOUR_OF_DAY["21:00"] = "21:00";
92
+ HOUR_OF_DAY["22:00"] = "22:00";
93
+ HOUR_OF_DAY["23:00"] = "23:00";
94
+ HOUR_OF_DAY["24:00"] = "24:00";
95
+ })(HOUR_OF_DAY || (HOUR_OF_DAY = {}));
76
96
  var EVENT_TYPES;
77
97
  (function (EVENT_TYPES) {
78
98
  EVENT_TYPES["TEACHING"] = "TEACHING";
@@ -84,6 +104,16 @@ var FORMAT_DATE_CARLENDA = {
84
104
  MONTH_AND_WEEK: 'MMMM, YYYY',
85
105
  DATE: 'MMMM DD, YYYY'
86
106
  };
107
+ var LEARNING_MODE;
108
+ (function (LEARNING_MODE) {
109
+ LEARNING_MODE["ONLINE"] = "ONLINE";
110
+ LEARNING_MODE["LIVE_ONLINE"] = "LIVE_ONLINE";
111
+ LEARNING_MODE["OFFLINE"] = "OFFLINE";
112
+ LEARNING_MODE["CASE_STUDY"] = "CASE_STUDY";
113
+ LEARNING_MODE["HOLIDAY"] = "HOLIDAY";
114
+ LEARNING_MODE["OVERDUE"] = "OVERDUE";
115
+ LEARNING_MODE["TEST"] = "TEST";
116
+ })(LEARNING_MODE || (LEARNING_MODE = {}));
87
117
 
88
118
  var _convertType;
89
119
  var customDateFormat = function customDateFormat(value, formatStr) {
@@ -91,6 +121,7 @@ var customDateFormat = function customDateFormat(value, formatStr) {
91
121
  };
92
122
  var convertType = (_convertType = {}, _convertType[EVENT_TYPES.TEACHING] = 'info', _convertType[EVENT_TYPES.BUSY] = 'error', _convertType[EVENT_TYPES.TIME_OFF] = 'warning', _convertType[EVENT_TYPES.OTHER] = 'success', _convertType);
93
123
  var daysOfWeekKeys = Object.values(DAYS_OF_WEEK);
124
+ var hoursOfDayKeys = Object.values(HOUR_OF_DAY);
94
125
  var calculateNormOfWeek = function calculateNormOfWeek(norms, events, startDate, endDate) {
95
126
  var norm = norms.find(function (norm) {
96
127
  return startDate.isBetween(norm.startDate, norm.endDate, 'day', '[]') && endDate.isBetween(norm.startDate, norm.endDate, 'day', '[]');
@@ -370,7 +401,7 @@ var HiddenEyeIcon = function HiddenEyeIcon() {
370
401
  }));
371
402
  };
372
403
 
373
- var styles = {"flex":"_2hGgU","transform":"_3-Pu9","cursor-pointer":"_2Mcv6","rounded-none":"_3EfQZ","border-gray-4":"_3-NVJ","bg-button":"_3-gs3","bg-info/10":"_2ENMR","bg-white":"_rF-HF","!text-error":"_3mBZd","text-black":"_Irb_H","text-gray-600":"_1pL5w","text-info":"_NLvfI","text-secondary-text":"_H-zEU","filter":"_p0OEu","sapp-calendar":"_18t93","btn":"_1oiD_","icon":"_-E7rn","btn-default":"_3WrnL","btn-primary":"_2-qBL","event-info":"_xYqjb","event-warning":"_1oq3N","event-success":"_1hTMm","event-error":"_1hEJk","event-default":"_8FWXy","sapp-calendar__container":"_102cL","header-calendar":"_3Yvs5","header-calendar__nav":"_18m93","header-calendar__date-picker":"_2GTYD","header-calendar__title":"_35LQ0","header-calendar__controls":"_FqVqb","header-calendar__divider":"_3kHog","monthly-calendar":"_2NDGW","weekly-calendar":"_1QrJs","monthly-calendar__title":"_3Tsy4","monthly-calendar__title-active":"_1Dyjm","weekly-norm__cell":"_sGK9m","weekly-norm__value":"_1Jsb-","monthly-calendar__cell":"_2hVZ4","monthly-calendar__cell--active":"_1uenJ","calendar-tooltip":"_2Uo1f","monthly-event__title":"_2gsg7","monthly-event__date":"_2GtPn","weekly-calendar__title":"_5WuQ8","weekly-calendar__cell":"_3lPkV","weekly-event":"_hnHem","weekly-event__title":"_21a0T","weekly-event__date":"_PiKmX","weekly-event--collapse":"_1pvXT","btn-lms-default":"_1GA3p","text-lms-primary":"_1gLzS","select-mode":"_12I9I","ant-select-dropdown-placement-bottomLeft":"_1ZvuX"};
404
+ var styles = {"flex":"_2hGgU","transform":"_3-Pu9","cursor-pointer":"_2Mcv6","rounded-none":"_3EfQZ","border-gray-4":"_3-NVJ","bg-button":"_3-gs3","bg-info/10":"_2ENMR","bg-white":"_rF-HF","!text-error":"_3mBZd","text-black":"_Irb_H","text-gray-600":"_1pL5w","text-info":"_NLvfI","text-secondary-text":"_H-zEU","filter":"_p0OEu","sapp-calendar":"_18t93","btn":"_1oiD_","icon":"_-E7rn","btn-default":"_3WrnL","btn-primary":"_2-qBL","event-info":"_xYqjb","event-warning":"_1oq3N","event-success":"_1hTMm","event-error":"_1hEJk","event-default":"_8FWXy","sapp-calendar__container":"_102cL","header-calendar":"_3Yvs5","header-calendar__nav":"_18m93","header-calendar__date-picker":"_2GTYD","header-calendar__title":"_35LQ0","header-calendar__controls":"_FqVqb","header-calendar__divider":"_3kHog","monthly-calendar":"_2NDGW","weekly-calendar":"_1QrJs","monthly-calendar__title":"_3Tsy4","monthly-calendar__title-active":"_1Dyjm","weekly-norm__cell":"_sGK9m","weekly-norm__value":"_1Jsb-","monthly-calendar__cell":"_2hVZ4","monthly-calendar__cell--active":"_1uenJ","calendar-tooltip":"_2Uo1f","monthly-event__title":"_2gsg7","monthly-event__date":"_2GtPn","weekly-calendar__title":"_5WuQ8","weekly-calendar__cell":"_3lPkV","weekly-event":"_hnHem","weekly-event__title":"_21a0T","weekly-event__date":"_PiKmX","weekly-event--collapse":"_1pvXT","btn-lms-default":"_1GA3p","text-lms-primary":"_1gLzS","select-mode":"_12I9I","ant-select-dropdown-placement-bottomLeft":"_1ZvuX","header-calendar_filter":"_1fd_Y","lms-calendar__tablet":"_1sVO3"};
374
405
 
375
406
  var Button = function Button(_ref) {
376
407
  var _ref$type = _ref.type,
@@ -458,234 +489,6 @@ var HeaderCalendar = function HeaderCalendar(_ref) {
458
489
  }, "Week")));
459
490
  };
460
491
 
461
- var CustomTooltip = function CustomTooltip(_ref) {
462
- var title = _ref.title,
463
- children = _ref.children,
464
- _ref$placement = _ref.placement,
465
- placement = _ref$placement === void 0 ? 'top' : _ref$placement;
466
- return React__default.createElement(antd.Tooltip, {
467
- color: '#ffffff',
468
- title: React__default.createElement("div", {
469
- className: styles['text-gray-600']
470
- }, title),
471
- placement: placement
472
- }, React__default.createElement("div", null, children));
473
- };
474
-
475
- var _getIconEvent;
476
- var calculateBoxSize = function calculateBoxSize(startTime, endTime, isAllDay) {
477
- if (isAllDay) {
478
- return {
479
- top: 10,
480
- height: 50
481
- };
482
- }
483
- var minutes = dayjs(startTime).minute();
484
- var diffMinutes = dayjs(endTime).diff(startTime, 'minute', true);
485
- return {
486
- top: Math.floor(minutes / MINUTES_PER_HOUR * 100),
487
- height: Math.floor(diffMinutes / MINUTES_PER_HOUR * 100)
488
- };
489
- };
490
- var getIconEvent = (_getIconEvent = {}, _getIconEvent[EVENT_TYPES.TEACHING] = React__default.createElement(Book, null), _getIconEvent[EVENT_TYPES.BUSY] = React__default.createElement(CalendarDelete, null), _getIconEvent[EVENT_TYPES.TIME_OFF] = React__default.createElement(Star, null), _getIconEvent[EVENT_TYPES.OTHER] = React__default.createElement(CalendarAccept, null), _getIconEvent);
491
- var MIN_HEIGHT_HIDE_DETAILS = 140;
492
- var MIN_HEIGHT_HIDE_ALL = 105;
493
- var WeeklyEvent = function WeeklyEvent(_ref) {
494
- var event = _ref.event,
495
- onOpenDetail = _ref.onOpenDetail,
496
- onEventDetail = _ref.onEventDetail;
497
- var _calculateBoxSize = calculateBoxSize(event.startDate, event.endDate, event.isAllDay),
498
- top = _calculateBoxSize.top,
499
- height = _calculateBoxSize.height;
500
- var formattedDate = customDateFormat(event.startDate, TIME_FORMAT) + ' - ' + customDateFormat(event.endDate, TIME_FORMAT);
501
- return React__default.createElement("div", {
502
- className: styles["event-" + convertType[event.type]],
503
- onClick: function onClick() {
504
- onOpenDetail(dayjs(event.startDate).toDate(), [event]);
505
- onEventDetail && onEventDetail(event);
506
- },
507
- style: {
508
- top: top + "%",
509
- height: height + "%",
510
- zIndex: event.type === EVENT_TYPES.BUSY ? 2 : 1
511
- }
512
- }, React__default.createElement("div", {
513
- className: clsx__default(styles['weekly-event'], height <= MIN_HEIGHT_HIDE_ALL && styles['weekly-event--collapse'])
514
- }, React__default.createElement("div", {
515
- className: styles.flex
516
- }, getIconEvent[event.type]), React__default.createElement("div", {
517
- className: clsx__default(height <= MIN_HEIGHT_HIDE_DETAILS && styles['weekly-event--collapse'])
518
- }, React__default.createElement("div", {
519
- className: styles['weekly-event__title']
520
- }, React__default.createElement(CustomTooltip, {
521
- title: event.title
522
- }, event.title)), React__default.createElement("div", {
523
- className: styles['weekly-event__date']
524
- }, React__default.createElement(CustomTooltip, {
525
- title: formattedDate
526
- }, formattedDate)))));
527
- };
528
-
529
- var WeeklyCell = function WeeklyCell(_ref) {
530
- var events = _ref.events,
531
- date = _ref.date,
532
- onOpenDetail = _ref.onOpenDetail,
533
- onOpenCreate = _ref.onOpenCreate,
534
- onEventDetail = _ref.onEventDetail;
535
- var isToday = dayjs().isSame(date, 'day');
536
- var handleOpenCreateModal = function handleOpenCreateModal(e) {
537
- if (e.target !== e.currentTarget) return;
538
- onOpenCreate(dayjs(date).toDate());
539
- };
540
- events.sort(function (a, b) {
541
- return a.type === EVENT_TYPES.BUSY && b.type !== EVENT_TYPES.BUSY ? 1 : -1;
542
- });
543
- var renderWeeklyEvent = React.useMemo(function () {
544
- var isAllDay = events.some(function (item) {
545
- return item.isAllDay;
546
- });
547
- if (isAllDay && events.length > 1) {
548
- return React__default.createElement(React__default.Fragment, null, React__default.createElement(WeeklyEvent, {
549
- event: events[0],
550
- onOpenDetail: onOpenDetail,
551
- onEventDetail: onEventDetail
552
- }), React__default.createElement("div", {
553
- className: styles['see-more']
554
- }, React__default.createElement(CustomTooltip, {
555
- placement: 'bottom',
556
- title: React__default.createElement("div", {
557
- className: styles['calendar-tooltip']
558
- }, events.slice(1, events.length).map(function (event, index) {
559
- return React__default.createElement(WeeklyEvent, {
560
- event: event,
561
- onOpenDetail: onOpenDetail,
562
- onEventDetail: onEventDetail,
563
- key: index + 1
564
- });
565
- }))
566
- }, "+", Math.max(events.length - 1, 0), " More")));
567
- }
568
- return events.map(function (event, index) {
569
- return React__default.createElement(WeeklyEvent, {
570
- key: index,
571
- event: event,
572
- onOpenDetail: onOpenDetail,
573
- onEventDetail: onEventDetail
574
- });
575
- });
576
- }, [events]);
577
- return React__default.createElement("div", {
578
- className: styles['weekly-calendar__cell'] + " " + (isToday ? styles['bg-info/10'] : styles['bg-white']),
579
- onClick: handleOpenCreateModal
580
- }, renderWeeklyEvent);
581
- };
582
-
583
- dayjs.extend(isBetween);
584
- var getEventAllDay = function getEventAllDay(events, targetDate) {
585
- return daysOfWeekKeys.reduce(function (acc, day, index) {
586
- var currentDate = targetDate.add(index, 'day');
587
- acc[day] = {
588
- events: events.reduce(function (filteredEvents, event) {
589
- if (dayjs(event.startDate).isSame(currentDate.startOf('day')) && checkIsAllday(dayjs(event.startDate), dayjs(event.endDate))) {
590
- filteredEvents.push(_extends({}, event, {
591
- isAllDay: true
592
- }));
593
- }
594
- return filteredEvents;
595
- }, []),
596
- date: currentDate
597
- };
598
- return acc;
599
- }, {});
600
- };
601
- var getEventsOfDay = function getEventsOfDay(events, targetHour) {
602
- return daysOfWeekKeys.reduce(function (acc, day, index) {
603
- var currentDate = targetHour.add(index, 'day');
604
- acc[day] = {
605
- events: events.filter(function (event) {
606
- return dayjs(event.startDate).isSame(currentDate, 'hour') && !checkIsAllday(dayjs(event.startDate), dayjs(event.endDate));
607
- }),
608
- date: currentDate
609
- };
610
- return acc;
611
- }, {});
612
- };
613
- var WeeklyCalendar = function WeeklyCalendar(_ref) {
614
- var startDate = _ref.startDate,
615
- endDate = _ref.endDate,
616
- events = _ref.events,
617
- norms = _ref.norms,
618
- showWeeklyNorm = _ref.showWeeklyNorm,
619
- onOpenDetail = _ref.onOpenDetail,
620
- onOpenCreate = _ref.onOpenCreate,
621
- onEventDetail = _ref.onEventDetail,
622
- loading = _ref.loading;
623
- var getTableColumns = function getTableColumns() {
624
- var _calculateNormOfWeek = calculateNormOfWeek(norms, events, startDate, endDate),
625
- normOfWeek = _calculateNormOfWeek.normOfWeek,
626
- totalNorm = _calculateNormOfWeek.totalNorm;
627
- var hourColumn = {
628
- title: React__default.createElement("div", {
629
- className: styles['weekly-calendar__title']
630
- }, showWeeklyNorm && React__default.createElement(React__default.Fragment, null, React__default.createElement("div", null, "Weekly Norm"), React__default.createElement("div", {
631
- className: clsx__default(normOfWeek > totalNorm && styles['!text-error'])
632
- }, normOfWeek + "/" + totalNorm))),
633
- dataIndex: 'hour',
634
- key: 'hour',
635
- width: 1,
636
- render: function render(value) {
637
- return React__default.createElement("div", null, value);
638
- }
639
- };
640
- var dayColumns = Object.values(DAYS_OF_WEEK).map(function (day, index) {
641
- return {
642
- title: React__default.createElement("div", {
643
- className: styles['weekly-calendar__title']
644
- }, React__default.createElement("div", null, day.slice(0, 3)), React__default.createElement("div", null, dayjs(startDate).add(index, 'day').format('DD/MM'))),
645
- dataIndex: day,
646
- key: day,
647
- render: function render(value) {
648
- return React__default.createElement(WeeklyCell, {
649
- key: index,
650
- events: value.events,
651
- date: value.date,
652
- onOpenDetail: onOpenDetail,
653
- onOpenCreate: onOpenCreate,
654
- onEventDetail: onEventDetail
655
- });
656
- }
657
- };
658
- });
659
- return [hourColumn].concat(dayColumns);
660
- };
661
- var getTableData = function getTableData() {
662
- var data = [];
663
- data.push(_extends({
664
- id: -1,
665
- hour: 'All day'
666
- }, getEventAllDay(events, startDate)));
667
- for (var i = 0; i < HOURS_PER_DAY; i++) {
668
- var targetHour = dayjs(startDate).add(i, 'hour');
669
- data.push(_extends({
670
- id: i,
671
- hour: targetHour.format('HH:mm')
672
- }, getEventsOfDay(events, targetHour)));
673
- }
674
- return data;
675
- };
676
- return React__default.createElement(antd.Table, {
677
- rowKey: function rowKey(record) {
678
- return record.id;
679
- },
680
- columns: getTableColumns(),
681
- dataSource: getTableData(),
682
- pagination: false,
683
- rowHoverable: false,
684
- className: styles['weekly-calendar'],
685
- loading: loading
686
- });
687
- };
688
-
689
492
  var SelectBox = function SelectBox(_ref) {
690
493
  var value = _ref.value,
691
494
  options = _ref.options,
@@ -729,6 +532,8 @@ var LMSHeaderCalendar = function LMSHeaderCalendar(_ref) {
729
532
  };
730
533
  return React__default.createElement("div", {
731
534
  className: styles['header-calendar']
535
+ }, React__default.createElement("div", {
536
+ className: styles['header-calendar_filter']
732
537
  }, React__default.createElement("div", {
733
538
  className: clsx__default('cursor-pointer', filter.isOpen && styles['text-lms-primary']),
734
539
  onClick: toggleTurnOnFilter
@@ -756,7 +561,7 @@ var LMSHeaderCalendar = function LMSHeaderCalendar(_ref) {
756
561
  onClick: function onClick() {
757
562
  return handleChangeDate(currentDate.add(1, calendarMode));
758
563
  }
759
- })), showTeacherName && React__default.createElement("div", {
564
+ }))), showTeacherName && React__default.createElement("div", {
760
565
  className: styles['header-calendar__title']
761
566
  }, title), React__default.createElement("div", {
762
567
  className: styles['header-calendar__controls']
@@ -789,39 +594,39 @@ var FilterCalendar = function FilterCalendar(_ref) {
789
594
  icon: React__default.createElement("div", {
790
595
  className: styles$1['calendar-filter_note_blue']
791
596
  }),
792
- value: 'ONLINE'
597
+ value: LEARNING_MODE.ONLINE
793
598
  }, {
794
599
  title: 'Live Online',
795
600
  icon: React__default.createElement("div", {
796
601
  className: styles$1['calendar-filter_note_pureple']
797
602
  }),
798
- value: 'LIVE_ONLINE'
603
+ value: LEARNING_MODE.LIVE_ONLINE
799
604
  }, {
800
605
  title: 'Offline',
801
606
  icon: React__default.createElement("div", {
802
607
  className: styles$1['calendar-filter_note_green']
803
608
  }),
804
- value: 'OFFLINE'
609
+ value: LEARNING_MODE.OFFLINE
805
610
  }, {
806
611
  title: 'Case Study',
807
612
  icon: React__default.createElement(GoldStarIcon, null),
808
- value: 'CASE_STUDY'
613
+ value: LEARNING_MODE.CASE_STUDY
809
614
  }, {
810
615
  title: 'Test',
811
616
  icon: React__default.createElement(BookIcon, null),
812
- value: 'TEST'
617
+ value: LEARNING_MODE.TEST
813
618
  }, {
814
619
  title: 'Holiday',
815
620
  icon: React__default.createElement("div", {
816
621
  className: styles$1['calendar-filter_note_yellow']
817
622
  }),
818
- value: 'HOLIDAY'
623
+ value: LEARNING_MODE.HOLIDAY
819
624
  }, {
820
625
  title: 'Overdue',
821
626
  icon: React__default.createElement("div", {
822
627
  className: styles$1['calendar-filter_note_red']
823
628
  }),
824
- value: 'OVERDUE'
629
+ value: LEARNING_MODE.OVERDUE
825
630
  }];
826
631
  }, []);
827
632
  var handleFilter = function handleFilter(type, value) {
@@ -905,6 +710,20 @@ var FilterCalendar = function FilterCalendar(_ref) {
905
710
  }))));
906
711
  };
907
712
 
713
+ var CustomTooltip = function CustomTooltip(_ref) {
714
+ var title = _ref.title,
715
+ children = _ref.children,
716
+ _ref$placement = _ref.placement,
717
+ placement = _ref$placement === void 0 ? 'top' : _ref$placement;
718
+ return React__default.createElement(antd.Tooltip, {
719
+ color: '#ffffff',
720
+ title: React__default.createElement("div", {
721
+ className: styles['text-gray-600']
722
+ }, title),
723
+ placement: placement
724
+ }, React__default.createElement("div", null, children));
725
+ };
726
+
908
727
  var MonthlyEvent = function MonthlyEvent(_ref) {
909
728
  var event = _ref.event,
910
729
  isSameMonth = _ref.isSameMonth,
@@ -1078,6 +897,203 @@ var MonthlyCalendar = function MonthlyCalendar(_ref) {
1078
897
  });
1079
898
  };
1080
899
 
900
+ var _getIconEvent;
901
+ var getIconEvent = (_getIconEvent = {}, _getIconEvent[EVENT_TYPES.TEACHING] = React__default.createElement(Book, null), _getIconEvent[EVENT_TYPES.BUSY] = React__default.createElement(CalendarDelete, null), _getIconEvent[EVENT_TYPES.TIME_OFF] = React__default.createElement(Star, null), _getIconEvent[EVENT_TYPES.OTHER] = React__default.createElement(CalendarAccept, null), _getIconEvent);
902
+ var calculateBoxSize = function calculateBoxSize(startTime, endTime) {
903
+ var minutes = dayjs(startTime).minute();
904
+ var diffMinutes = dayjs(endTime).diff(startTime, 'hour', true);
905
+ return {
906
+ width: diffMinutes || 1,
907
+ left: Math.floor(minutes / MINUTES_PER_HOUR * 100)
908
+ };
909
+ };
910
+ var LMSWeeklyEvent = function LMSWeeklyEvent(_ref) {
911
+ var event = _ref.event,
912
+ onOpenDetail = _ref.onOpenDetail,
913
+ onEventDetail = _ref.onEventDetail;
914
+ var formattedDate = customDateFormat(event.startDate, TIME_FORMAT) + ' - ' + customDateFormat(event.endDate, TIME_FORMAT);
915
+ var _calculateBoxSize = calculateBoxSize(event.startDate, event.endDate),
916
+ width = _calculateBoxSize.width,
917
+ left = _calculateBoxSize.left;
918
+ return React__default.createElement("div", {
919
+ className: styles["event-" + convertType[event.type]],
920
+ onClick: function onClick() {
921
+ onOpenDetail(dayjs(event.startDate).toDate(), [event]);
922
+ onEventDetail && onEventDetail(event);
923
+ },
924
+ style: {
925
+ top: "0%",
926
+ height: "100%",
927
+ width: width * 100 + '%',
928
+ left: left + '%',
929
+ zIndex: event.type === EVENT_TYPES.BUSY ? 2 : 1
930
+ }
931
+ }, React__default.createElement("div", {
932
+ className: clsx__default(styles['weekly-event'])
933
+ }, React__default.createElement("div", {
934
+ className: clsx__default(styles['weekly-event--collapse'])
935
+ }, React__default.createElement("div", {
936
+ className: styles.flex
937
+ }, getIconEvent[event.type]), React__default.createElement("div", {
938
+ className: styles['weekly-event__title']
939
+ }, React__default.createElement(CustomTooltip, {
940
+ title: event.title
941
+ }, event.title))), React__default.createElement("div", {
942
+ className: styles['weekly-event__date']
943
+ }, React__default.createElement(CustomTooltip, {
944
+ title: formattedDate
945
+ }, formattedDate))));
946
+ };
947
+
948
+ var LMSWeeklyCell = function LMSWeeklyCell(_ref) {
949
+ var _events;
950
+ var events = _ref.events,
951
+ date = _ref.date,
952
+ onOpenDetail = _ref.onOpenDetail,
953
+ onOpenCreate = _ref.onOpenCreate,
954
+ onEventDetail = _ref.onEventDetail;
955
+ var isToday = dayjs().isSame(date, 'day');
956
+ var handleOpenCreateModal = function handleOpenCreateModal(e) {
957
+ if (e.target !== e.currentTarget) return;
958
+ onOpenCreate(dayjs(date).toDate());
959
+ };
960
+ events = (_events = events) === null || _events === void 0 ? void 0 : _events.sort(function (a, b) {
961
+ return a.type === EVENT_TYPES.BUSY && b.type !== EVENT_TYPES.BUSY ? 1 : -1;
962
+ });
963
+ var renderWeeklyEvent = React.useMemo(function () {
964
+ var _events2, _events3, _events4;
965
+ var isAllDay = (_events2 = events) === null || _events2 === void 0 ? void 0 : _events2.some(function (item) {
966
+ return item.isAllDay;
967
+ });
968
+ if (isAllDay && ((_events3 = events) === null || _events3 === void 0 ? void 0 : _events3.length) > 1) {
969
+ return React__default.createElement(React__default.Fragment, null, React__default.createElement(LMSWeeklyEvent, {
970
+ event: events[0],
971
+ onOpenDetail: onOpenDetail,
972
+ onEventDetail: onEventDetail
973
+ }), React__default.createElement("div", {
974
+ className: styles['see-more']
975
+ }, React__default.createElement(CustomTooltip, {
976
+ placement: 'bottom',
977
+ title: React__default.createElement("div", {
978
+ className: styles['calendar-tooltip']
979
+ }, events.slice(1, events.length).map(function (event, index) {
980
+ return React__default.createElement(LMSWeeklyEvent, {
981
+ event: event,
982
+ onOpenDetail: onOpenDetail,
983
+ onEventDetail: onEventDetail,
984
+ key: index + 1
985
+ });
986
+ }))
987
+ }, "+", Math.max(events.length - 1, 0), " More")));
988
+ }
989
+ return (_events4 = events) === null || _events4 === void 0 ? void 0 : _events4.map(function (event, index) {
990
+ return React__default.createElement(LMSWeeklyEvent, {
991
+ key: index,
992
+ event: event,
993
+ onOpenDetail: onOpenDetail,
994
+ onEventDetail: onEventDetail
995
+ });
996
+ });
997
+ }, [events]);
998
+ return React__default.createElement("div", {
999
+ className: styles['weekly-calendar__cell'] + " " + (isToday ? styles['bg-info/10'] : styles['bg-white']),
1000
+ onClick: handleOpenCreateModal
1001
+ }, renderWeeklyEvent);
1002
+ };
1003
+
1004
+ dayjs.extend(isBetween);
1005
+ var LMSWeeklyCalendar = function LMSWeeklyCalendar(_ref) {
1006
+ var startDate = _ref.startDate,
1007
+ events = _ref.events,
1008
+ onOpenDetail = _ref.onOpenDetail,
1009
+ onOpenCreate = _ref.onOpenCreate,
1010
+ onEventDetail = _ref.onEventDetail,
1011
+ loading = _ref.loading;
1012
+ var getEventsOfHour = function getEventsOfHour(events, targetHour) {
1013
+ return hoursOfDayKeys.reduce(function (acc, hour) {
1014
+ acc[hour] = {
1015
+ events: events.filter(function (event) {
1016
+ return dayjs(event.startDate).isSame(dayjs(targetHour.format('YYYY-MM-DD') + "T" + hour + ":00"), 'hour') && !checkIsAllday(dayjs(event.startDate), dayjs(event.endDate));
1017
+ }),
1018
+ date: dayjs(targetHour.format('YYYY-MM-DD') + "T" + hour)
1019
+ };
1020
+ return acc;
1021
+ }, {});
1022
+ };
1023
+ var getTableColumns = function getTableColumns() {
1024
+ var hourColumn = {
1025
+ title: React__default.createElement("div", {
1026
+ className: styles['weekly-calendar__title']
1027
+ }),
1028
+ dataIndex: 'hour',
1029
+ key: 'hour',
1030
+ width: 1,
1031
+ render: function render(value) {
1032
+ return React__default.createElement("div", null, value);
1033
+ }
1034
+ };
1035
+ var hours = Array.from({
1036
+ length: 17
1037
+ }, function (_, i) {
1038
+ return 7 + i;
1039
+ });
1040
+ var timeColums = hours.map(function (time, index) {
1041
+ return {
1042
+ title: React__default.createElement("div", {
1043
+ className: styles['weekly-calendar__title']
1044
+ }, time % 2 !== 0 ? React__default.createElement("div", {
1045
+ style: {
1046
+ textAlign: 'start'
1047
+ }
1048
+ }, time < 10 ? '0' + time + ':00' : time + ':00') : React__default.createElement("div", {
1049
+ style: {
1050
+ minWidth: '35px'
1051
+ }
1052
+ })),
1053
+ dataIndex: "" + (time < 10 ? '0' + time + ':00' : time + ':00'),
1054
+ key: "" + (time < 10 ? '0' + time + ':00' : time + ':00'),
1055
+ render: function render(value) {
1056
+ return React__default.createElement(LMSWeeklyCell, {
1057
+ key: index,
1058
+ events: value === null || value === void 0 ? void 0 : value.events,
1059
+ date: value === null || value === void 0 ? void 0 : value.date,
1060
+ onOpenDetail: onOpenDetail,
1061
+ onOpenCreate: onOpenCreate,
1062
+ onEventDetail: onEventDetail
1063
+ });
1064
+ }
1065
+ };
1066
+ });
1067
+ return [hourColumn].concat(timeColums);
1068
+ };
1069
+ var getTableData = function getTableData() {
1070
+ var data = [];
1071
+ for (var i = 0; i < 7; i++) {
1072
+ var targetHour = dayjs(startDate).add(i, 'day');
1073
+ data.push(_extends({
1074
+ id: i,
1075
+ hour: React__default.createElement("div", null, React__default.createElement("div", {
1076
+ className: styles['lms-calendar__tablet']
1077
+ }, Object.values(DAYS_OF_WEEK)[i]), React__default.createElement("div", {
1078
+ className: styles['lms-calendar__tablet']
1079
+ }, dayjs(startDate).add(i, 'day').format('DD')))
1080
+ }, getEventsOfHour(events, targetHour)));
1081
+ }
1082
+ return data;
1083
+ };
1084
+ return React__default.createElement(antd.Table, {
1085
+ rowKey: function rowKey(record) {
1086
+ return record.id;
1087
+ },
1088
+ columns: getTableColumns(),
1089
+ dataSource: getTableData(),
1090
+ pagination: false,
1091
+ rowHoverable: false,
1092
+ className: styles['weekly-calendar'],
1093
+ loading: loading
1094
+ });
1095
+ };
1096
+
1081
1097
  var SAPPCalendar = function SAPPCalendar(_ref) {
1082
1098
  var teacherName = _ref.teacherName,
1083
1099
  events = _ref.events,
@@ -1099,13 +1115,15 @@ var SAPPCalendar = function SAPPCalendar(_ref) {
1099
1115
  var _useState = React.useState(dayjs()),
1100
1116
  currentDate = _useState[0],
1101
1117
  setCurrentDate = _useState[1];
1102
- var _useState2 = React.useState('month'),
1118
+ var _useState2 = React.useState('week'),
1103
1119
  calendarMode = _useState2[0],
1104
1120
  setCalendarMode = _useState2[1];
1105
1121
  var _useState3 = React.useState({
1106
1122
  isOpen: false,
1107
- type: [],
1108
- courseId: []
1123
+ type: Object.values(LEARNING_MODE),
1124
+ courseId: courses !== null && courses !== void 0 && courses.length ? courses === null || courses === void 0 ? void 0 : courses.map(function (item) {
1125
+ return item.id;
1126
+ }) : []
1109
1127
  }),
1110
1128
  filter = _useState3[0],
1111
1129
  setFilter = _useState3[1];
@@ -1135,11 +1153,12 @@ var SAPPCalendar = function SAPPCalendar(_ref) {
1135
1153
  useEffectAfterMounted(function () {
1136
1154
  onRefetchAPI(startDate.toDate(), endDate.toDate());
1137
1155
  }, [startDate, endDate]);
1156
+ console.log('course:', courses);
1138
1157
  React.useEffect(function () {
1139
1158
  if (type === 'filter') {
1140
1159
  onFilter && onFilter(filter);
1141
1160
  }
1142
- }, [events]);
1161
+ }, [filter]);
1143
1162
  return React__default.createElement("div", {
1144
1163
  className: styles['sapp-calendar']
1145
1164
  }, filter.isOpen && React__default.createElement(FilterCalendar, {
@@ -1175,12 +1194,11 @@ var SAPPCalendar = function SAPPCalendar(_ref) {
1175
1194
  onOpenCreate: onOpenCreate,
1176
1195
  onEventDetail: onEventDetail,
1177
1196
  loading: loading
1178
- }), calendarMode === 'week' && React__default.createElement(WeeklyCalendar, {
1197
+ }), calendarMode === 'week' && React__default.createElement(LMSWeeklyCalendar, {
1179
1198
  startDate: startDate,
1180
1199
  endDate: endDate,
1181
1200
  events: splittedEvents,
1182
1201
  norms: norms,
1183
- showWeeklyNorm: showWeeklyNorm,
1184
1202
  onOpenDetail: onOpenDetail,
1185
1203
  onOpenCreate: onOpenCreate,
1186
1204
  onEventDetail: onEventDetail,