foundry-component-library 0.1.14 → 0.2.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/lib/components/cases/Items/index.tsx +6 -1
- package/lib/queries/client.ts +15 -1
- package/lib/queries/getCaseById.ts +284 -0
- package/lib/queries/getCasesPage.ts +4 -0
- package/lib/queries/getHubBySlug.ts +1 -1
- package/lib/queries/index.ts +2 -0
- package/lib/types/index.ts +2 -0
- package/package.json +1 -1
|
@@ -83,7 +83,11 @@ function Cases({
|
|
|
83
83
|
|
|
84
84
|
return (
|
|
85
85
|
<div key={item.id} className={styles.case}>
|
|
86
|
-
<Link
|
|
86
|
+
<Link
|
|
87
|
+
href={`/cases/${
|
|
88
|
+
item.status !== "draft" ? item.slug : `preview/${item.id}`
|
|
89
|
+
}`}
|
|
90
|
+
>
|
|
87
91
|
{thumbnailVideo && (
|
|
88
92
|
<Video
|
|
89
93
|
url={thumbnailVideo.mediaItemUrl}
|
|
@@ -109,6 +113,7 @@ function Cases({
|
|
|
109
113
|
<div className={styles.texts}>
|
|
110
114
|
<div>
|
|
111
115
|
<h3 className={styles.title}>{item.title}</h3>
|
|
116
|
+
{item.status === "draft" && <div>DRAFT</div>}
|
|
112
117
|
<div className={styles.caption}>{item.case.caption}</div>
|
|
113
118
|
</div>
|
|
114
119
|
<div className={styles.arrowWrapper}>
|
package/lib/queries/client.ts
CHANGED
|
@@ -1,6 +1,20 @@
|
|
|
1
1
|
import { GraphQLClient } from "graphql-request";
|
|
2
2
|
|
|
3
3
|
const baseUrl = process.env.WORDPRESS_URL || "https://data.foundry.ch";
|
|
4
|
-
|
|
4
|
+
|
|
5
|
+
const headers: Record<string, string> = {
|
|
6
|
+
"Content-Type": "application/json",
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
if (process.env.WP_PREVIEW_USER && process.env.WP_PREVIEW_PASS) {
|
|
10
|
+
const auth = Buffer.from(`admin:${process.env.WP_PREVIEW_PASS}`).toString(
|
|
11
|
+
"base64"
|
|
12
|
+
);
|
|
13
|
+
headers["Authorization"] = `Basic ${auth}`;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const graphqlClient = new GraphQLClient(`${baseUrl}/graphql`, {
|
|
17
|
+
headers,
|
|
18
|
+
});
|
|
5
19
|
|
|
6
20
|
export default graphqlClient;
|
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
import { gql } from "graphql-request";
|
|
2
|
+
import { Case } from "../../lib/types";
|
|
3
|
+
import client from "./client";
|
|
4
|
+
import { type ContactPage } from "./getContactPage";
|
|
5
|
+
|
|
6
|
+
type HomePage = {
|
|
7
|
+
customFieldsBerlin: {
|
|
8
|
+
awardsHeading?: string;
|
|
9
|
+
awards?: Array<{
|
|
10
|
+
image: {
|
|
11
|
+
sourceUrl: string;
|
|
12
|
+
};
|
|
13
|
+
heading: string;
|
|
14
|
+
text: string;
|
|
15
|
+
}>;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export default async function getCaseBySlug({
|
|
20
|
+
id,
|
|
21
|
+
language,
|
|
22
|
+
}: {
|
|
23
|
+
id: string;
|
|
24
|
+
language: string;
|
|
25
|
+
}): Promise<{
|
|
26
|
+
case: Case;
|
|
27
|
+
contactPage: ContactPage;
|
|
28
|
+
homePage: HomePage;
|
|
29
|
+
}> {
|
|
30
|
+
const homePage = language === "DE" ? "home-berlin-de" : "home-berlin";
|
|
31
|
+
const contactPage = language === "DE" ? "contact-de" : "contact";
|
|
32
|
+
|
|
33
|
+
const query = gql`
|
|
34
|
+
query GetCaseBySlug($id: ID!) {
|
|
35
|
+
case(id: $id, idType: ID) {
|
|
36
|
+
id
|
|
37
|
+
title
|
|
38
|
+
status
|
|
39
|
+
case {
|
|
40
|
+
caption
|
|
41
|
+
mainImage {
|
|
42
|
+
sourceUrl
|
|
43
|
+
}
|
|
44
|
+
details {
|
|
45
|
+
heading
|
|
46
|
+
text
|
|
47
|
+
}
|
|
48
|
+
awards {
|
|
49
|
+
heading
|
|
50
|
+
text
|
|
51
|
+
image {
|
|
52
|
+
sourceUrl
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
relatedCases {
|
|
56
|
+
__typename
|
|
57
|
+
... on Case {
|
|
58
|
+
id
|
|
59
|
+
title
|
|
60
|
+
uri
|
|
61
|
+
case {
|
|
62
|
+
thumbnailImage{
|
|
63
|
+
sourceUrl
|
|
64
|
+
}
|
|
65
|
+
mainImage {
|
|
66
|
+
sourceUrl
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
content {
|
|
72
|
+
... on Case_Case_Content_Quote {
|
|
73
|
+
fieldGroupName
|
|
74
|
+
name
|
|
75
|
+
position
|
|
76
|
+
text
|
|
77
|
+
}
|
|
78
|
+
... on Case_Case_Content_Results {
|
|
79
|
+
fieldGroupName
|
|
80
|
+
context
|
|
81
|
+
approach
|
|
82
|
+
outcome
|
|
83
|
+
}
|
|
84
|
+
... on Case_Case_Content_Numbers {
|
|
85
|
+
fieldGroupName
|
|
86
|
+
number1
|
|
87
|
+
text1
|
|
88
|
+
number2
|
|
89
|
+
text2
|
|
90
|
+
number3
|
|
91
|
+
text3
|
|
92
|
+
}
|
|
93
|
+
... on Case_Case_Content_Video {
|
|
94
|
+
fieldGroupName
|
|
95
|
+
autoplay
|
|
96
|
+
poster {
|
|
97
|
+
sourceUrl
|
|
98
|
+
}
|
|
99
|
+
caption
|
|
100
|
+
video
|
|
101
|
+
ratio
|
|
102
|
+
}
|
|
103
|
+
... on Case_Case_Content_FullWidthImage {
|
|
104
|
+
fieldGroupName
|
|
105
|
+
fullWidth
|
|
106
|
+
image {
|
|
107
|
+
sourceUrl
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
... on Case_Case_Content_CenterColumn {
|
|
111
|
+
fieldGroupName
|
|
112
|
+
text
|
|
113
|
+
}
|
|
114
|
+
... on Case_Case_Content_Twocolumns {
|
|
115
|
+
fieldGroupName
|
|
116
|
+
left {
|
|
117
|
+
... on Case_Case_Content_Twocolumns_Left_Image {
|
|
118
|
+
fieldGroupName
|
|
119
|
+
image {
|
|
120
|
+
sourceUrl
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
... on Case_Case_Content_Twocolumns_Left_Text {
|
|
124
|
+
fieldGroupName
|
|
125
|
+
text
|
|
126
|
+
}
|
|
127
|
+
... on Case_Case_Content_Twocolumns_Left_Video {
|
|
128
|
+
fieldGroupName
|
|
129
|
+
autoplay
|
|
130
|
+
poster {
|
|
131
|
+
sourceUrl
|
|
132
|
+
}
|
|
133
|
+
caption
|
|
134
|
+
video
|
|
135
|
+
ratio
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
right {
|
|
139
|
+
... on Case_Case_Content_Twocolumns_Right_Image {
|
|
140
|
+
fieldGroupName
|
|
141
|
+
image {
|
|
142
|
+
sourceUrl
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
... on Case_Case_Content_Twocolumns_Right_Text {
|
|
146
|
+
fieldGroupName
|
|
147
|
+
text
|
|
148
|
+
}
|
|
149
|
+
... on Case_Case_Content_Twocolumns_Right_Video {
|
|
150
|
+
fieldGroupName
|
|
151
|
+
autoplay
|
|
152
|
+
poster {
|
|
153
|
+
sourceUrl
|
|
154
|
+
}
|
|
155
|
+
caption
|
|
156
|
+
video
|
|
157
|
+
ratio
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
... on Case_Case_Content_Threecolumns {
|
|
162
|
+
fieldGroupName
|
|
163
|
+
left {
|
|
164
|
+
... on Case_Case_Content_Threecolumns_Left_Image {
|
|
165
|
+
fieldGroupName
|
|
166
|
+
image {
|
|
167
|
+
sourceUrl
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
... on Case_Case_Content_Threecolumns_Left_Text {
|
|
171
|
+
fieldGroupName
|
|
172
|
+
text
|
|
173
|
+
}
|
|
174
|
+
... on Case_Case_Content_Threecolumns_Left_Video {
|
|
175
|
+
fieldGroupName
|
|
176
|
+
autoplay
|
|
177
|
+
poster {
|
|
178
|
+
sourceUrl
|
|
179
|
+
}
|
|
180
|
+
caption
|
|
181
|
+
video
|
|
182
|
+
ratio
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
center {
|
|
186
|
+
... on Case_Case_Content_Threecolumns_Center_Image {
|
|
187
|
+
fieldGroupName
|
|
188
|
+
image {
|
|
189
|
+
sourceUrl
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
... on Case_Case_Content_Threecolumns_Center_Text {
|
|
193
|
+
fieldGroupName
|
|
194
|
+
text
|
|
195
|
+
}
|
|
196
|
+
... on Case_Case_Content_Threecolumns_Center_Video {
|
|
197
|
+
fieldGroupName
|
|
198
|
+
autoplay
|
|
199
|
+
poster {
|
|
200
|
+
sourceUrl
|
|
201
|
+
}
|
|
202
|
+
caption
|
|
203
|
+
video
|
|
204
|
+
ratio
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
right {
|
|
208
|
+
... on Case_Case_Content_Threecolumns_Right_Image {
|
|
209
|
+
fieldGroupName
|
|
210
|
+
image {
|
|
211
|
+
sourceUrl
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
... on Case_Case_Content_Threecolumns_Right_Text {
|
|
215
|
+
fieldGroupName
|
|
216
|
+
text
|
|
217
|
+
}
|
|
218
|
+
... on Case_Case_Content_Threecolumns_Right_Video {
|
|
219
|
+
fieldGroupName
|
|
220
|
+
autoplay
|
|
221
|
+
poster {
|
|
222
|
+
sourceUrl
|
|
223
|
+
}
|
|
224
|
+
caption
|
|
225
|
+
video
|
|
226
|
+
ratio
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
contactPage: page(id: "${contactPage}", idType: URI) {
|
|
234
|
+
customFieldsContact {
|
|
235
|
+
berlinImage {
|
|
236
|
+
sourceUrl
|
|
237
|
+
}
|
|
238
|
+
berlinText
|
|
239
|
+
berlinEmail
|
|
240
|
+
berlinPhone
|
|
241
|
+
zurichImage {
|
|
242
|
+
sourceUrl
|
|
243
|
+
}
|
|
244
|
+
zurichText
|
|
245
|
+
zurichEmail
|
|
246
|
+
zurichPhone
|
|
247
|
+
newyorkImage {
|
|
248
|
+
sourceUrl
|
|
249
|
+
}
|
|
250
|
+
newyorkText
|
|
251
|
+
newyorkEmail
|
|
252
|
+
newyorkPhone
|
|
253
|
+
contactTeaserHeading
|
|
254
|
+
contactTeaserText
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
homePage: page(id: "${homePage}", idType: URI) {
|
|
258
|
+
customFieldsBerlin {
|
|
259
|
+
awardsHeading
|
|
260
|
+
awards {
|
|
261
|
+
image {
|
|
262
|
+
sourceUrl
|
|
263
|
+
}
|
|
264
|
+
heading
|
|
265
|
+
text
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
`;
|
|
271
|
+
|
|
272
|
+
const variables = { id };
|
|
273
|
+
const data: {
|
|
274
|
+
case: Case;
|
|
275
|
+
contactPage: ContactPage;
|
|
276
|
+
homePage: HomePage;
|
|
277
|
+
} = await client.request(query, variables);
|
|
278
|
+
|
|
279
|
+
return {
|
|
280
|
+
case: data.case,
|
|
281
|
+
contactPage: data.contactPage,
|
|
282
|
+
homePage: data.homePage,
|
|
283
|
+
};
|
|
284
|
+
}
|
|
@@ -38,6 +38,7 @@ type Params = {
|
|
|
38
38
|
page?: number;
|
|
39
39
|
service?: string;
|
|
40
40
|
industry?: string;
|
|
41
|
+
isPreview?: boolean;
|
|
41
42
|
};
|
|
42
43
|
|
|
43
44
|
export default async function getCasesPage({
|
|
@@ -50,6 +51,7 @@ export default async function getCasesPage({
|
|
|
50
51
|
page = 1,
|
|
51
52
|
service = "",
|
|
52
53
|
industry = "",
|
|
54
|
+
isPreview = false,
|
|
53
55
|
}: Params): Promise<{
|
|
54
56
|
casesPage: CasesPage;
|
|
55
57
|
cases: Case[];
|
|
@@ -88,6 +90,7 @@ export default async function getCasesPage({
|
|
|
88
90
|
|
|
89
91
|
// Where Clause
|
|
90
92
|
const whereConditions = [
|
|
93
|
+
isPreview ? "status: DRAFT" : "status: PUBLISH",
|
|
91
94
|
hasSearchTerm ? "search: $search" : "",
|
|
92
95
|
hasCategoryTerm ? "caseCategory: $categorySlug" : "",
|
|
93
96
|
exclude ? "notIn: $exclude" : "",
|
|
@@ -130,6 +133,7 @@ export default async function getCasesPage({
|
|
|
130
133
|
title
|
|
131
134
|
slug
|
|
132
135
|
uri
|
|
136
|
+
status
|
|
133
137
|
case {
|
|
134
138
|
featured
|
|
135
139
|
service
|
package/lib/queries/index.ts
CHANGED
|
@@ -5,6 +5,7 @@ import getMetadataBySlug from "./getMetadataBySlug";
|
|
|
5
5
|
import getPageBySlug from "./getPageBySlug";
|
|
6
6
|
import getPostBySlug from "./getPostBySlug";
|
|
7
7
|
import getCaseBySlug from "./getCaseBySlug";
|
|
8
|
+
import getCaseById from "./getCaseById";
|
|
8
9
|
import getContactPage from "./getContactPage";
|
|
9
10
|
import getBrands from "./getBrands";
|
|
10
11
|
import getPeoplePage from "./getPeoplePage";
|
|
@@ -25,6 +26,7 @@ export {
|
|
|
25
26
|
getPageBySlug,
|
|
26
27
|
getPostBySlug,
|
|
27
28
|
getCaseBySlug,
|
|
29
|
+
getCaseById,
|
|
28
30
|
getContactPage,
|
|
29
31
|
getBrands,
|
|
30
32
|
getPeoplePage,
|
package/lib/types/index.ts
CHANGED