@canva/cli 1.10.0 → 1.12.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.
Files changed (126) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/README.md +2 -0
  3. package/cli.js +596 -574
  4. package/lib/cjs/index.cjs +2 -2
  5. package/lib/esm/index.mjs +2 -2
  6. package/lib/index.d.ts +2 -0
  7. package/package.json +7 -2
  8. package/templates/base/package.json +9 -8
  9. package/templates/base/styles/components.css +18 -0
  10. package/templates/common/.env.template +1 -1
  11. package/templates/common/jest.config.mjs +1 -1
  12. package/templates/dam/backend/server.ts +8 -0
  13. package/templates/dam/canva-app.json +9 -0
  14. package/templates/dam/package.json +10 -8
  15. package/templates/dam/src/index.tsx +3 -21
  16. package/templates/dam/src/intents/design_editor/index.tsx +25 -0
  17. package/templates/data_connector/README.md +1 -1
  18. package/templates/data_connector/package.json +9 -8
  19. package/templates/data_connector/src/api/data_sources/designs.tsx +1 -1
  20. package/templates/data_connector/src/api/data_sources/templates.tsx +1 -1
  21. package/templates/data_connector/src/components/header.tsx +1 -1
  22. package/templates/data_connector/src/index.tsx +2 -66
  23. package/templates/data_connector/src/{app.tsx → intents/data_connector/app.tsx} +3 -3
  24. package/templates/data_connector/src/{entrypoint.tsx → intents/data_connector/entrypoint.tsx} +5 -5
  25. package/templates/data_connector/src/{home.tsx → intents/data_connector/home.tsx} +1 -1
  26. package/templates/data_connector/src/intents/data_connector/index.tsx +56 -0
  27. package/templates/data_connector/src/pages/error.tsx +1 -1
  28. package/templates/data_connector/src/pages/login.tsx +1 -1
  29. package/templates/data_connector/src/routes/protected_route.tsx +1 -1
  30. package/templates/data_connector/src/routes/routes.tsx +3 -3
  31. package/templates/data_connector/styles/components.css +18 -0
  32. package/templates/gen_ai/backend/server.ts +17 -0
  33. package/templates/gen_ai/canva-app.json +5 -0
  34. package/templates/gen_ai/package.json +10 -8
  35. package/templates/gen_ai/src/api/api.ts +4 -0
  36. package/templates/gen_ai/src/components/footer.tsx +1 -1
  37. package/templates/gen_ai/src/components/loading_results.tsx +1 -1
  38. package/templates/gen_ai/src/components/prompt_input.tsx +1 -1
  39. package/templates/gen_ai/src/index.tsx +3 -14
  40. package/templates/gen_ai/src/{app.tsx → intents/design_editor/app.tsx} +3 -3
  41. package/templates/gen_ai/src/{home.tsx → intents/design_editor/home.tsx} +1 -1
  42. package/templates/gen_ai/src/intents/design_editor/index.tsx +17 -0
  43. package/templates/gen_ai/src/pages/error.tsx +1 -1
  44. package/templates/gen_ai/src/routes/routes.tsx +2 -2
  45. package/templates/gen_ai/styles/components.css +18 -0
  46. package/templates/hello_world/canva-app.json +5 -0
  47. package/templates/hello_world/package.json +10 -8
  48. package/templates/hello_world/src/index.tsx +3 -21
  49. package/templates/hello_world/src/{app.tsx → intents/design_editor/app.tsx} +26 -3
  50. package/templates/hello_world/src/intents/design_editor/index.tsx +25 -0
  51. package/templates/hello_world/src/{tests → intents/design_editor/tests}/app.tests.tsx +19 -13
  52. package/templates/hello_world/styles/components.css +18 -0
  53. package/templates/mls/README.md +81 -0
  54. package/templates/mls/canva-app.json +25 -0
  55. package/templates/mls/declarations/declarations.d.ts +29 -0
  56. package/templates/mls/eslint.config.mjs +14 -0
  57. package/templates/mls/jest.config.mjs +36 -0
  58. package/templates/mls/jest.setup.ts +37 -0
  59. package/templates/mls/package.json +117 -0
  60. package/templates/mls/scripts/copy_env.ts +13 -0
  61. package/templates/mls/scripts/ssl/ssl.ts +131 -0
  62. package/templates/mls/scripts/start/app_runner.ts +223 -0
  63. package/templates/mls/scripts/start/context.ts +171 -0
  64. package/templates/mls/scripts/start/start.ts +46 -0
  65. package/templates/mls/src/__tests__/app.tests.tsx +11 -0
  66. package/templates/mls/src/__tests__/office_selection_page.tests.tsx +72 -0
  67. package/templates/mls/src/__tests__/utils.tsx +19 -0
  68. package/templates/mls/src/adapter.ts +126 -0
  69. package/templates/mls/src/components/agent/agent_card.tsx +57 -0
  70. package/templates/mls/src/components/agent/agent_grid.tsx +37 -0
  71. package/templates/mls/src/components/agent/agent_list.tsx +17 -0
  72. package/templates/mls/src/components/agent/agent_search_filters.tsx +88 -0
  73. package/templates/mls/src/components/breadcrumb/breadcrumb.tsx +40 -0
  74. package/templates/mls/src/components/listing/listing_card.tsx +64 -0
  75. package/templates/mls/src/components/listing/listing_grid.tsx +37 -0
  76. package/templates/mls/src/components/listing/listing_list.tsx +21 -0
  77. package/templates/mls/src/components/listing/listing_search_filters.tsx +145 -0
  78. package/templates/mls/src/components/placeholders/placeholders.tsx +65 -0
  79. package/templates/mls/src/data.ts +359 -0
  80. package/templates/mls/src/index.tsx +4 -0
  81. package/templates/mls/src/intents/design_editor/app.tsx +44 -0
  82. package/templates/mls/src/intents/design_editor/index.tsx +25 -0
  83. package/templates/mls/src/pages/agent_details_page/agent_details_page.tsx +175 -0
  84. package/templates/mls/src/pages/list_page/agent_tab_panel.tsx +126 -0
  85. package/templates/mls/src/pages/list_page/list_page.tsx +67 -0
  86. package/templates/mls/src/pages/list_page/listing_tab_panel.tsx +135 -0
  87. package/templates/mls/src/pages/listing_details_page/listing_details_page.tsx +418 -0
  88. package/templates/mls/src/pages/loading_page/loading_page.tsx +152 -0
  89. package/templates/mls/src/pages/office_selection_page/office_selection_page.tsx +144 -0
  90. package/templates/mls/src/real_estate.type.ts +44 -0
  91. package/templates/mls/src/util/use_add_element.tsx +62 -0
  92. package/templates/mls/src/util/use_drag_element.tsx +68 -0
  93. package/templates/mls/styles/components.css +56 -0
  94. package/templates/mls/tsconfig.json +55 -0
  95. package/templates/mls/webpack.config.ts +254 -0
  96. package/templates/optional/AGENTS.md +80 -2
  97. package/templates/optional/CLAUDE.md +80 -2
  98. package/templates/base/backend/routers/oauth.ts +0 -393
  99. package/templates/base/utils/backend/bearer_middleware/bearer_middleware.ts +0 -99
  100. package/templates/base/utils/backend/bearer_middleware/index.ts +0 -1
  101. package/templates/base/utils/backend/bearer_middleware/tests/bearer_middleware.tests.ts +0 -192
  102. package/templates/base/utils/use_add_element.ts +0 -58
  103. package/templates/base/utils/use_feature_support.ts +0 -28
  104. package/templates/common/utils/backend/base_backend/create.ts +0 -104
  105. package/templates/common/utils/table_wrapper.ts +0 -520
  106. package/templates/common/utils/use_add_element.ts +0 -58
  107. package/templates/common/utils/use_feature_support.ts +0 -28
  108. package/templates/common/utils/use_overlay_hook.ts +0 -76
  109. package/templates/common/utils/use_selection_hook.ts +0 -37
  110. package/templates/gen_ai/backend/database/database.ts +0 -42
  111. package/templates/gen_ai/utils/backend/bearer_middleware/bearer_middleware.ts +0 -99
  112. package/templates/gen_ai/utils/backend/bearer_middleware/index.ts +0 -1
  113. package/templates/hello_world/utils/use_add_element.ts +0 -58
  114. package/templates/hello_world/utils/use_feature_support.ts +0 -28
  115. /package/templates/base/{utils/backend → backend}/base_backend/create.ts +0 -0
  116. /package/templates/base/{utils/backend → backend}/jwt_middleware/index.ts +0 -0
  117. /package/templates/base/{utils/backend → backend}/jwt_middleware/jwt_middleware.ts +0 -0
  118. /package/templates/dam/src/{adapter.ts → intents/design_editor/adapter.ts} +0 -0
  119. /package/templates/dam/src/{app.tsx → intents/design_editor/app.tsx} +0 -0
  120. /package/templates/dam/src/{config.ts → intents/design_editor/config.ts} +0 -0
  121. /package/templates/dam/src/{index.css → intents/design_editor/index.css} +0 -0
  122. /package/templates/data_connector/src/{paths.ts → routes/paths.ts} +0 -0
  123. /package/templates/gen_ai/src/{paths.ts → routes/paths.ts} +0 -0
  124. /package/templates/{common → gen_ai}/utils/backend/jwt_middleware/index.ts +0 -0
  125. /package/templates/{common → gen_ai}/utils/backend/jwt_middleware/jwt_middleware.ts +0 -0
  126. /package/templates/hello_world/src/{tests → intents/design_editor/tests}/__snapshots__/app.tests.tsx.snap +0 -0
