@remit/ui 0.0.192 → 0.0.194
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 +1 -1
- package/src/components/account-service-change-dialog.render.test.ts +73 -0
- package/src/components/account-service-change-dialog.stories.tsx +66 -0
- package/src/components/account-service-change-dialog.tsx +117 -0
- package/src/components/account-service-choice.tsx +4 -3
- package/src/components/account-service-status.render.test.ts +82 -0
- package/src/components/account-service-status.stories.tsx +61 -0
- package/src/components/account-service-status.tsx +89 -0
- package/src/components/account-service-toggles.render.test.ts +123 -0
- package/src/components/account-service-toggles.stories.tsx +121 -0
- package/src/components/account-service-toggles.tsx +125 -0
- package/src/components/agenda-composer.render.test.ts +1 -0
- package/src/components/agenda-composer.stories.tsx +1 -0
- package/src/components/agenda-flow.tsx +3 -0
- package/src/components/app-shell-types.ts +7 -0
- package/src/components/calendar-list.render.test.ts +34 -0
- package/src/components/calendar-list.stories.tsx +32 -0
- package/src/components/calendar-list.tsx +43 -30
- package/src/components/calendar-slot-offers.render.test.ts +7 -1
- package/src/components/calendar-slot-offers.stories.tsx +7 -1
- package/src/components/calendar-types.ts +9 -0
- package/src/components/event-editor.render.test.ts +23 -0
- package/src/components/event-editor.stories.tsx +31 -4
- package/src/components/event-editor.tsx +78 -50
- package/src/components/intelligence-calendar-fixtures.ts +7 -1
- package/src/components/nav-sidebar.render.test.ts +40 -0
- package/src/components/nav-sidebar.tsx +13 -0
- package/src/index.ts +27 -0
- package/src/lib/agenda-time.ts +15 -0
- package/src/lib/calendar-slot-pick.test.ts +25 -5
- package/src/lib/calendar-slot-pick.ts +13 -3
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ChevronDown, ChevronRight, Repeat } from "lucide-react";
|
|
2
2
|
import { type ReactNode, useId } from "react";
|
|
3
|
+
import { addDays, daysFrom } from "../lib/agenda-time.js";
|
|
3
4
|
import { calendarColorClasses } from "../lib/calendar-color.js";
|
|
4
5
|
import { cn } from "../lib/cn.js";
|
|
5
6
|
import { NO_REPEAT, repeatChoices } from "../lib/recurrence.js";
|
|
@@ -72,20 +73,52 @@ export function EventTitleField({
|
|
|
72
73
|
}
|
|
73
74
|
|
|
74
75
|
/**
|
|
75
|
-
*
|
|
76
|
-
* over —
|
|
77
|
-
* to save it rather than swapping the
|
|
76
|
+
* An end before the start is a span the calendar reads backwards, not a night
|
|
77
|
+
* that runs over — a night that runs over ends on the next day, and says so.
|
|
78
|
+
* The form names the problem and refuses to save it rather than swapping the
|
|
79
|
+
* fields behind whoever typed them.
|
|
78
80
|
*/
|
|
79
81
|
export function endsBeforeStart(draft: EventDraft): boolean {
|
|
80
|
-
if (draft.
|
|
82
|
+
if (draft.date === "" || draft.endDate === "") return false;
|
|
83
|
+
if (draft.allDay) return draft.endDate < draft.date;
|
|
81
84
|
if (draft.startTime === "" || draft.endTime === "") return false;
|
|
82
|
-
return
|
|
85
|
+
return (
|
|
86
|
+
`${draft.endDate}T${draft.endTime}` < `${draft.date}T${draft.startTime}`
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export function withStartDate(draft: EventDraft, date: string): EventDraft {
|
|
91
|
+
if (date === "") return { ...draft, date };
|
|
92
|
+
if (draft.endDate === "") return { ...draft, date, endDate: date };
|
|
93
|
+
if (draft.date === "") return { ...draft, date };
|
|
94
|
+
return {
|
|
95
|
+
...draft,
|
|
96
|
+
date,
|
|
97
|
+
endDate: addDays(date, daysFrom(draft.date, draft.endDate)),
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export function withAllDay(draft: EventDraft, allDay: boolean): EventDraft {
|
|
102
|
+
const overnight =
|
|
103
|
+
draft.date !== "" &&
|
|
104
|
+
draft.endDate === addDays(draft.date, 1) &&
|
|
105
|
+
draft.startTime !== "" &&
|
|
106
|
+
draft.endTime !== "" &&
|
|
107
|
+
draft.endTime < draft.startTime;
|
|
108
|
+
if (allDay && overnight) return { ...draft, allDay, endDate: draft.date };
|
|
109
|
+
return { ...draft, allDay };
|
|
83
110
|
}
|
|
84
111
|
|
|
85
112
|
export function EventWhenField({ draft, onChange, touch }: EventFieldProps) {
|
|
86
113
|
const fieldHeight = touch ? "min-h-11" : "";
|
|
87
114
|
const backwards = endsBeforeStart(draft);
|
|
88
115
|
const messageId = useId();
|
|
116
|
+
const invalid = {
|
|
117
|
+
"aria-invalid": backwards,
|
|
118
|
+
"aria-describedby": backwards ? messageId : undefined,
|
|
119
|
+
};
|
|
120
|
+
const dateClass = cn("w-40", fieldHeight, backwards && "border-danger/60");
|
|
121
|
+
const timeClass = cn("w-28", fieldHeight, backwards && "border-danger/60");
|
|
89
122
|
return (
|
|
90
123
|
<div className="flex flex-col gap-1.5">
|
|
91
124
|
<div className="flex flex-wrap items-center gap-2">
|
|
@@ -93,57 +126,51 @@ export function EventWhenField({ draft, onChange, touch }: EventFieldProps) {
|
|
|
93
126
|
type="date"
|
|
94
127
|
value={draft.date}
|
|
95
128
|
aria-label="Date"
|
|
129
|
+
{...invalid}
|
|
130
|
+
onChange={(e) => onChange(withStartDate(draft, e.target.value))}
|
|
131
|
+
className={dateClass}
|
|
132
|
+
/>
|
|
133
|
+
{!draft.allDay && (
|
|
134
|
+
<Input
|
|
135
|
+
type="time"
|
|
136
|
+
value={draft.startTime}
|
|
137
|
+
aria-label="Start time"
|
|
138
|
+
{...invalid}
|
|
139
|
+
onChange={(e) =>
|
|
140
|
+
setField({ draft, onChange }, "startTime", e.target.value)
|
|
141
|
+
}
|
|
142
|
+
className={timeClass}
|
|
143
|
+
/>
|
|
144
|
+
)}
|
|
145
|
+
<span className="text-sm text-fg-subtle">to</span>
|
|
146
|
+
<Input
|
|
147
|
+
type="date"
|
|
148
|
+
value={draft.endDate}
|
|
149
|
+
aria-label="End date"
|
|
150
|
+
min={draft.date === "" ? undefined : draft.date}
|
|
151
|
+
{...invalid}
|
|
96
152
|
onChange={(e) =>
|
|
97
|
-
setField({ draft, onChange }, "
|
|
153
|
+
setField({ draft, onChange }, "endDate", e.target.value)
|
|
98
154
|
}
|
|
99
|
-
className={
|
|
155
|
+
className={dateClass}
|
|
100
156
|
/>
|
|
101
|
-
{draft.allDay
|
|
102
|
-
<
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
onChange={(e) =>
|
|
113
|
-
setField({ draft, onChange }, "startTime", e.target.value)
|
|
114
|
-
}
|
|
115
|
-
className={cn(
|
|
116
|
-
"w-28",
|
|
117
|
-
fieldHeight,
|
|
118
|
-
backwards && "border-danger/60",
|
|
119
|
-
)}
|
|
120
|
-
/>
|
|
121
|
-
<span className="text-sm text-fg-subtle">to</span>
|
|
122
|
-
<Input
|
|
123
|
-
type="time"
|
|
124
|
-
value={draft.endTime}
|
|
125
|
-
aria-label="End time"
|
|
126
|
-
min={draft.startTime === "" ? undefined : draft.startTime}
|
|
127
|
-
aria-invalid={backwards}
|
|
128
|
-
aria-describedby={backwards ? messageId : undefined}
|
|
129
|
-
onChange={(e) =>
|
|
130
|
-
setField({ draft, onChange }, "endTime", e.target.value)
|
|
131
|
-
}
|
|
132
|
-
className={cn(
|
|
133
|
-
"w-28",
|
|
134
|
-
fieldHeight,
|
|
135
|
-
backwards && "border-danger/60",
|
|
136
|
-
)}
|
|
137
|
-
/>
|
|
138
|
-
</>
|
|
157
|
+
{!draft.allDay && (
|
|
158
|
+
<Input
|
|
159
|
+
type="time"
|
|
160
|
+
value={draft.endTime}
|
|
161
|
+
aria-label="End time"
|
|
162
|
+
{...invalid}
|
|
163
|
+
onChange={(e) =>
|
|
164
|
+
setField({ draft, onChange }, "endTime", e.target.value)
|
|
165
|
+
}
|
|
166
|
+
className={timeClass}
|
|
167
|
+
/>
|
|
139
168
|
)}
|
|
140
169
|
<label className="flex items-center gap-2 text-sm text-fg-muted">
|
|
141
170
|
<input
|
|
142
171
|
type="checkbox"
|
|
143
172
|
checked={draft.allDay}
|
|
144
|
-
onChange={(e) =>
|
|
145
|
-
setField({ draft, onChange }, "allDay", e.target.checked)
|
|
146
|
-
}
|
|
173
|
+
onChange={(e) => onChange(withAllDay(draft, e.target.checked))}
|
|
147
174
|
className="size-4 accent-current"
|
|
148
175
|
/>
|
|
149
176
|
All day
|
|
@@ -151,8 +178,9 @@ export function EventWhenField({ draft, onChange, touch }: EventFieldProps) {
|
|
|
151
178
|
</div>
|
|
152
179
|
{backwards && (
|
|
153
180
|
<p id={messageId} className="text-xs text-danger" role="alert">
|
|
154
|
-
|
|
155
|
-
|
|
181
|
+
{draft.allDay
|
|
182
|
+
? `Ends before it starts. Move the end to ${draft.date} or later.`
|
|
183
|
+
: `Ends before it starts. Move the end past ${draft.date} ${draft.startTime}, or start earlier.`}
|
|
156
184
|
</p>
|
|
157
185
|
)}
|
|
158
186
|
</div>
|
|
@@ -231,7 +231,13 @@ const thursdayProposals: CalendarProposal[] = [
|
|
|
231
231
|
const THURSDAY = "2026-06-11";
|
|
232
232
|
|
|
233
233
|
function slot(startTime: string, endTime: string): CalendarSlotPick {
|
|
234
|
-
return {
|
|
234
|
+
return {
|
|
235
|
+
date: THURSDAY,
|
|
236
|
+
endDate: THURSDAY,
|
|
237
|
+
startTime,
|
|
238
|
+
endTime,
|
|
239
|
+
allDay: false,
|
|
240
|
+
};
|
|
235
241
|
}
|
|
236
242
|
|
|
237
243
|
const thursdaySlots: CalendarSlotPick[] = [
|
|
@@ -308,6 +308,46 @@ describe("NavSidebar", () => {
|
|
|
308
308
|
});
|
|
309
309
|
});
|
|
310
310
|
|
|
311
|
+
/**
|
|
312
|
+
* An account that stopped syncing mail (#1179). It kept every mailbox it had,
|
|
313
|
+
* so the nav keeps it too — labelled, never dropped, and never an empty tree.
|
|
314
|
+
*/
|
|
315
|
+
describe("NavSidebar with mail sync off", () => {
|
|
316
|
+
const mailOff: NavAccount[] = accounts.map((account) => ({
|
|
317
|
+
...account,
|
|
318
|
+
syncedServices: ["Calendar"],
|
|
319
|
+
}));
|
|
320
|
+
const mailOn: NavAccount[] = accounts.map((account) => ({
|
|
321
|
+
...account,
|
|
322
|
+
syncedServices: ["Mail"],
|
|
323
|
+
}));
|
|
324
|
+
|
|
325
|
+
const render = (list: NavAccount[]) =>
|
|
326
|
+
renderToString(
|
|
327
|
+
createElement(NavSidebar, {
|
|
328
|
+
accounts: list,
|
|
329
|
+
selectedNavId: "personal-inbox",
|
|
330
|
+
onSelectNav: () => undefined,
|
|
331
|
+
}),
|
|
332
|
+
);
|
|
333
|
+
|
|
334
|
+
it("keeps the account and every mailbox it already synced", () => {
|
|
335
|
+
const html = render(mailOff);
|
|
336
|
+
assert.match(html, /Personal/);
|
|
337
|
+
assert.match(html, /Inbox/);
|
|
338
|
+
assert.match(html, /Travel/);
|
|
339
|
+
});
|
|
340
|
+
|
|
341
|
+
it("labels the account rather than leaving it to be guessed at", () => {
|
|
342
|
+
assert.match(render(mailOff), /mail sync off/);
|
|
343
|
+
});
|
|
344
|
+
|
|
345
|
+
it("leaves an account that syncs mail unlabelled", () => {
|
|
346
|
+
assert.doesNotMatch(render(accounts), /mail sync off/);
|
|
347
|
+
assert.doesNotMatch(render(mailOn), /mail sync off/);
|
|
348
|
+
});
|
|
349
|
+
});
|
|
350
|
+
|
|
311
351
|
describe("NavSidebar collapse persistence", () => {
|
|
312
352
|
afterEach(() => {
|
|
313
353
|
Reflect.deleteProperty(globalThis, "localStorage");
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
Folder,
|
|
11
11
|
Inbox,
|
|
12
12
|
Mails,
|
|
13
|
+
PauseCircle,
|
|
13
14
|
Send,
|
|
14
15
|
Sparkles,
|
|
15
16
|
Star,
|
|
@@ -19,6 +20,7 @@ import type { ReactNode } from "react";
|
|
|
19
20
|
import { useRef, useState } from "react";
|
|
20
21
|
import { cn } from "../lib/cn.js";
|
|
21
22
|
import { useRovingFocus } from "../lib/roving-focus.js";
|
|
23
|
+
import { ACCOUNT_SERVICE_OFF_LABEL } from "./account-service-status.js";
|
|
22
24
|
import type {
|
|
23
25
|
AppShellProps,
|
|
24
26
|
NavAccount,
|
|
@@ -274,6 +276,9 @@ function AccountNav({
|
|
|
274
276
|
const hiddenCount = folders.length - visibleFolders.length;
|
|
275
277
|
|
|
276
278
|
const status = account.status ?? "ready";
|
|
279
|
+
const mailOff =
|
|
280
|
+
account.syncedServices !== undefined &&
|
|
281
|
+
!account.syncedServices.includes("Mail");
|
|
277
282
|
const isEmpty =
|
|
278
283
|
status === "ready" && system.length === 0 && folders.length === 0;
|
|
279
284
|
|
|
@@ -303,6 +308,14 @@ function AccountNav({
|
|
|
303
308
|
<span className="text-2xs text-fg-subtle">muted</span>
|
|
304
309
|
</>
|
|
305
310
|
)}
|
|
311
|
+
{mailOff && (
|
|
312
|
+
<>
|
|
313
|
+
<PauseCircle className="size-3 shrink-0 text-fg-subtle" />
|
|
314
|
+
<span className="text-2xs text-fg-subtle">
|
|
315
|
+
{ACCOUNT_SERVICE_OFF_LABEL.Mail}
|
|
316
|
+
</span>
|
|
317
|
+
</>
|
|
318
|
+
)}
|
|
306
319
|
</button>
|
|
307
320
|
|
|
308
321
|
{accountOpen && (
|
package/src/index.ts
CHANGED
|
@@ -16,12 +16,35 @@ export {
|
|
|
16
16
|
isThreadCategory,
|
|
17
17
|
type ThreadCategory,
|
|
18
18
|
} from "./category-presentation.js";
|
|
19
|
+
export {
|
|
20
|
+
type AccountServiceChange,
|
|
21
|
+
type AccountServiceChangeCopy,
|
|
22
|
+
AccountServiceChangeDialog,
|
|
23
|
+
type AccountServiceChangeDialogProps,
|
|
24
|
+
accountServiceChangeCopy,
|
|
25
|
+
} from "./components/account-service-change-dialog.js";
|
|
19
26
|
export {
|
|
20
27
|
ACCOUNT_SERVICE_EMPTY_MESSAGE,
|
|
28
|
+
ACCOUNT_SERVICE_ROWS,
|
|
21
29
|
type AccountService,
|
|
22
30
|
AccountServiceChoice,
|
|
23
31
|
type AccountServiceChoiceProps,
|
|
32
|
+
type AccountServiceRow,
|
|
24
33
|
} from "./components/account-service-choice.js";
|
|
34
|
+
export {
|
|
35
|
+
ACCOUNT_NO_SERVICE_TOGGLES_MESSAGE,
|
|
36
|
+
ACCOUNT_SERVICE_OFF_LABEL,
|
|
37
|
+
ACCOUNT_SERVICE_OFF_MESSAGE,
|
|
38
|
+
AccountServiceOffBadge,
|
|
39
|
+
type AccountServiceOffBadgeProps,
|
|
40
|
+
AccountServiceOffNotice,
|
|
41
|
+
type AccountServiceOffNoticeProps,
|
|
42
|
+
} from "./components/account-service-status.js";
|
|
43
|
+
export {
|
|
44
|
+
type AccountServiceIntent,
|
|
45
|
+
AccountServiceToggles,
|
|
46
|
+
type AccountServiceTogglesProps,
|
|
47
|
+
} from "./components/account-service-toggles.js";
|
|
25
48
|
export {
|
|
26
49
|
AddressDisplay,
|
|
27
50
|
type AddressDisplayProps,
|
|
@@ -324,6 +347,8 @@ export {
|
|
|
324
347
|
EventTitleField,
|
|
325
348
|
EventWhenField,
|
|
326
349
|
endsBeforeStart,
|
|
350
|
+
withAllDay,
|
|
351
|
+
withStartDate,
|
|
327
352
|
} from "./components/event-editor.js";
|
|
328
353
|
export {
|
|
329
354
|
EventEditorPane,
|
|
@@ -918,6 +943,7 @@ export {
|
|
|
918
943
|
DAY_END_MINUTE,
|
|
919
944
|
DAY_START_MINUTE,
|
|
920
945
|
datesBetween,
|
|
946
|
+
daysFrom,
|
|
921
947
|
FREE_MINUTES,
|
|
922
948
|
type FreeStretch,
|
|
923
949
|
formatMinute,
|
|
@@ -930,6 +956,7 @@ export {
|
|
|
930
956
|
groupOverlapping,
|
|
931
957
|
isClearDay,
|
|
932
958
|
isEmptyDay,
|
|
959
|
+
lastDayOf,
|
|
933
960
|
mergeBusySpans,
|
|
934
961
|
minuteOfDay,
|
|
935
962
|
monthLabel,
|
package/src/lib/agenda-time.ts
CHANGED
|
@@ -46,6 +46,21 @@ export function addDays(date: string, days: number): string {
|
|
|
46
46
|
return cursor.toISOString().slice(0, 10);
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
+
export function daysFrom(from: string, to: string): number {
|
|
50
|
+
return Math.round(
|
|
51
|
+
(Date.parse(`${to}T00:00:00Z`) - Date.parse(`${from}T00:00:00Z`)) /
|
|
52
|
+
86_400_000,
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function lastDayOf(event: CalendarEventData): string {
|
|
57
|
+
const start = event.start.slice(0, 10);
|
|
58
|
+
const end = event.end.slice(0, 10);
|
|
59
|
+
if (!event.allDay) return end;
|
|
60
|
+
const last = addDays(end, -1);
|
|
61
|
+
return last < start ? start : last;
|
|
62
|
+
}
|
|
63
|
+
|
|
49
64
|
export function datesBetween(from: string, to: string): string[] {
|
|
50
65
|
const dates: string[] = [];
|
|
51
66
|
for (let cursor = from; cursor <= to; cursor = addDays(cursor, 1))
|
|
@@ -10,6 +10,7 @@ describe("pointPick", () => {
|
|
|
10
10
|
it("drafts an hour from the point that was clicked", () => {
|
|
11
11
|
assert.deepEqual(pointPick("2026-06-10T14:30:00+02:00", false), {
|
|
12
12
|
date: "2026-06-10",
|
|
13
|
+
endDate: "2026-06-10",
|
|
13
14
|
startTime: "14:30",
|
|
14
15
|
endTime: "15:30",
|
|
15
16
|
allDay: false,
|
|
@@ -30,6 +31,7 @@ describe("pointPick", () => {
|
|
|
30
31
|
it("carries an all-day point with no clock at all", () => {
|
|
31
32
|
assert.deepEqual(pointPick("2026-06-10", true), {
|
|
32
33
|
date: "2026-06-10",
|
|
34
|
+
endDate: "2026-06-10",
|
|
33
35
|
startTime: "",
|
|
34
36
|
endTime: "",
|
|
35
37
|
allDay: true,
|
|
@@ -37,10 +39,9 @@ describe("pointPick", () => {
|
|
|
37
39
|
});
|
|
38
40
|
|
|
39
41
|
it("rolls a draft that runs past midnight round the clock", () => {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
);
|
|
42
|
+
const pick = pointPick("2026-06-10T23:30:00+02:00", false);
|
|
43
|
+
assert.equal(pick.endTime, "00:30");
|
|
44
|
+
assert.equal(pick.endDate, "2026-06-11");
|
|
44
45
|
});
|
|
45
46
|
});
|
|
46
47
|
|
|
@@ -54,6 +55,7 @@ describe("rangePick", () => {
|
|
|
54
55
|
),
|
|
55
56
|
{
|
|
56
57
|
date: "2026-06-10",
|
|
58
|
+
endDate: "2026-06-10",
|
|
57
59
|
startTime: "09:00",
|
|
58
60
|
endTime: "11:30",
|
|
59
61
|
allDay: false,
|
|
@@ -61,9 +63,27 @@ describe("rangePick", () => {
|
|
|
61
63
|
);
|
|
62
64
|
});
|
|
63
65
|
|
|
64
|
-
it("
|
|
66
|
+
it("keeps a dragged range that runs past midnight on its own end day", () => {
|
|
67
|
+
assert.deepEqual(
|
|
68
|
+
rangePick(
|
|
69
|
+
"2026-06-10T22:00:00+02:00",
|
|
70
|
+
"2026-06-11T01:00:00+02:00",
|
|
71
|
+
false,
|
|
72
|
+
),
|
|
73
|
+
{
|
|
74
|
+
date: "2026-06-10",
|
|
75
|
+
endDate: "2026-06-11",
|
|
76
|
+
startTime: "22:00",
|
|
77
|
+
endTime: "01:00",
|
|
78
|
+
allDay: false,
|
|
79
|
+
},
|
|
80
|
+
);
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it("drops the clock off an all-day range and keeps its last day", () => {
|
|
65
84
|
assert.deepEqual(rangePick("2026-06-10", "2026-06-13", true), {
|
|
66
85
|
date: "2026-06-10",
|
|
86
|
+
endDate: "2026-06-12",
|
|
67
87
|
startTime: "",
|
|
68
88
|
endTime: "",
|
|
69
89
|
allDay: true,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { CalendarSlotPick } from "../components/calendar-types.js";
|
|
2
|
+
import { addDays } from "./agenda-time.js";
|
|
2
3
|
import { addMinutesToClock } from "./event-phrase.js";
|
|
3
4
|
|
|
4
5
|
/** How long a new event is when nobody said — the hour every other path starts from. */
|
|
@@ -18,9 +19,14 @@ export function rangePick(
|
|
|
18
19
|
endStr: string,
|
|
19
20
|
allDay: boolean,
|
|
20
21
|
): CalendarSlotPick {
|
|
21
|
-
if (allDay)
|
|
22
|
+
if (allDay) {
|
|
23
|
+
const date = startStr.slice(0, 10);
|
|
24
|
+
const last = addDays(endStr.slice(0, 10), -1);
|
|
25
|
+
return { ...allDayPick(startStr), endDate: last < date ? date : last };
|
|
26
|
+
}
|
|
22
27
|
return {
|
|
23
28
|
date: startStr.slice(0, 10),
|
|
29
|
+
endDate: endStr.slice(0, 10),
|
|
24
30
|
startTime: startStr.slice(11, 16),
|
|
25
31
|
endTime: endStr.slice(11, 16),
|
|
26
32
|
allDay: false,
|
|
@@ -31,10 +37,13 @@ export function rangePick(
|
|
|
31
37
|
export function pointPick(dateStr: string, allDay: boolean): CalendarSlotPick {
|
|
32
38
|
if (allDay) return allDayPick(dateStr);
|
|
33
39
|
const startTime = dateStr.slice(11, 16);
|
|
40
|
+
const endTime = addMinutesToClock(startTime, DRAFT_MINUTES);
|
|
41
|
+
const date = dateStr.slice(0, 10);
|
|
34
42
|
return {
|
|
35
|
-
date
|
|
43
|
+
date,
|
|
44
|
+
endDate: endTime < startTime ? addDays(date, 1) : date,
|
|
36
45
|
startTime,
|
|
37
|
-
endTime
|
|
46
|
+
endTime,
|
|
38
47
|
allDay: false,
|
|
39
48
|
};
|
|
40
49
|
}
|
|
@@ -42,6 +51,7 @@ export function pointPick(dateStr: string, allDay: boolean): CalendarSlotPick {
|
|
|
42
51
|
function allDayPick(dateStr: string): CalendarSlotPick {
|
|
43
52
|
return {
|
|
44
53
|
date: dateStr.slice(0, 10),
|
|
54
|
+
endDate: dateStr.slice(0, 10),
|
|
45
55
|
startTime: "",
|
|
46
56
|
endTime: "",
|
|
47
57
|
allDay: true,
|