@propriety/court-calendar 1.0.20 → 1.0.21

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@propriety/court-calendar",
3
3
  "private": false,
4
- "version": "1.0.20",
4
+ "version": "1.0.21",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "module": "./dist/index.mjs",
@@ -247,9 +247,7 @@ export default function CalendarList({
247
247
  .filter((date) => {
248
248
  if (!date.CourtDate) return false;
249
249
  const courtDate = new Date(date.CourtDate);
250
- return (
251
- courtDate.getMonth() === currentDate.getMonth() && courtDate.getFullYear() === currentDate.getFullYear()
252
- );
250
+ return courtDate.getFullYear() === currentDate.getFullYear();
253
251
  })
254
252
  .map((date) => ({
255
253
  id: date.CourtDateID,
@@ -24,6 +24,7 @@ export default function Toolbar({
24
24
  handleCreateClick,
25
25
  currentView,
26
26
  setCurrentView,
27
+ currentDate,
27
28
  setCurrentDate,
28
29
  activeUser,
29
30
  isFetchingCases,
@@ -46,34 +47,43 @@ export default function Toolbar({
46
47
  useEffect(() => {
47
48
  if (calendarApi) {
48
49
  const handleDatesSet = () => {
49
- setCurrentTitle(calendarApi.getCurrentData().viewTitle);
50
+ if (currentView !== 'tableView') {
51
+ setCurrentTitle(calendarApi.getCurrentData().viewTitle);
52
+ }
50
53
  };
51
54
  calendarApi.on('datesSet', handleDatesSet);
52
55
  return () => {
53
56
  calendarApi.off('datesSet', handleDatesSet);
54
57
  };
55
58
  }
56
- }, [calendarApi]);
59
+ }, [calendarApi, currentView]);
57
60
 
58
61
  useEffect(() => {
62
+ if (currentView === 'tableView') {
63
+ setCurrentTitle(currentDate.getFullYear().toString());
64
+ return;
65
+ }
59
66
  if (calendarApi) {
60
- if (currentView === 'tableView') {
61
- setCurrentTitle(calendarApi.getDate().toLocaleDateString('en-US', { month: 'long', year: 'numeric' }));
62
- return;
63
- }
64
67
  setCurrentTitle(calendarApi.getCurrentData().viewTitle);
65
68
  }
66
- }, [calendarApi, currentView]);
69
+ }, [calendarApi, currentView, currentDate]);
67
70
 
68
71
  function goToToday() {
72
+ setCurrentDate(new Date());
73
+ if (currentView === 'tableView') return;
69
74
  if (calendarApi) {
70
75
  calendarApi.today();
71
- setCurrentDate(new Date());
72
76
  setCurrentTitle(calendarApi.getCurrentData().viewTitle);
73
77
  }
74
78
  }
75
79
 
76
80
  function handleNext() {
81
+ if (currentView === 'tableView') {
82
+ const next = new Date(currentDate);
83
+ next.setFullYear(next.getFullYear() + 1);
84
+ setCurrentDate(next);
85
+ return;
86
+ }
77
87
  if (calendarApi) {
78
88
  calendarApi.next();
79
89
  setCurrentDate(calendarApi.getDate());
@@ -82,6 +92,12 @@ export default function Toolbar({
82
92
  }
83
93
 
84
94
  function handlePrev() {
95
+ if (currentView === 'tableView') {
96
+ const prev = new Date(currentDate);
97
+ prev.setFullYear(prev.getFullYear() - 1);
98
+ setCurrentDate(prev);
99
+ return;
100
+ }
85
101
  if (calendarApi) {
86
102
  calendarApi.prev();
87
103
  setCurrentDate(calendarApi.getDate());