@@ -0,0 +1,418 @@
1
+ import {
2
+ ArrowLeftIcon,
3
+ Box,
4
+ Button,
5
+ CheckIcon,
6
+ Column,
7
+ Columns,
8
+ CopyIcon,
9
+ Grid,
10
+ ImageCard,
11
+ Rows,
12
+ SegmentedControl,
13
+ Text,
14
+ TypographyCard,
15
+ } from "@canva/app-ui-kit";
16
+ import React, { useState } from "react";
17
+ import { useIntl } from "react-intl";
18
+ import { useLocation, useNavigate } from "react-router-dom";
19
+ import type { Property } from "../../real_estate.type";
20
+ import { useAddElement } from "../../util/use_add_element";
21
+ import { useDragElement } from "../../util/use_drag_element";
22
+
23
+ export const ListingDetailsPage = () => {
24
+ const navigate = useNavigate();
25
+ const listing = (useLocation().state as { listing: Property })?.listing;
26
+ const intl = useIntl();
27
+ const [selectedTab, setSelectedTab] = useState("images");
28
+ const [copyState, setCopyState] = useState<"idle" | "loading" | "complete">(
29
+ "idle",
30
+ );
31
+
32
+ const { addText, addImage } = useAddElement();
33
+
34
+ const { dragText, dragImage } = useDragElement();
35
+
36
+ if (!listing) {
37
+ navigate(-1);
38
+ }
39
+
40
+ const handleCopy = async (text: string) => {
41
+ setCopyState("loading");
42
+ try {
43
+ await Promise.all([
44
+ navigator.clipboard.writeText(text),
45
+ new Promise((resolve) => setTimeout(resolve, 500)),
46
+ ]);
47
+ setCopyState("complete");
48
+ setTimeout(() => setCopyState("idle"), 2000);
49
+ } catch (error) {
50
+ setCopyState("idle");
51
+ // eslint-disable-next-line no-console
52
+ console.error(
53
+ intl.formatMessage({
54
+ defaultMessage: "Failed to copy:",
55
+ description: "Console error message when copying fails",
56
+ }),
57
+ error,
58
+ );
59
+ }
60
+ };
61
+
62
+ return (
63
+ <Box paddingY="2u" height="full">
64
+ <Rows spacing="2u">
65
+ <Columns spacing="1u" alignY="center">
66
+ <Column width="content">
67
+ <Button
68
+ icon={ArrowLeftIcon}
69
+ size="small"
70
+ type="button"
71
+ variant="tertiary"
72
+ onClick={() => navigate(-1)}
73
+ />
74
+ </Column>
75
+ <Column>
76
+ <Text variant="bold">
77
+ {intl.formatMessage({
78
+ defaultMessage: "Property Details",
79
+ description: "Page title for property details page",
80
+ })}
81
+ </Text>
82
+ </Column>
83
+ </Columns>
84
+
85
+ <Rows spacing="2u">
86
+ <SegmentedControl
87
+ options={[
88
+ {
89
+ value: "images",
90
+ label: intl.formatMessage({
91
+ defaultMessage: "Images",
92
+ description: "Property images tab",
93
+ }),
94
+ },
95
+ {
96
+ value: "details",
97
+ label: intl.formatMessage({
98
+ defaultMessage: "Details",
99
+ description: "Property details tab",
100
+ }),
101
+ },
102
+ {
103
+ value: "agent",
104
+ label: intl.formatMessage({
105
+ defaultMessage: "Agent",
106
+ description: "Property's agent tab",
107
+ }),
108
+ },
109
+ ]}
110
+ value={selectedTab}
111
+ onChange={setSelectedTab}
112
+ />
113
+
114
+ {selectedTab === "images" && (
115
+ <Box>
116
+ <Rows spacing="2u">
117
+ {listing.listing_images && listing.listing_images.length > 0 ? (
118
+ <Grid columns={2} spacing="2u">
119
+ {listing.listing_images.map((image, index) => (
120
+ <ImageCard
121
+ key={index}
122
+ selectable
123
+ thumbnailUrl={image.url}
124
+ alt={
125
+ image.alt ||
126
+ intl.formatMessage({
127
+ defaultMessage: "Property image",
128
+ description: "Alt text for property image",
129
+ })
130
+ }
131
+ thumbnailHeight={150}
132
+ thumbnailAspectRatio={4 / 3}
133
+ onClick={async () => {
134
+ await addImage(
135
+ image.url,
136
+ image.alt ||
137
+ intl.formatMessage({
138
+ defaultMessage: "Property image",
139
+ description: "Alt text for property image",
140
+ }),
141
+ );
142
+ }}
143
+ onDragStart={(e) => {
144
+ dragImage(
145
+ e,
146
+ image.url,
147
+ image.alt ||
148
+ intl.formatMessage({
149
+ defaultMessage: "Property image",
150
+ description: "Alt text for property image",
151
+ }),
152
+ image.width,
153
+ image.height,
154
+ );
155
+ }}
156
+ />
157
+ ))}
158
+ </Grid>
159
+ ) : (
160
+ <Box>
161
+ <Text>
162
+ {intl.formatMessage({
163
+ defaultMessage: "No images available",
164
+ description:
165
+ "Message shown when no images are available",
166
+ })}
167
+ </Text>
168
+ </Box>
169
+ )}
170
+ </Rows>
171
+ </Box>
172
+ )}
173
+
174
+ {selectedTab === "details" && (
175
+ <Rows spacing="2u">
176
+ <Rows spacing="1u">
177
+ <Text variant="bold">
178
+ {intl.formatMessage({
179
+ defaultMessage: "Title",
180
+ description: "Label for property title field",
181
+ })}
182
+ </Text>
183
+ <TypographyCard
184
+ ariaLabel={intl.formatMessage({
185
+ defaultMessage: "Add property title to design",
186
+ description:
187
+ "Accessibility label for adding property title to design",
188
+ })}
189
+ onClick={() => addText(listing.title)}
190
+ onDragStart={(e) => dragText(e, listing.title)}
191
+ >
192
+ <Text>{listing.title}</Text>
193
+ </TypographyCard>
194
+ </Rows>
195
+
196
+ <Rows spacing="2u">
197
+ <Rows spacing="1u">
198
+ <Text variant="bold">
199
+ {intl.formatMessage({
200
+ defaultMessage: "Description",
201
+ description: "Label for property description field",
202
+ })}
203
+ </Text>
204
+ <TypographyCard
205
+ ariaLabel={intl.formatMessage({
206
+ defaultMessage: "Add property description to design",
207
+ description:
208
+ "Accessibility label for adding property description to design",
209
+ })}
210
+ onClick={() => addText(listing.description)}
211
+ onDragStart={(e) => dragText(e, listing.description)}
212
+ >
213
+ <Text>{listing.description}</Text>
214
+ </TypographyCard>
215
+ </Rows>
216
+
217
+ <Columns spacing="1u" alignY="stretch">
218
+ <Column>
219
+ <Button
220
+ variant="primary"
221
+ stretch
222
+ onClick={() => addText(listing.description)}
223
+ >
224
+ {intl.formatMessage({
225
+ defaultMessage: "Add to design",
226
+ description:
227
+ "Button text for adding description to design",
228
+ })}
229
+ </Button>
230
+ </Column>
231
+ <Column width="content">
232
+ <Button
233
+ icon={copyState === "complete" ? CheckIcon : CopyIcon}
234
+ variant="secondary"
235
+ loading={copyState === "loading"}
236
+ onClick={() => handleCopy(listing.description)}
237
+ />
238
+ </Column>
239
+ </Columns>
240
+ </Rows>
241
+
242
+ <Rows spacing="1u">
243
+ <Text variant="bold">
244
+ {intl.formatMessage({
245
+ defaultMessage: "Address",
246
+ description: "Label for property address field",
247
+ })}
248
+ </Text>
249
+ <TypographyCard
250
+ ariaLabel={intl.formatMessage({
251
+ defaultMessage: "Add property address to design",
252
+ description:
253
+ "Accessibility label for adding property address to design",
254
+ })}
255
+ onClick={() => addText(listing.address)}
256
+ onDragStart={(e) => dragText(e, listing.address)}
257
+ >
258
+ <Text>{listing.address}</Text>
259
+ </TypographyCard>
260
+ </Rows>
261
+
262
+ <Rows spacing="1u">
263
+ <Text variant="bold">
264
+ {intl.formatMessage({
265
+ defaultMessage: "Price",
266
+ description: "Label for property price field",
267
+ })}
268
+ </Text>
269
+ <TypographyCard
270
+ ariaLabel={intl.formatMessage({
271
+ defaultMessage: "Add listing price to design",
272
+ description:
273
+ "Accessibility label for adding listing price to design",
274
+ })}
275
+ onClick={() => addText(listing.price)}
276
+ onDragStart={(e) => dragText(e, listing.price)}
277
+ >
278
+ <Text>{listing.price}</Text>
279
+ </TypographyCard>
280
+ </Rows>
281
+ </Rows>
282
+ )}
283
+
284
+ {selectedTab === "agent" && listing.agent && (
285
+ <Box>
286
+ <Rows spacing="2u">
287
+ {listing.agent.headshots && (
288
+ <Box>
289
+ <Rows spacing="1u">
290
+ <Text variant="bold">
291
+ {intl.formatMessage({
292
+ defaultMessage: "Headshots",
293
+ description: "Label for agent headshots section",
294
+ })}
295
+ </Text>
296
+ <Columns spacing="2u" alignY="stretch">
297
+ {listing.agent.headshots.map((headshot, index) => (
298
+ <Column key={index} width="1/2">
299
+ <ImageCard
300
+ selectable
301
+ thumbnailUrl={headshot.url}
302
+ alt={intl.formatMessage({
303
+ defaultMessage: "Agent photo",
304
+ description: "Alt text for agent photo",
305
+ })}
306
+ thumbnailHeight={150}
307
+ onClick={async () => {
308
+ await addImage(
309
+ headshot.url,
310
+ intl.formatMessage({
311
+ defaultMessage: "Agent photo",
312
+ description: "Alt text for agent photo",
313
+ }),
314
+ );
315
+ }}
316
+ onDragStart={(e) => {
317
+ dragImage(
318
+ e,
319
+ headshot.url,
320
+ intl.formatMessage({
321
+ defaultMessage: "Agent photo",
322
+ description: "Alt text for agent photo",
323
+ }),
324
+ headshot.width,
325
+ headshot.height,
326
+ );
327
+ }}
328
+ />
329
+ </Column>
330
+ ))}
331
+ </Columns>
332
+ </Rows>
333
+ </Box>
334
+ )}
335
+
336
+ <Rows spacing="2u">
337
+ <Box>
338
+ <Rows spacing="1u">
339
+ <Text variant="bold">
340
+ {intl.formatMessage({
341
+ defaultMessage: "Name",
342
+ description: "Label for agent name field",
343
+ })}
344
+ </Text>
345
+ <TypographyCard
346
+ ariaLabel={intl.formatMessage({
347
+ defaultMessage: "Add agent name to design",
348
+ description:
349
+ "Accessibility label for adding agent name to design",
350
+ })}
351
+ onClick={() => addText(listing.agent?.name || "")}
352
+ onDragStart={(e) =>
353
+ dragText(e, listing.agent?.name || "")
354
+ }
355
+ >
356
+ <Text>{listing.agent?.name}</Text>
357
+ </TypographyCard>
358
+ </Rows>
359
+ </Box>
360
+
361
+ <Box>
362
+ <Rows spacing="1u">
363
+ <Text variant="bold">
364
+ {intl.formatMessage({
365
+ defaultMessage: "Title",
366
+ description: "Label for agent role title field",
367
+ })}
368
+ </Text>
369
+ <TypographyCard
370
+ ariaLabel={intl.formatMessage({
371
+ defaultMessage: "Add agent title to design",
372
+ description:
373
+ "Accessibility label for adding agent title to design",
374
+ })}
375
+ onClick={() => addText(listing.agent?.roleTitle || "")}
376
+ onDragStart={(e) =>
377
+ dragText(e, listing.agent?.roleTitle || "")
378
+ }
379
+ >
380
+ <Text>{listing.agent?.roleTitle}</Text>
381
+ </TypographyCard>
382
+ </Rows>
383
+ </Box>
384
+
385
+ <Box>
386
+ <Rows spacing="0.5u">
387
+ <Text variant="bold">
388
+ {intl.formatMessage({
389
+ defaultMessage: "Phone number",
390
+ description: "Label for agent phone number field",
391
+ })}
392
+ </Text>
393
+ <TypographyCard
394
+ ariaLabel={intl.formatMessage({
395
+ defaultMessage: "Add agent phone to design",
396
+ description:
397
+ "Accessibility label for adding agent phone to design",
398
+ })}
399
+ onClick={() =>
400
+ addText(listing.agent?.phoneNumber || "")
401
+ }
402
+ onDragStart={(e) =>
403
+ dragText(e, listing.agent?.phoneNumber || "")
404
+ }
405
+ >
406
+ <Text>{listing.agent?.phoneNumber}</Text>
407
+ </TypographyCard>
408
+ </Rows>
409
+ </Box>
410
+ </Rows>
411
+ </Rows>
412
+ </Box>
413
+ )}
414
+ </Rows>
415
+ </Rows>
416
+ </Box>
417
+ );
418
+ };
@@ -0,0 +1,152 @@
1
+ import {
2
+ Box,
3
+ Column,
4
+ Columns,
5
+ Placeholder,
6
+ Rows,
7
+ Text,
8
+ Title,
9
+ tokens,
10
+ } from "@canva/app-ui-kit";
11
+ import { useQueries } from "@tanstack/react-query";
12
+ import React, { useEffect } from "react";
13
+ import { useIntl } from "react-intl";
14
+ import { useLocation, useNavigate } from "react-router-dom";
15
+ import { fetchAgents, fetchListings } from "../../adapter";
16
+ import { Breadcrumb } from "../../components/breadcrumb/breadcrumb";
17
+ import type { Office } from "../../real_estate.type";
18
+
19
+ export const LoadingPage = () => {
20
+ const navigate = useNavigate();
21
+ const office = (useLocation().state as { office: Office })?.office;
22
+ const intl = useIntl();
23
+
24
+ const results = useQueries({
25
+ queries: [
26
+ {
27
+ queryKey: ["agents-loading", office?.id],
28
+ queryFn: async () => fetchAgents(office),
29
+ enabled: !!office,
30
+ },
31
+ {
32
+ queryKey: ["listings-loading", office],
33
+ queryFn: async () => fetchListings(office),
34
+ enabled: !!office,
35
+ },
36
+ ],
37
+ });
38
+
39
+ const isLoading = results.some((result) => result.isLoading);
40
+ const isError = results.every((result) => result.isError);
41
+ const isEmpty =
42
+ !isLoading &&
43
+ !isError &&
44
+ results[0].data?.agents.length === 0 &&
45
+ results[1].data?.listings.length === 0;
46
+
47
+ useEffect(() => {
48
+ if (!isLoading && !isError && !isEmpty && office) {
49
+ const hasListings = results[1].data?.listings?.length;
50
+
51
+ // Navigate to list page with appropriate tab based on available data
52
+ const defaultTab = hasListings ? "listings" : "agents";
53
+ navigate(`/list/${defaultTab}`, { replace: true, state: { office } });
54
+ }
55
+ }, [results, isLoading, isError, isEmpty, office, navigate]);
56
+
57
+ if (isLoading) {
58
+ return (
59
+ <Box height="full" paddingY="2u" display="flex" flexDirection="column">
60
+ <Breadcrumb />
61
+ <Box height="full" width="full" paddingTop="2u">
62
+ <Rows spacing="2u">
63
+ <Columns spacing="1u" alignY="stretch">
64
+ <Column width="1/2">
65
+ <div style={{ height: tokens.space400 }}>
66
+ <Placeholder shape="rectangle" />
67
+ </div>
68
+ </Column>
69
+ <Column width="1/2">
70
+ <div style={{ height: tokens.space400 }}>
71
+ <Placeholder shape="rectangle" />
72
+ </div>
73
+ </Column>
74
+ </Columns>
75
+ <div style={{ width: "100%", height: tokens.space400 }}>
76
+ <Placeholder shape="rectangle" />
77
+ </div>
78
+ </Rows>
79
+ </Box>
80
+ </Box>
81
+ );
82
+ }
83
+
84
+ if (isError) {
85
+ return (
86
+ <Box height="full" paddingY="2u" display="flex" flexDirection="column">
87
+ <Breadcrumb />
88
+ <Box
89
+ height="full"
90
+ width="full"
91
+ paddingX="2u"
92
+ justifyContent="center"
93
+ alignItems="center"
94
+ display="flex"
95
+ flexDirection="column"
96
+ >
97
+ <Rows spacing="2u" align="center">
98
+ <Title alignment="center">
99
+ {intl.formatMessage({
100
+ defaultMessage: "Something went wrong",
101
+ description: "Title shown when there's an error loading data",
102
+ })}
103
+ </Title>
104
+ <Text alignment="center">
105
+ {intl.formatMessage({
106
+ defaultMessage: "Unable to load data. Please try again.",
107
+ description: "Error message shown when data fails to load",
108
+ })}
109
+ </Text>
110
+ </Rows>
111
+ </Box>
112
+ </Box>
113
+ );
114
+ }
115
+
116
+ if (isEmpty) {
117
+ return (
118
+ <Box height="full" paddingY="2u" display="flex" flexDirection="column">
119
+ <Breadcrumb />
120
+ <Box
121
+ height="full"
122
+ width="full"
123
+ justifyContent="center"
124
+ alignItems="center"
125
+ display="flex"
126
+ flexDirection="column"
127
+ paddingX="2u"
128
+ >
129
+ <Rows spacing="2u" align="center">
130
+ <Title alignment="center">
131
+ {intl.formatMessage({
132
+ defaultMessage: "Nothing here yet",
133
+ description:
134
+ "Title shown when there are no agents or listings to display",
135
+ })}
136
+ </Title>
137
+ <Text alignment="center">
138
+ {intl.formatMessage({
139
+ defaultMessage:
140
+ "There are no agents or listings here. Try choosing another office.",
141
+ description:
142
+ "Helper text shown when there are no agents or listings to display",
143
+ })}
144
+ </Text>
145
+ </Rows>
146
+ </Box>
147
+ </Box>
148
+ );
149
+ }
150
+
151
+ return null;
152
+ };