Skip to content

Commit 163358f

Browse files
committed
fix: issues withg frontend after umbraco 17 upgrade
1 parent 30bf0fe commit 163358f

File tree

3 files changed

+36
-20
lines changed

3 files changed

+36
-20
lines changed

frontend/src/data/parseUtcAsCst.ts

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,45 @@
1-
import { parse } from 'date-fns';
21
import { TZDate } from '@date-fns/tz';
32
import { CST_TZ } from '@/config';
43

54
// Umbraco doesn't save dates with timezone information so we have to manually fix it
65
export function parseUtcAsCst(dateStr: string): Date {
7-
const utcDate = parse(dateStr, "yyyy-MM-dd'T'HH:mm:ss'Z'", new Date());
6+
const match = dateStr.match(
7+
/^(\d{4})-(\d{2})-(\d{2})(?:T(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,7}))?)?)?(?:Z|[+-]\d{2}:\d{2})?$/,
8+
);
9+
10+
if (!match) {
11+
return new Date(Number.NaN);
12+
}
13+
14+
const [
15+
,
16+
yearStr,
17+
monthStr,
18+
dayStr,
19+
hourStr,
20+
minuteStr,
21+
secondStr,
22+
millisecondStr,
23+
] = match;
24+
25+
const year = Number(yearStr);
26+
const month = Number(monthStr) - 1;
27+
const day = Number(dayStr);
28+
const hour = Number(hourStr ?? 0);
29+
const minute = Number(minuteStr ?? 0);
30+
const second = Number(secondStr ?? 0);
31+
const millisecond = Number(
32+
(millisecondStr ?? '0').slice(0, 3).padEnd(3, '0'),
33+
);
834

935
return new TZDate(
10-
utcDate.getFullYear(),
11-
utcDate.getMonth(),
12-
utcDate.getDate(),
13-
utcDate.getHours(),
14-
utcDate.getMinutes(),
15-
utcDate.getSeconds(),
16-
utcDate.getMilliseconds(),
36+
year,
37+
month,
38+
day,
39+
hour,
40+
minute,
41+
second,
42+
millisecond,
1743
CST_TZ,
1844
);
1945
}

frontend/src/data/umbraco/defaultApiSchema.d.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ export interface paths {
2828
/** @description OK */
2929
200: {
3030
headers: {
31-
/** @description The list of notifications produced during the request. */
32-
"Umb-Notifications"?: components["schemas"]["NotificationHeaderModel"][] | null;
3331
[name: string]: unknown;
3432
};
3533
content: {
@@ -114,8 +112,6 @@ export interface paths {
114112
/** @description OK */
115113
200: {
116114
headers: {
117-
/** @description The list of notifications produced during the request. */
118-
"Umb-Notifications"?: components["schemas"]["NotificationHeaderModel"][] | null;
119115
[name: string]: unknown;
120116
};
121117
content: {
@@ -165,13 +161,6 @@ export interface components {
165161
name?: string | null;
166162
email?: string | null;
167163
};
168-
/** @enum {string} */
169-
EventMessageTypeModel: "Default" | "Info" | "Error" | "Success" | "Warning";
170-
NotificationHeaderModel: {
171-
message: string;
172-
category: string;
173-
type: components["schemas"]["EventMessageTypeModel"];
174-
};
175164
SessionFeedbackResponseDto: {
176165
/** Format: uuid */
177166
id: string;

frontend/src/data/umbraco/deliveryApiSchema.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ export interface components {
175175
readonly destinationType?: string | null;
176176
readonly route?: components["schemas"]["ApiContentRouteModel"] | null;
177177
linkType: components["schemas"]["LinkTypeModel"];
178+
readonly culture?: string | null;
178179
};
179180
ConferenceContentModel: {
180181
properties?: components["schemas"]["ConferencePropertiesModel"];

0 commit comments

Comments
 (0)