@canva/cli 1.19.0 → 1.20.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 (231) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/README.md +1 -9
  3. package/cli.js +408 -409
  4. package/package.json +1 -2
  5. package/templates/base/backend/base_backend/create.ts +0 -114
  6. package/templates/base/backend/database/database.ts +0 -42
  7. package/templates/base/backend/routers/auth.ts +0 -288
  8. package/templates/base/declarations/declarations.d.ts +0 -29
  9. package/templates/base/eslint.config.mjs +0 -14
  10. package/templates/base/package.json +0 -91
  11. package/templates/base/scripts/copy_env.ts +0 -13
  12. package/templates/base/scripts/ssl/ssl.ts +0 -131
  13. package/templates/base/scripts/start/app_runner.ts +0 -223
  14. package/templates/base/scripts/start/context.ts +0 -171
  15. package/templates/base/scripts/start/start.ts +0 -46
  16. package/templates/base/scripts/start.tests.ts +0 -61
  17. package/templates/base/styles/components.css +0 -38
  18. package/templates/base/tsconfig.json +0 -56
  19. package/templates/base/webpack.config.ts +0 -247
  20. package/templates/common/.env.template +0 -6
  21. package/templates/common/.gitignore.template +0 -8
  22. package/templates/common/.nvmrc +0 -1
  23. package/templates/common/.prettierrc +0 -21
  24. package/templates/common/LICENSE.md +0 -48
  25. package/templates/common/README.md +0 -179
  26. package/templates/common/jest.config.mjs +0 -35
  27. package/templates/common/jest.setup.ts +0 -35
  28. package/templates/content_publisher/README.md +0 -58
  29. package/templates/content_publisher/canva-app.json +0 -17
  30. package/templates/content_publisher/declarations/declarations.d.ts +0 -29
  31. package/templates/content_publisher/eslint.config.mjs +0 -14
  32. package/templates/content_publisher/package.json +0 -90
  33. package/templates/content_publisher/scripts/copy_env.ts +0 -13
  34. package/templates/content_publisher/scripts/ssl/ssl.ts +0 -131
  35. package/templates/content_publisher/scripts/start/app_runner.ts +0 -223
  36. package/templates/content_publisher/scripts/start/context.ts +0 -171
  37. package/templates/content_publisher/scripts/start/start.ts +0 -46
  38. package/templates/content_publisher/src/index.tsx +0 -4
  39. package/templates/content_publisher/src/intents/content_publisher/index.tsx +0 -107
  40. package/templates/content_publisher/src/intents/content_publisher/post_preview.tsx +0 -240
  41. package/templates/content_publisher/src/intents/content_publisher/preview_ui.tsx +0 -62
  42. package/templates/content_publisher/src/intents/content_publisher/settings_ui.tsx +0 -81
  43. package/templates/content_publisher/src/intents/content_publisher/types.ts +0 -29
  44. package/templates/content_publisher/styles/components.css +0 -38
  45. package/templates/content_publisher/styles/preview_ui.css +0 -49
  46. package/templates/content_publisher/tsconfig.json +0 -56
  47. package/templates/content_publisher/webpack.config.ts +0 -247
  48. package/templates/dam/backend/routers/dam.ts +0 -108
  49. package/templates/dam/backend/server.ts +0 -65
  50. package/templates/dam/canva-app.json +0 -25
  51. package/templates/dam/declarations/declarations.d.ts +0 -29
  52. package/templates/dam/eslint.config.mjs +0 -14
  53. package/templates/dam/package.json +0 -97
  54. package/templates/dam/scripts/copy_env.ts +0 -13
  55. package/templates/dam/scripts/ssl/ssl.ts +0 -131
  56. package/templates/dam/scripts/start/app_runner.ts +0 -223
  57. package/templates/dam/scripts/start/context.ts +0 -171
  58. package/templates/dam/scripts/start/start.ts +0 -46
  59. package/templates/dam/src/index.tsx +0 -4
  60. package/templates/dam/src/intents/design_editor/adapter.ts +0 -44
  61. package/templates/dam/src/intents/design_editor/app.tsx +0 -35
  62. package/templates/dam/src/intents/design_editor/config.ts +0 -220
  63. package/templates/dam/src/intents/design_editor/index.css +0 -3
  64. package/templates/dam/src/intents/design_editor/index.tsx +0 -25
  65. package/templates/dam/tsconfig.json +0 -56
  66. package/templates/dam/utils/backend/base_backend/create.ts +0 -114
  67. package/templates/dam/webpack.config.ts +0 -247
  68. package/templates/data_connector/README.md +0 -84
  69. package/templates/data_connector/canva-app.json +0 -21
  70. package/templates/data_connector/declarations/declarations.d.ts +0 -29
  71. package/templates/data_connector/eslint.config.mjs +0 -14
  72. package/templates/data_connector/package.json +0 -92
  73. package/templates/data_connector/scripts/copy_env.ts +0 -13
  74. package/templates/data_connector/scripts/ssl/ssl.ts +0 -131
  75. package/templates/data_connector/scripts/start/app_runner.ts +0 -223
  76. package/templates/data_connector/scripts/start/context.ts +0 -171
  77. package/templates/data_connector/scripts/start/start.ts +0 -46
  78. package/templates/data_connector/src/api/connect_client.ts +0 -6
  79. package/templates/data_connector/src/api/data_source.ts +0 -97
  80. package/templates/data_connector/src/api/data_sources/designs.tsx +0 -296
  81. package/templates/data_connector/src/api/data_sources/index.ts +0 -4
  82. package/templates/data_connector/src/api/data_sources/templates.tsx +0 -328
  83. package/templates/data_connector/src/api/fetch_data_table.ts +0 -55
  84. package/templates/data_connector/src/api/index.ts +0 -4
  85. package/templates/data_connector/src/api/oauth.ts +0 -8
  86. package/templates/data_connector/src/api/tests/data_source.test.tsx +0 -99
  87. package/templates/data_connector/src/components/app_error.tsx +0 -15
  88. package/templates/data_connector/src/components/footer.tsx +0 -26
  89. package/templates/data_connector/src/components/header.tsx +0 -40
  90. package/templates/data_connector/src/components/index.ts +0 -3
  91. package/templates/data_connector/src/components/inputs/messages.tsx +0 -95
  92. package/templates/data_connector/src/components/inputs/search_filter.tsx +0 -109
  93. package/templates/data_connector/src/components/inputs/select_field.tsx +0 -26
  94. package/templates/data_connector/src/context/app_context.tsx +0 -125
  95. package/templates/data_connector/src/context/index.ts +0 -2
  96. package/templates/data_connector/src/context/use_app_context.ts +0 -17
  97. package/templates/data_connector/src/index.tsx +0 -4
  98. package/templates/data_connector/src/intents/data_connector/app.tsx +0 -20
  99. package/templates/data_connector/src/intents/data_connector/entrypoint.tsx +0 -70
  100. package/templates/data_connector/src/intents/data_connector/home.tsx +0 -21
  101. package/templates/data_connector/src/intents/data_connector/index.tsx +0 -56
  102. package/templates/data_connector/src/pages/data_source_config.tsx +0 -9
  103. package/templates/data_connector/src/pages/error.tsx +0 -37
  104. package/templates/data_connector/src/pages/index.ts +0 -4
  105. package/templates/data_connector/src/pages/login.tsx +0 -145
  106. package/templates/data_connector/src/pages/select_source.tsx +0 -24
  107. package/templates/data_connector/src/routes/index.ts +0 -2
  108. package/templates/data_connector/src/routes/paths.ts +0 -7
  109. package/templates/data_connector/src/routes/protected_route.tsx +0 -26
  110. package/templates/data_connector/src/routes/routes.tsx +0 -42
  111. package/templates/data_connector/src/utils/data_params.ts +0 -17
  112. package/templates/data_connector/src/utils/data_table.ts +0 -116
  113. package/templates/data_connector/src/utils/fetch_result.ts +0 -36
  114. package/templates/data_connector/src/utils/index.ts +0 -2
  115. package/templates/data_connector/src/utils/tests/data_table.test.ts +0 -133
  116. package/templates/data_connector/styles/components.css +0 -38
  117. package/templates/data_connector/tsconfig.json +0 -56
  118. package/templates/data_connector/webpack.config.ts +0 -247
  119. package/templates/gen_ai/README.md +0 -27
  120. package/templates/gen_ai/backend/routers/image.ts +0 -232
  121. package/templates/gen_ai/backend/server.ts +0 -65
  122. package/templates/gen_ai/canva-app.json +0 -25
  123. package/templates/gen_ai/declarations/declarations.d.ts +0 -29
  124. package/templates/gen_ai/eslint.config.mjs +0 -14
  125. package/templates/gen_ai/package.json +0 -101
  126. package/templates/gen_ai/scripts/copy_env.ts +0 -13
  127. package/templates/gen_ai/scripts/ssl/ssl.ts +0 -131
  128. package/templates/gen_ai/scripts/start/app_runner.ts +0 -223
  129. package/templates/gen_ai/scripts/start/context.ts +0 -171
  130. package/templates/gen_ai/scripts/start/start.ts +0 -46
  131. package/templates/gen_ai/src/api/api.ts +0 -194
  132. package/templates/gen_ai/src/api/index.ts +0 -1
  133. package/templates/gen_ai/src/components/app_error.tsx +0 -18
  134. package/templates/gen_ai/src/components/footer.messages.ts +0 -48
  135. package/templates/gen_ai/src/components/footer.tsx +0 -156
  136. package/templates/gen_ai/src/components/image_grid.tsx +0 -103
  137. package/templates/gen_ai/src/components/index.ts +0 -7
  138. package/templates/gen_ai/src/components/loading_results.tsx +0 -169
  139. package/templates/gen_ai/src/components/prompt_input.messages.ts +0 -14
  140. package/templates/gen_ai/src/components/prompt_input.tsx +0 -154
  141. package/templates/gen_ai/src/components/remaining_credits.tsx +0 -84
  142. package/templates/gen_ai/src/components/report_box.tsx +0 -54
  143. package/templates/gen_ai/src/components/tests/remaining_credit.tests.tsx +0 -47
  144. package/templates/gen_ai/src/config.ts +0 -21
  145. package/templates/gen_ai/src/context/app_context.tsx +0 -153
  146. package/templates/gen_ai/src/context/context.messages.ts +0 -30
  147. package/templates/gen_ai/src/context/index.ts +0 -2
  148. package/templates/gen_ai/src/context/use_app_context.ts +0 -17
  149. package/templates/gen_ai/src/index.tsx +0 -4
  150. package/templates/gen_ai/src/intents/design_editor/app.tsx +0 -19
  151. package/templates/gen_ai/src/intents/design_editor/home.tsx +0 -13
  152. package/templates/gen_ai/src/intents/design_editor/index.tsx +0 -17
  153. package/templates/gen_ai/src/pages/error.tsx +0 -41
  154. package/templates/gen_ai/src/pages/generate.tsx +0 -9
  155. package/templates/gen_ai/src/pages/index.ts +0 -3
  156. package/templates/gen_ai/src/pages/results.tsx +0 -31
  157. package/templates/gen_ai/src/routes/index.ts +0 -1
  158. package/templates/gen_ai/src/routes/paths.ts +0 -4
  159. package/templates/gen_ai/src/routes/routes.tsx +0 -24
  160. package/templates/gen_ai/src/utils/index.ts +0 -1
  161. package/templates/gen_ai/src/utils/obscenity_filter.ts +0 -33
  162. package/templates/gen_ai/styles/components.css +0 -38
  163. package/templates/gen_ai/styles/utils.css +0 -3
  164. package/templates/gen_ai/tsconfig.json +0 -56
  165. package/templates/gen_ai/utils/backend/base_backend/create.ts +0 -114
  166. package/templates/gen_ai/webpack.config.ts +0 -247
  167. package/templates/hello_world/canva-app.json +0 -21
  168. package/templates/hello_world/declarations/declarations.d.ts +0 -29
  169. package/templates/hello_world/eslint.config.mjs +0 -14
  170. package/templates/hello_world/package.json +0 -90
  171. package/templates/hello_world/scripts/copy_env.ts +0 -13
  172. package/templates/hello_world/scripts/ssl/ssl.ts +0 -131
  173. package/templates/hello_world/scripts/start/app_runner.ts +0 -223
  174. package/templates/hello_world/scripts/start/context.ts +0 -171
  175. package/templates/hello_world/scripts/start/start.ts +0 -46
  176. package/templates/hello_world/src/index.tsx +0 -4
  177. package/templates/hello_world/src/intents/design_editor/app.tsx +0 -86
  178. package/templates/hello_world/src/intents/design_editor/index.tsx +0 -25
  179. package/templates/hello_world/src/intents/design_editor/tests/__snapshots__/app.tests.tsx.snap +0 -45
  180. package/templates/hello_world/src/intents/design_editor/tests/app.tests.tsx +0 -92
  181. package/templates/hello_world/styles/components.css +0 -38
  182. package/templates/hello_world/tsconfig.json +0 -56
  183. package/templates/hello_world/webpack.config.ts +0 -247
  184. package/templates/mls/README.md +0 -81
  185. package/templates/mls/canva-app.json +0 -25
  186. package/templates/mls/declarations/declarations.d.ts +0 -29
  187. package/templates/mls/eslint.config.mjs +0 -14
  188. package/templates/mls/jest.config.mjs +0 -36
  189. package/templates/mls/jest.setup.ts +0 -39
  190. package/templates/mls/package.json +0 -117
  191. package/templates/mls/scripts/copy_env.ts +0 -13
  192. package/templates/mls/scripts/ssl/ssl.ts +0 -131
  193. package/templates/mls/scripts/start/app_runner.ts +0 -223
  194. package/templates/mls/scripts/start/context.ts +0 -171
  195. package/templates/mls/scripts/start/start.ts +0 -46
  196. package/templates/mls/src/__tests__/app.tests.tsx +0 -11
  197. package/templates/mls/src/__tests__/office_selection_page.tests.tsx +0 -72
  198. package/templates/mls/src/__tests__/utils.tsx +0 -19
  199. package/templates/mls/src/adapter.ts +0 -126
  200. package/templates/mls/src/components/agent/agent_card.tsx +0 -57
  201. package/templates/mls/src/components/agent/agent_grid.tsx +0 -37
  202. package/templates/mls/src/components/agent/agent_list.tsx +0 -17
  203. package/templates/mls/src/components/agent/agent_search_filters.tsx +0 -88
  204. package/templates/mls/src/components/breadcrumb/breadcrumb.tsx +0 -40
  205. package/templates/mls/src/components/listing/listing_card.tsx +0 -64
  206. package/templates/mls/src/components/listing/listing_grid.tsx +0 -37
  207. package/templates/mls/src/components/listing/listing_list.tsx +0 -21
  208. package/templates/mls/src/components/listing/listing_search_filters.tsx +0 -145
  209. package/templates/mls/src/components/placeholders/placeholders.tsx +0 -65
  210. package/templates/mls/src/data.ts +0 -359
  211. package/templates/mls/src/index.tsx +0 -4
  212. package/templates/mls/src/intents/design_editor/app.tsx +0 -44
  213. package/templates/mls/src/intents/design_editor/index.tsx +0 -25
  214. package/templates/mls/src/pages/agent_details_page/agent_details_page.tsx +0 -175
  215. package/templates/mls/src/pages/list_page/agent_tab_panel.tsx +0 -126
  216. package/templates/mls/src/pages/list_page/list_page.tsx +0 -67
  217. package/templates/mls/src/pages/list_page/listing_tab_panel.tsx +0 -135
  218. package/templates/mls/src/pages/listing_details_page/listing_details_page.tsx +0 -418
  219. package/templates/mls/src/pages/loading_page/loading_page.tsx +0 -152
  220. package/templates/mls/src/pages/office_selection_page/office_selection_page.tsx +0 -144
  221. package/templates/mls/src/real_estate.type.ts +0 -44
  222. package/templates/mls/src/util/use_add_element.tsx +0 -62
  223. package/templates/mls/src/util/use_drag_element.tsx +0 -68
  224. package/templates/mls/styles/components.css +0 -38
  225. package/templates/mls/tsconfig.json +0 -54
  226. package/templates/mls/webpack.config.ts +0 -248
  227. package/templates/optional/.cursor/mcp.json +0 -8
  228. package/templates/optional/.vscode/extensions.json +0 -6
  229. package/templates/optional/.vscode/mcp.json +0 -9
  230. package/templates/optional/AGENTS.md +0 -154
  231. package/templates/optional/CLAUDE.md +0 -154
@@ -1,418 +0,0 @@
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
- };
@@ -1,152 +0,0 @@
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
- };