@antlur/backstage 1.12.16 → 1.13.0
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/cli/actions/sync-blocks.d.ts.map +1 -1
- package/dist/cli/actions/sync-blocks.js +1 -0
- package/dist/cli/cli.js +0 -0
- package/dist/client.d.ts +6 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +9 -0
- package/dist/endpoints/blocks.d.ts +5 -3
- package/dist/endpoints/blocks.d.ts.map +1 -1
- package/dist/endpoints/frontstage.d.ts +9 -0
- package/dist/endpoints/frontstage.d.ts.map +1 -0
- package/dist/endpoints/frontstage.js +32 -0
- package/dist/endpoints/layouts.d.ts +5 -3
- package/dist/endpoints/layouts.d.ts.map +1 -1
- package/dist/endpoints/modules.d.ts +7 -0
- package/dist/endpoints/modules.d.ts.map +1 -0
- package/dist/endpoints/modules.js +11 -0
- package/dist/endpoints/reviews.d.ts +18 -0
- package/dist/endpoints/reviews.d.ts.map +1 -0
- package/dist/endpoints/reviews.js +30 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/studio/define-block.d.ts +2 -0
- package/dist/studio/define-block.d.ts.map +1 -1
- package/dist/studio/types/block.d.ts +9 -0
- package/dist/studio/types/block.d.ts.map +1 -1
- package/dist/types/account-block.d.ts +17 -1
- package/dist/types/account-block.d.ts.map +1 -1
- package/dist/types/account-layout.d.ts +29 -9
- package/dist/types/account-layout.d.ts.map +1 -1
- package/dist/types/account-module.d.ts +26 -0
- package/dist/types/account-module.d.ts.map +1 -0
- package/dist/types/account-module.js +12 -0
- package/dist/types/frontstage.d.ts +213 -0
- package/dist/types/frontstage.d.ts.map +1 -0
- package/dist/types/frontstage.js +1 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +1 -1
- package/dist/types/location.d.ts +1 -0
- package/dist/types/location.d.ts.map +1 -1
- package/dist/types/review.d.ts +17 -0
- package/dist/types/review.d.ts.map +1 -0
- package/dist/types/review.js +1 -0
- package/dist/util/special-hours.d.ts +1 -1
- package/dist/util/special-hours.d.ts.map +1 -1
- package/dist/util/special-hours.js +8 -7
- package/package.json +1 -1
- package/readme.md +14 -0
- package/src/cli/actions/sync-blocks.ts +1 -0
- package/src/client.ts +9 -0
- package/src/endpoints/blocks.ts +5 -3
- package/src/endpoints/frontstage.ts +50 -0
- package/src/endpoints/layouts.ts +5 -3
- package/src/endpoints/modules.ts +14 -0
- package/src/endpoints/reviews.ts +57 -0
- package/src/index.ts +3 -0
- package/src/studio/define-block.ts +2 -0
- package/src/studio/types/block.ts +10 -0
- package/src/types/account-block.ts +22 -1
- package/src/types/account-layout.ts +32 -9
- package/src/types/account-module.ts +38 -0
- package/src/types/frontstage.ts +254 -0
- package/src/types/index.ts +4 -0
- package/src/types/location.ts +1 -0
- package/src/types/review.ts +16 -0
- package/src/util/special-hours.ts +10 -6
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { BlockSchema, BlockDefinition, BlockComponent, Field } from "./types";
|
|
2
|
+
import type { BlockFrontstageConfig } from "./types/block";
|
|
2
3
|
|
|
3
4
|
export function defineBlock<TFields extends readonly Field[]>(options: {
|
|
4
5
|
name: string;
|
|
5
6
|
slug: string;
|
|
6
7
|
description?: string;
|
|
7
8
|
schema: BlockSchema<TFields>;
|
|
9
|
+
frontstage?: BlockFrontstageConfig;
|
|
8
10
|
component: BlockComponent<BlockSchema<TFields>>;
|
|
9
11
|
}): BlockDefinition<TFields> {
|
|
10
12
|
// Runtime validation
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Field, FieldType, FieldTypeToValue } from "./field";
|
|
2
2
|
import { Entry } from "../../types/entry";
|
|
3
|
+
import type { FrontstageStandardBlockType, FrontstageStandardBlockVariant } from "../../types/frontstage";
|
|
3
4
|
|
|
4
5
|
type Nullable<T> = T | null;
|
|
5
6
|
|
|
@@ -28,6 +29,7 @@ export interface BlockDefinition<TFields extends readonly Field[]> {
|
|
|
28
29
|
slug: string;
|
|
29
30
|
description?: string;
|
|
30
31
|
schema: BlockSchema<TFields>;
|
|
32
|
+
frontstage?: BlockFrontstageConfig;
|
|
31
33
|
component: BlockComponent<BlockSchema<TFields>>;
|
|
32
34
|
}
|
|
33
35
|
|
|
@@ -35,6 +37,14 @@ export interface BlockProperties {
|
|
|
35
37
|
customClassName?: string;
|
|
36
38
|
}
|
|
37
39
|
|
|
40
|
+
export interface BlockFrontstageConfig {
|
|
41
|
+
enabled?: boolean;
|
|
42
|
+
type?: FrontstageStandardBlockType | string;
|
|
43
|
+
defaultVariant?: FrontstageStandardBlockVariant | string;
|
|
44
|
+
variants?: Array<FrontstageStandardBlockVariant | string>;
|
|
45
|
+
category?: string;
|
|
46
|
+
}
|
|
47
|
+
|
|
38
48
|
export interface BuilderBlock<TSchema extends BlockSchema<readonly Field[]>> {
|
|
39
49
|
id: string;
|
|
40
50
|
type: string;
|
|
@@ -1,9 +1,30 @@
|
|
|
1
|
+
import type { FrontstageBlockDefinition } from "./frontstage";
|
|
2
|
+
import type { Field } from "../studio/types/field";
|
|
3
|
+
|
|
4
|
+
export interface AccountBlockSchema {
|
|
5
|
+
fields?: readonly Field[];
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface AccountBlockFrontstageConfig {
|
|
9
|
+
enabled?: boolean;
|
|
10
|
+
type?: FrontstageBlockDefinition["frontstage"] extends infer T
|
|
11
|
+
? T extends { type: infer Type }
|
|
12
|
+
? Type
|
|
13
|
+
: string
|
|
14
|
+
: string;
|
|
15
|
+
defaultVariant?: string;
|
|
16
|
+
variants?: string[];
|
|
17
|
+
category?: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
1
20
|
export interface AccountBlock {
|
|
2
21
|
id: string;
|
|
3
22
|
account_id: string;
|
|
4
23
|
slug: string;
|
|
5
24
|
name: string;
|
|
6
|
-
|
|
25
|
+
description?: string | null;
|
|
26
|
+
schema: AccountBlockSchema;
|
|
27
|
+
frontstage?: AccountBlockFrontstageConfig | null;
|
|
7
28
|
created_at: string;
|
|
8
29
|
updated_at: string;
|
|
9
30
|
}
|
|
@@ -1,14 +1,37 @@
|
|
|
1
|
+
import type { Field } from "../studio/types/field";
|
|
2
|
+
import type { FrontstageBlock, FrontstageNavItem, FrontstageTheme } from "./frontstage";
|
|
3
|
+
|
|
4
|
+
export interface AccountLayoutSchema {
|
|
5
|
+
fields: Field[];
|
|
6
|
+
[key: string]: unknown;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface AccountLayoutValues {
|
|
10
|
+
theme?: Partial<FrontstageTheme["layout"]>;
|
|
11
|
+
navigation?: {
|
|
12
|
+
primary?: FrontstageNavItem[];
|
|
13
|
+
footer?: FrontstageNavItem[];
|
|
14
|
+
};
|
|
15
|
+
regions?: {
|
|
16
|
+
beforeHeader?: FrontstageBlock[];
|
|
17
|
+
afterHeader?: FrontstageBlock[];
|
|
18
|
+
beforeMain?: FrontstageBlock[];
|
|
19
|
+
afterMain?: FrontstageBlock[];
|
|
20
|
+
beforeFooter?: FrontstageBlock[];
|
|
21
|
+
footer?: FrontstageBlock[];
|
|
22
|
+
afterFooter?: FrontstageBlock[];
|
|
23
|
+
};
|
|
24
|
+
[key: string]: unknown;
|
|
25
|
+
}
|
|
26
|
+
|
|
1
27
|
export interface AccountLayout {
|
|
2
28
|
id: string;
|
|
29
|
+
account_id?: string;
|
|
3
30
|
name: string;
|
|
4
31
|
slug: string;
|
|
5
|
-
schema:
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
[key: string]: any;
|
|
11
|
-
}>;
|
|
12
|
-
};
|
|
13
|
-
data: Record<string, any>;
|
|
32
|
+
schema: AccountLayoutSchema;
|
|
33
|
+
values?: AccountLayoutValues;
|
|
34
|
+
data?: AccountLayoutValues;
|
|
35
|
+
created_at?: string;
|
|
36
|
+
updated_at?: string;
|
|
14
37
|
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export type AccountModuleKey =
|
|
2
|
+
| "core.modules"
|
|
3
|
+
| "core.media"
|
|
4
|
+
| "core.change_management"
|
|
5
|
+
| "core.deployments"
|
|
6
|
+
| "cms.site_builder"
|
|
7
|
+
| "cms.custom_blocks"
|
|
8
|
+
| "cms.custom_layouts"
|
|
9
|
+
| "restaurant.menus"
|
|
10
|
+
| "engagement.events"
|
|
11
|
+
| "engagement.press"
|
|
12
|
+
| (string & {});
|
|
13
|
+
|
|
14
|
+
export interface AccountModule {
|
|
15
|
+
key: AccountModuleKey;
|
|
16
|
+
label: string;
|
|
17
|
+
category: string;
|
|
18
|
+
description: string;
|
|
19
|
+
default_enabled: boolean;
|
|
20
|
+
dependencies: AccountModuleKey[];
|
|
21
|
+
plan_entitlement: string | null;
|
|
22
|
+
active: boolean;
|
|
23
|
+
entitled: boolean;
|
|
24
|
+
enabled: boolean;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export const AccountModules = {
|
|
28
|
+
CoreModules: "core.modules",
|
|
29
|
+
CoreMedia: "core.media",
|
|
30
|
+
CoreChangeManagement: "core.change_management",
|
|
31
|
+
CoreDeployments: "core.deployments",
|
|
32
|
+
CmsSiteBuilder: "cms.site_builder",
|
|
33
|
+
CmsCustomBlocks: "cms.custom_blocks",
|
|
34
|
+
CmsCustomLayouts: "cms.custom_layouts",
|
|
35
|
+
RestaurantMenus: "restaurant.menus",
|
|
36
|
+
EngagementEvents: "engagement.events",
|
|
37
|
+
EngagementPress: "engagement.press",
|
|
38
|
+
} as const satisfies Record<string, AccountModuleKey>;
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
export type FrontstageContractVersion = "2026-05-frontstage-v1";
|
|
2
|
+
|
|
3
|
+
export interface FrontstageImage {
|
|
4
|
+
url: string;
|
|
5
|
+
alt?: string;
|
|
6
|
+
width?: number;
|
|
7
|
+
height?: number;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface FrontstageNavItem {
|
|
11
|
+
label: string;
|
|
12
|
+
href: string;
|
|
13
|
+
variant?: "link" | "button";
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export type FrontstageThemePreset = "classic-restaurant" | "premium-hospitality" | "fast-casual" | (string & {});
|
|
17
|
+
export type FrontstageAlertType = "banner" | "popup";
|
|
18
|
+
export type FrontstageAlertPosition = "top" | "bottom" | "center" | "bottom-right";
|
|
19
|
+
|
|
20
|
+
export interface FrontstageHourRow {
|
|
21
|
+
label: string;
|
|
22
|
+
value: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface FrontstageSpecialHour {
|
|
26
|
+
id?: string;
|
|
27
|
+
date: string;
|
|
28
|
+
label: string;
|
|
29
|
+
title?: string;
|
|
30
|
+
value?: string;
|
|
31
|
+
notes?: string;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface FrontstageAlert {
|
|
35
|
+
id: string;
|
|
36
|
+
title: string;
|
|
37
|
+
type: FrontstageAlertType;
|
|
38
|
+
position?: FrontstageAlertPosition;
|
|
39
|
+
dismissible: boolean;
|
|
40
|
+
content?: string;
|
|
41
|
+
media?: FrontstageImage;
|
|
42
|
+
cta?: {
|
|
43
|
+
label: string;
|
|
44
|
+
href: string;
|
|
45
|
+
};
|
|
46
|
+
analytics?: {
|
|
47
|
+
name?: string;
|
|
48
|
+
category?: string;
|
|
49
|
+
label?: string;
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface FrontstageBlock<TProps = Record<string, unknown>> {
|
|
54
|
+
id: string;
|
|
55
|
+
type: FrontstageStandardBlockType | string;
|
|
56
|
+
variant?: string;
|
|
57
|
+
props: TProps;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export type FrontstageStandardBlockType =
|
|
61
|
+
| "hero"
|
|
62
|
+
| "content"
|
|
63
|
+
| "feature-grid"
|
|
64
|
+
| "gallery"
|
|
65
|
+
| "media-feature"
|
|
66
|
+
| "menu-preview"
|
|
67
|
+
| "menu-section"
|
|
68
|
+
| "locations"
|
|
69
|
+
| "hours"
|
|
70
|
+
| "ordering"
|
|
71
|
+
| "cta"
|
|
72
|
+
| "events"
|
|
73
|
+
| "event-spotlight"
|
|
74
|
+
| "private-events"
|
|
75
|
+
| "contact-form"
|
|
76
|
+
| "testimonials"
|
|
77
|
+
| "press"
|
|
78
|
+
| "awards"
|
|
79
|
+
| "reviews"
|
|
80
|
+
| "newsletter"
|
|
81
|
+
| "faq"
|
|
82
|
+
| "html-embed";
|
|
83
|
+
|
|
84
|
+
export type FrontstageStandardBlockVariant =
|
|
85
|
+
| "default"
|
|
86
|
+
| "full-bleed-image"
|
|
87
|
+
| "background-video"
|
|
88
|
+
| "image-collage"
|
|
89
|
+
| "masonry"
|
|
90
|
+
| "carousel"
|
|
91
|
+
| "editorial-strip"
|
|
92
|
+
| "mixed-media"
|
|
93
|
+
| "full-width"
|
|
94
|
+
| "inline";
|
|
95
|
+
|
|
96
|
+
export interface FrontstageTheme {
|
|
97
|
+
preset?: FrontstageThemePreset;
|
|
98
|
+
colors: {
|
|
99
|
+
background: string;
|
|
100
|
+
foreground: string;
|
|
101
|
+
primary: string;
|
|
102
|
+
primaryForeground: string;
|
|
103
|
+
muted: string;
|
|
104
|
+
mutedForeground: string;
|
|
105
|
+
border: string;
|
|
106
|
+
secondary?: string;
|
|
107
|
+
secondaryForeground?: string;
|
|
108
|
+
accent?: string;
|
|
109
|
+
accentForeground?: string;
|
|
110
|
+
topbar?: string;
|
|
111
|
+
topbarForeground?: string;
|
|
112
|
+
};
|
|
113
|
+
fonts: {
|
|
114
|
+
heading: FrontstageFont;
|
|
115
|
+
body: FrontstageFont;
|
|
116
|
+
};
|
|
117
|
+
radius: string;
|
|
118
|
+
layout: {
|
|
119
|
+
container: "narrow" | "default" | "wide" | "full";
|
|
120
|
+
header: "default" | "centered-logo" | "split-nav" | "minimal";
|
|
121
|
+
footer: "simple" | "multi-column" | "location-heavy";
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export interface FrontstageFont {
|
|
126
|
+
source: "system" | "google" | "custom";
|
|
127
|
+
name: string;
|
|
128
|
+
family: string;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export interface FrontstageSiteResponse {
|
|
132
|
+
contractVersion: FrontstageContractVersion;
|
|
133
|
+
site: {
|
|
134
|
+
id: string;
|
|
135
|
+
accountId: string;
|
|
136
|
+
name: string;
|
|
137
|
+
baseUrl: string;
|
|
138
|
+
locale: string;
|
|
139
|
+
timezone: string;
|
|
140
|
+
description?: string | null;
|
|
141
|
+
status: "draft" | "published" | "archived";
|
|
142
|
+
};
|
|
143
|
+
brand: {
|
|
144
|
+
logo?: FrontstageImage;
|
|
145
|
+
favicon?: { url: string };
|
|
146
|
+
social?: Record<string, string>;
|
|
147
|
+
};
|
|
148
|
+
contact?: {
|
|
149
|
+
address?: string;
|
|
150
|
+
mapUrl?: string;
|
|
151
|
+
phone?: string;
|
|
152
|
+
email?: string;
|
|
153
|
+
neighborhood?: string;
|
|
154
|
+
hours?: FrontstageHourRow[];
|
|
155
|
+
specialHours?: FrontstageSpecialHour[];
|
|
156
|
+
};
|
|
157
|
+
theme: FrontstageTheme;
|
|
158
|
+
navigation: {
|
|
159
|
+
primary: FrontstageNavItem[];
|
|
160
|
+
footer: FrontstageNavItem[];
|
|
161
|
+
};
|
|
162
|
+
alerts?: FrontstageAlert[];
|
|
163
|
+
integrations?: {
|
|
164
|
+
analytics?: { gtmId?: string };
|
|
165
|
+
ordering?: { provider?: string; url?: string };
|
|
166
|
+
reservations?: { provider?: string; url?: string };
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
export interface FrontstageResolvedLayout {
|
|
171
|
+
id: string | null;
|
|
172
|
+
name: string | null;
|
|
173
|
+
slug: string | null;
|
|
174
|
+
source?: "page" | "site" | "fallback" | "preview" | "override" | null;
|
|
175
|
+
theme?: Partial<FrontstageTheme["layout"]>;
|
|
176
|
+
navigation?: {
|
|
177
|
+
primary?: FrontstageNavItem[];
|
|
178
|
+
footer?: FrontstageNavItem[];
|
|
179
|
+
};
|
|
180
|
+
regions?: {
|
|
181
|
+
beforeHeader?: FrontstageBlock[];
|
|
182
|
+
afterHeader?: FrontstageBlock[];
|
|
183
|
+
beforeMain?: FrontstageBlock[];
|
|
184
|
+
afterMain?: FrontstageBlock[];
|
|
185
|
+
beforeFooter?: FrontstageBlock[];
|
|
186
|
+
footer?: FrontstageBlock[];
|
|
187
|
+
afterFooter?: FrontstageBlock[];
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
export interface FrontstageSeo {
|
|
192
|
+
title: string;
|
|
193
|
+
description?: string;
|
|
194
|
+
canonical?: string;
|
|
195
|
+
noindex?: boolean;
|
|
196
|
+
image?: FrontstageImage;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
export interface FrontstagePageResponse {
|
|
200
|
+
contractVersion: FrontstageContractVersion;
|
|
201
|
+
page: {
|
|
202
|
+
id: string;
|
|
203
|
+
title: string;
|
|
204
|
+
slug: string;
|
|
205
|
+
status: "draft" | "published" | "archived";
|
|
206
|
+
seo: FrontstageSeo;
|
|
207
|
+
blocks: FrontstageBlock[];
|
|
208
|
+
layout?: FrontstageResolvedLayout;
|
|
209
|
+
alerts?: FrontstageAlert[];
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
export interface FrontstageRoute {
|
|
214
|
+
id?: string | null;
|
|
215
|
+
path: string;
|
|
216
|
+
slug?: string;
|
|
217
|
+
type?: string | null;
|
|
218
|
+
model?: string | null;
|
|
219
|
+
modelId?: string | null;
|
|
220
|
+
title?: string | null;
|
|
221
|
+
lastModified?: string | null;
|
|
222
|
+
changeFrequency?: "always" | "hourly" | "daily" | "weekly" | "monthly" | "yearly" | "never";
|
|
223
|
+
priority?: number;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
export interface FrontstageRoutesResponse {
|
|
227
|
+
routes: FrontstageRoute[];
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
export interface FrontstageBlockDefinition {
|
|
231
|
+
id: string;
|
|
232
|
+
name: string;
|
|
233
|
+
type: FrontstageStandardBlockType | string;
|
|
234
|
+
category: string;
|
|
235
|
+
description: string;
|
|
236
|
+
variants: FrontstageStandardBlockVariant[] | string[];
|
|
237
|
+
fields: unknown[];
|
|
238
|
+
frontstage?: {
|
|
239
|
+
enabled: boolean;
|
|
240
|
+
type: FrontstageStandardBlockType | string;
|
|
241
|
+
defaultVariant?: FrontstageStandardBlockVariant | string;
|
|
242
|
+
variants: FrontstageStandardBlockVariant[] | string[];
|
|
243
|
+
category: string;
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
export interface FrontstageBlocksResponse {
|
|
248
|
+
blocks: FrontstageBlockDefinition[];
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
export interface FrontstagePreviewParams {
|
|
252
|
+
preview?: boolean;
|
|
253
|
+
previewId?: string;
|
|
254
|
+
}
|
package/src/types/index.ts
CHANGED
|
@@ -5,6 +5,7 @@ export type * from "./api";
|
|
|
5
5
|
export type * from "./blueprint";
|
|
6
6
|
export type * from "./entry";
|
|
7
7
|
export type * from "./event";
|
|
8
|
+
export type * from "./frontstage";
|
|
8
9
|
export type * from "./instagram";
|
|
9
10
|
export type * from "./location";
|
|
10
11
|
export type * from "./media-item";
|
|
@@ -12,10 +13,13 @@ export type * from "./menu-category-item";
|
|
|
12
13
|
export type * from "./menu-category";
|
|
13
14
|
export type * from "./menu-item";
|
|
14
15
|
export type * from "./menu";
|
|
16
|
+
export { AccountModules } from "./account-module";
|
|
17
|
+
export type * from "./account-module";
|
|
15
18
|
export type * from "./navigation";
|
|
16
19
|
export type * from "./page";
|
|
17
20
|
export type * from "./press";
|
|
18
21
|
export type * from "./redirect";
|
|
22
|
+
export type * from "./review";
|
|
19
23
|
export type * from "./route";
|
|
20
24
|
export type * from "./website";
|
|
21
25
|
|
package/src/types/location.ts
CHANGED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface Review {
|
|
2
|
+
id: number;
|
|
3
|
+
account_id: string;
|
|
4
|
+
location_id: string | null;
|
|
5
|
+
external_id: string;
|
|
6
|
+
source: string;
|
|
7
|
+
author_name: string;
|
|
8
|
+
author_avatar: string | null;
|
|
9
|
+
rating: number;
|
|
10
|
+
text: string | null;
|
|
11
|
+
url: string | null;
|
|
12
|
+
responded_at: string | null;
|
|
13
|
+
published_at: string | null;
|
|
14
|
+
created_at: string;
|
|
15
|
+
updated_at: string;
|
|
16
|
+
}
|
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
import type { Location } from "../types";
|
|
2
2
|
import { DateTime } from "luxon";
|
|
3
3
|
|
|
4
|
-
export function getSpecialHoursFromLocation(location: Location): any[] {
|
|
4
|
+
export function getSpecialHoursFromLocation(location: Location, noticeDays?: number): any[] {
|
|
5
5
|
if (!location.special_hours) return [];
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
if (location.timezone) now.setZone(location.timezone);
|
|
7
|
+
const now = (location.timezone ? DateTime.now().setZone(location.timezone) : DateTime.now()).startOf("day");
|
|
8
|
+
const lastVisibleDate = typeof noticeDays === "number" ? now.plus({ days: Math.max(0, noticeDays) }) : null;
|
|
10
9
|
|
|
11
10
|
const specialHours = location.special_hours.filter((specialHour) => {
|
|
12
|
-
const specialHourDate = DateTime.fromISO(specialHour.date);
|
|
13
|
-
|
|
11
|
+
const specialHourDate = DateTime.fromISO(specialHour.date, { zone: location.timezone || undefined }).startOf("day");
|
|
12
|
+
|
|
13
|
+
if (specialHourDate < now) {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return lastVisibleDate ? specialHourDate <= lastVisibleDate : true;
|
|
14
18
|
});
|
|
15
19
|
|
|
16
20
|
// sort by date
|