@stoker-platform/web-app 0.5.122 → 0.5.124

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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @stoker-platform/web-app
2
2
 
3
+ ## 0.5.124
4
+
5
+ ### Patch Changes
6
+
7
+ - feat: use inclusive dates for all day events
8
+
9
+ ## 0.5.123
10
+
11
+ ### Patch Changes
12
+
13
+ - fix: correct maintenance alert colours
14
+
3
15
  ## 0.5.122
4
16
 
5
17
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stoker-platform/web-app",
3
- "version": "0.5.122",
3
+ "version": "0.5.124",
4
4
  "type": "module",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "scripts": {
package/src/Calendar.tsx CHANGED
@@ -85,6 +85,21 @@ import { useConnection } from "./providers/ConnectionProvider"
85
85
  import { SortingState } from "@tanstack/react-table"
86
86
  import { cn } from "./lib/utils"
87
87
 
88
+ function getExclusiveEnd(inclusiveEnd: Date, timezone: string): Date {
89
+ return DateTime.fromJSDate(inclusiveEnd).setZone(timezone).startOf("day").plus({ days: 1 }).toJSDate()
90
+ }
91
+
92
+ function getInclusiveEnd(exclusiveEnd: Date, timezone: string): Date {
93
+ return DateTime.fromJSDate(exclusiveEnd).setZone(timezone).startOf("day").minus({ days: 1 }).toJSDate()
94
+ }
95
+
96
+ function isAllDayEvent(record: StokerRecord, calendarConfig: CalendarConfig): boolean {
97
+ if (calendarConfig.allDayField !== undefined) {
98
+ return !!record[calendarConfig.allDayField]
99
+ }
100
+ return !!(calendarConfig.fullCalendarLarge?.defaultAllDay || calendarConfig.fullCalendarSmall?.defaultAllDay)
101
+ }
102
+
88
103
  function Row({
89
104
  collection,
90
105
  record,
@@ -655,10 +670,13 @@ export function Calendar({
655
670
  resourceEditable: !isPendingServer && !isUpdateDisabled && hasReourceUpdateAccess,
656
671
  }
657
672
  if (calendarConfig.endField && record[calendarConfig.endField]) {
658
- event.end = record[calendarConfig.endField].toDate()
673
+ const rawEnd = record[calendarConfig.endField].toDate()
674
+ event.end = isAllDayEvent(record, calendarConfig) ? getExclusiveEnd(rawEnd, timezone) : rawEnd
659
675
  }
660
676
  if (calendarConfig.allDayField !== undefined) {
661
677
  event.allDay = record[calendarConfig.allDayField]
678
+ } else if (isAllDayEvent(record, calendarConfig)) {
679
+ event.allDay = true
662
680
  }
663
681
  if (calendarConfig.resourceField && record[calendarConfig.resourceField] !== undefined) {
664
682
  const resource = getResource(labels.collection, record, calendarConfig.resourceField)
@@ -722,6 +740,7 @@ export function Calendar({
722
740
  hasEndUpdateAccess,
723
741
  hasReourceUpdateAccess,
724
742
  isGlobalLoading,
743
+ timezone,
725
744
  ])
726
745
 
727
746
  const updateEvent = useCallback(
@@ -733,10 +752,23 @@ export function Calendar({
733
752
 
734
753
  const updatedFields: Partial<StokerRecord> = {}
735
754
  if (calendarConfig.startField && info.event.start) {
736
- updatedFields[calendarConfig.startField] = Timestamp.fromDate(info.event.start)
755
+ const startDate = info.event.allDay
756
+ ? DateTime.fromJSDate(info.event.start).setZone(timezone).startOf("day").toJSDate()
757
+ : info.event.start
758
+ updatedFields[calendarConfig.startField] = Timestamp.fromDate(startDate)
737
759
  }
738
760
  if (calendarConfig.endField && info.event.start) {
739
- updatedFields[calendarConfig.endField] = Timestamp.fromDate(info.event.end || info.event.start)
761
+ let endDate: Date
762
+ if (info.event.allDay) {
763
+ if (info.event.end) {
764
+ endDate = getInclusiveEnd(info.event.end, timezone)
765
+ } else {
766
+ endDate = DateTime.fromJSDate(info.event.start).setZone(timezone).startOf("day").toJSDate()
767
+ }
768
+ } else {
769
+ endDate = info.event.end ?? info.event.start
770
+ }
771
+ updatedFields[calendarConfig.endField] = Timestamp.fromDate(endDate)
740
772
  }
741
773
  if (calendarConfig.allDayField !== undefined) {
742
774
  updatedFields[calendarConfig.allDayField] = info.event.allDay
@@ -816,7 +848,7 @@ export function Calendar({
816
848
  })
817
849
  }
818
850
  },
819
- [calendarConfig, list, unscheduledRecords, recordTitleField, recordTitle],
851
+ [calendarConfig, list, unscheduledRecords, recordTitleField, recordTitle, timezone],
820
852
  )
821
853
 
822
854
  const createEvent = useCallback(
@@ -1021,7 +1053,14 @@ export function Calendar({
1021
1053
  createEvent({ start: info.date })
1022
1054
  },
1023
1055
  select(info: DateSelectArg) {
1024
- createEvent({ start: info.start, end: info.end })
1056
+ if (info.allDay && info.end) {
1057
+ createEvent({
1058
+ start: info.start,
1059
+ end: getInclusiveEnd(info.end, timezone),
1060
+ })
1061
+ } else {
1062
+ createEvent({ start: info.start, end: info.end })
1063
+ }
1025
1064
  },
1026
1065
  eventInteractive: true,
1027
1066
  height: "auto",
@@ -2,8 +2,8 @@ import { Card, CardContent, CardHeader, CardTitle } from "./components/ui/card"
2
2
 
3
3
  export default function Maintenance() {
4
4
  return (
5
- <div className="flex justify-center items-center h-[calc(100vh-128px)] p-5">
6
- <Card>
5
+ <div className="flex justify-center items-center h-screen p-5 bg-white">
6
+ <Card className="relative bottom-8 bg-white text-black border-gray-200">
7
7
  <CardHeader>
8
8
  <CardTitle>Maintenance Mode</CardTitle>
9
9
  </CardHeader>