@schandlergarcia/sf-web-components 2.3.17 → 2.4.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 (80) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/CLAUDE.md +12 -13
  3. package/README.md +0 -15
  4. package/dist/styles/global.css +44 -57
  5. package/package.json +1 -2
  6. package/scripts/apply-brand.mjs +47 -30
  7. package/scripts/postinstall.mjs +1 -11
  8. package/src/styles/global.css +44 -57
  9. package/brands/engine/PARTNER_HUB_PRD.md +0 -584
  10. package/brands/engine/agentApiConfig.ts +0 -36
  11. package/brands/engine/app/api/graphql-operations-types.ts +0 -11260
  12. package/brands/engine/app/api/graphqlClient.ts +0 -25
  13. package/brands/engine/app/api/partnerQueries.ts +0 -212
  14. package/brands/engine/app/appLayout.tsx +0 -5
  15. package/brands/engine/app/components/AgentPanel.tsx +0 -541
  16. package/brands/engine/app/components/AgentforceConversationClient.tsx +0 -201
  17. package/brands/engine/app/components/Data360Widget.tsx +0 -301
  18. package/brands/engine/app/components/__inherit_AgentforceConversationClient.tsx +0 -3
  19. package/brands/engine/app/components/alerts/status-alert.tsx +0 -49
  20. package/brands/engine/app/components/layouts/card-layout.tsx +0 -29
  21. package/brands/engine/app/components/workspace/CommandCenter.tsx +0 -16
  22. package/brands/engine/app/config/agentApi.ts +0 -36
  23. package/brands/engine/app/data/partner-hub-sample-data.js +0 -297
  24. package/brands/engine/app/features/object-search/__examples__/api/accountSearchService.ts +0 -46
  25. package/brands/engine/app/features/object-search/__examples__/api/query/distinctAccountIndustries.graphql +0 -19
  26. package/brands/engine/app/features/object-search/__examples__/api/query/distinctAccountTypes.graphql +0 -19
  27. package/brands/engine/app/features/object-search/__examples__/api/query/getAccountDetail.graphql +0 -121
  28. package/brands/engine/app/features/object-search/__examples__/api/query/searchAccounts.graphql +0 -51
  29. package/brands/engine/app/features/object-search/__examples__/pages/AccountObjectDetailPage.tsx +0 -357
  30. package/brands/engine/app/features/object-search/__examples__/pages/AccountSearch.tsx +0 -312
  31. package/brands/engine/app/features/object-search/__examples__/pages/Home.tsx +0 -34
  32. package/brands/engine/app/features/object-search/api/objectSearchService.ts +0 -84
  33. package/brands/engine/app/features/object-search/components/ActiveFilters.tsx +0 -89
  34. package/brands/engine/app/features/object-search/components/FilterContext.tsx +0 -83
  35. package/brands/engine/app/features/object-search/components/ObjectBreadcrumb.tsx +0 -66
  36. package/brands/engine/app/features/object-search/components/PaginationControls.tsx +0 -109
  37. package/brands/engine/app/features/object-search/components/SearchBar.tsx +0 -41
  38. package/brands/engine/app/features/object-search/components/SortControl.tsx +0 -143
  39. package/brands/engine/app/features/object-search/components/filters/BooleanFilter.tsx +0 -78
  40. package/brands/engine/app/features/object-search/components/filters/DateFilter.tsx +0 -128
  41. package/brands/engine/app/features/object-search/components/filters/DateRangeFilter.tsx +0 -70
  42. package/brands/engine/app/features/object-search/components/filters/FilterFieldWrapper.tsx +0 -33
  43. package/brands/engine/app/features/object-search/components/filters/MultiSelectFilter.tsx +0 -97
  44. package/brands/engine/app/features/object-search/components/filters/NumericRangeFilter.tsx +0 -163
  45. package/brands/engine/app/features/object-search/components/filters/SearchFilter.tsx +0 -50
  46. package/brands/engine/app/features/object-search/components/filters/SelectFilter.tsx +0 -97
  47. package/brands/engine/app/features/object-search/components/filters/TextFilter.tsx +0 -91
  48. package/brands/engine/app/features/object-search/hooks/useAsyncData.ts +0 -54
  49. package/brands/engine/app/features/object-search/hooks/useCachedAsyncData.ts +0 -184
  50. package/brands/engine/app/features/object-search/hooks/useDebouncedCallback.ts +0 -34
  51. package/brands/engine/app/features/object-search/hooks/useObjectSearchParams.ts +0 -252
  52. package/brands/engine/app/features/object-search/utils/debounce.ts +0 -25
  53. package/brands/engine/app/features/object-search/utils/fieldUtils.ts +0 -29
  54. package/brands/engine/app/features/object-search/utils/filterUtils.ts +0 -404
  55. package/brands/engine/app/features/object-search/utils/sortUtils.ts +0 -38
  56. package/brands/engine/app/hooks/useEngineLiveData.ts +0 -49
  57. package/brands/engine/app/hooks/useEvaAgent.ts +0 -288
  58. package/brands/engine/app/hooks/usePartnerDashboardData.ts +0 -141
  59. package/brands/engine/app/navigationMenu.tsx +0 -80
  60. package/brands/engine/app/pages/AccountObjectDetailPage.tsx +0 -361
  61. package/brands/engine/app/pages/AccountSearch.tsx +0 -305
  62. package/brands/engine/app/pages/BlankDashboard.tsx +0 -15
  63. package/brands/engine/app/pages/DataTest.tsx +0 -78
  64. package/brands/engine/app/pages/Home.tsx +0 -5
  65. package/brands/engine/app/pages/NotFound.tsx +0 -19
  66. package/brands/engine/app/pages/PartnerHubDashboard.tsx +0 -2760
  67. package/brands/engine/app/pages/Search.tsx +0 -13
  68. package/brands/engine/app/router-utils.tsx +0 -35
  69. package/brands/engine/app/routes.tsx +0 -39
  70. package/brands/engine/app/styles/global.css +0 -269
  71. package/brands/engine/brand.css +0 -40
  72. package/brands/engine/engine-command-center-prd.md +0 -575
  73. package/brands/engine/engine-live-data.js +0 -135
  74. package/brands/engine/engine-sample-data.js +0 -378
  75. package/brands/engine/engine_logo.png +0 -0
  76. package/brands/engine/global.css +0 -269
  77. package/brands/engine/partner-hub-sample-data.js +0 -281
  78. package/brands/engine/schema.graphql +0 -292
  79. package/brands/engine/useEngineLiveData.ts +0 -49
  80. package/brands/engine/useEvaAgent.ts +0 -288
@@ -1,361 +0,0 @@
1
- import { useState } from "react";
2
- import { useParams, useNavigate } from "react-router";
3
- import { createDataSDK } from "@salesforce/sdk-data";
4
- import { AlertCircle, ChevronDown, ChevronRight, FileQuestion } from "lucide-react";
5
- import GET_ACCOUNT_DETAIL from "../api/account/query/getAccountDetail.graphql?raw";
6
- import type {
7
- GetAccountDetailQuery,
8
- GetAccountDetailQueryVariables,
9
- } from "../api/graphql-operations-types";
10
- import { Alert, AlertTitle, AlertDescription } from "../components/ui/alert";
11
- import { Button } from "../components/ui/button";
12
- import { Card, CardContent } from "../components/ui/card";
13
- import {
14
- fieldValue,
15
- getAddressFieldLines,
16
- formatDateTimeField,
17
- } from "../features/object-search/utils/fieldUtils";
18
- import {
19
- Collapsible,
20
- CollapsibleTrigger,
21
- CollapsibleContent,
22
- } from "../components/ui/collapsible";
23
- import { Separator } from "../components/ui/separator";
24
- import { Skeleton } from "../components/ui/skeleton";
25
- import { useCachedAsyncData } from "../features/object-search/hooks/useCachedAsyncData";
26
- import { ObjectBreadcrumb } from "../features/object-search/components/ObjectBreadcrumb";
27
-
28
- type AccountNode = NonNullable<
29
- NonNullable<
30
- NonNullable<NonNullable<GetAccountDetailQuery["uiapi"]["query"]["Account"]>["edges"]>[number]
31
- >["node"]
32
- >;
33
-
34
- async function fetchAccountDetail(recordId: string): Promise<AccountNode | null | undefined> {
35
- const data = await createDataSDK();
36
- const response = await data.graphql?.<GetAccountDetailQuery, GetAccountDetailQueryVariables>(
37
- GET_ACCOUNT_DETAIL,
38
- { id: recordId },
39
- );
40
-
41
- if (response?.errors?.length) {
42
- throw new Error(response.errors.map((e) => e.message).join("; "));
43
- }
44
-
45
- return response?.data?.uiapi?.query?.Account?.edges?.[0]?.node;
46
- }
47
-
48
- export default function AccountObjectDetail() {
49
- const { recordId } = useParams();
50
- const navigate = useNavigate();
51
-
52
- const {
53
- data: account,
54
- loading,
55
- error,
56
- } = useCachedAsyncData(() => fetchAccountDetail(recordId!), [recordId], {
57
- key: `account:${recordId}`,
58
- });
59
-
60
- return (
61
- <div className="max-w-6xl mx-auto px-4 sm:px-6 lg:px-8 py-6">
62
- <ObjectBreadcrumb
63
- listPath="/accounts"
64
- listLabel="Accounts"
65
- loading={loading}
66
- recordName={
67
- account
68
- ? (fieldValue(account.Name) ?? "")
69
- : error
70
- ? "Error"
71
- : loading
72
- ? undefined
73
- : "Not Found"
74
- }
75
- />
76
-
77
- {/* Loading state */}
78
- {loading && <AccountDetailSkeleton />}
79
-
80
- {/* Error state */}
81
- {error && <AccountDetailError onBack={() => navigate(-1)} />}
82
-
83
- {/* Not found state */}
84
- {!loading && !error && !account && <AccountDetailNotFound onBack={() => navigate(-1)} />}
85
-
86
- {/* Content */}
87
- {account && <AccountDetailContent account={account} />}
88
- </div>
89
- );
90
- }
91
-
92
- function AccountDetailContent({ account }: { account: AccountNode }) {
93
- const billingAddress = getAddressFieldLines({
94
- street: fieldValue(account.BillingStreet),
95
- city: fieldValue(account.BillingCity),
96
- state: fieldValue(account.BillingState),
97
- postalCode: fieldValue(account.BillingPostalCode),
98
- country: fieldValue(account.BillingCountry),
99
- });
100
-
101
- const shippingAddress = getAddressFieldLines({
102
- street: fieldValue(account.ShippingStreet),
103
- city: fieldValue(account.ShippingCity),
104
- state: fieldValue(account.ShippingState),
105
- postalCode: fieldValue(account.ShippingPostalCode),
106
- country: fieldValue(account.ShippingCountry),
107
- });
108
-
109
- const dateTimeOptions = { dateStyle: "medium", timeStyle: "short" } as const;
110
- const createdDate = formatDateTimeField(
111
- fieldValue(account.CreatedDate),
112
- undefined,
113
- dateTimeOptions,
114
- );
115
- const lastModifiedDate = formatDateTimeField(
116
- fieldValue(account.LastModifiedDate),
117
- undefined,
118
- dateTimeOptions,
119
- );
120
-
121
- return (
122
- <>
123
- <h1 className="text-2xl font-bold mb-4">Account: {fieldValue(account.Name)}</h1>
124
-
125
- <Card>
126
- <CardContent className="space-y-8 pt-6">
127
- {/* Top section */}
128
- <div>
129
- <div className="space-y-4">
130
- <FieldRow>
131
- <FieldItem label="Account Owner">{fieldValue(account.Owner?.Name)}</FieldItem>
132
- <FieldItem label="Phone">
133
- <TelephoneField value={fieldValue(account.Phone)} />
134
- </FieldItem>
135
- </FieldRow>
136
- <FieldRow>
137
- <FieldItem label="Account Name">{fieldValue(account.Name)}</FieldItem>
138
- <FieldItem label="Fax">
139
- <TelephoneField value={fieldValue(account.Fax)} />
140
- </FieldItem>
141
- </FieldRow>
142
- <FieldRow>
143
- <FieldItem label="Parent Account">{fieldValue(account.Parent?.Name)}</FieldItem>
144
- <FieldItem label="Website">{fieldValue(account.Website)}</FieldItem>
145
- </FieldRow>
146
- </div>
147
- </div>
148
-
149
- <Separator />
150
-
151
- {/* Additional Information */}
152
- <Section title="Additional Information">
153
- <FieldRow>
154
- <FieldItem label="Type">{fieldValue(account.Type)}</FieldItem>
155
- <FieldItem label="Employees">{fieldValue(account.NumberOfEmployees)}</FieldItem>
156
- </FieldRow>
157
- <FieldRow>
158
- <FieldItem label="Industry">{fieldValue(account.Industry)}</FieldItem>
159
- <FieldItem label="Annual Revenue">{fieldValue(account.AnnualRevenue)}</FieldItem>
160
- </FieldRow>
161
- <FieldItem label="Description">{fieldValue(account.Description)}</FieldItem>
162
- </Section>
163
-
164
- <Separator />
165
-
166
- {/* Address Information */}
167
- <Section title="Address Information">
168
- <FieldRow>
169
- <FieldItem label="Billing Address">
170
- {billingAddress ? billingAddress.map((line, i) => <div key={i}>{line}</div>) : null}
171
- </FieldItem>
172
- <FieldItem label="Shipping Address">
173
- {shippingAddress
174
- ? shippingAddress.map((line, i) => <div key={i}>{line}</div>)
175
- : null}
176
- </FieldItem>
177
- </FieldRow>
178
- </Section>
179
-
180
- <Separator />
181
-
182
- {/* System Information */}
183
- <Section title="System Information">
184
- <FieldRow>
185
- <FieldItem label="Created By">
186
- {[fieldValue(account.CreatedBy?.Name), createdDate].filter(Boolean).join(" ") ||
187
- null}
188
- </FieldItem>
189
- <FieldItem label="Last Modified By">
190
- {[fieldValue(account.LastModifiedBy?.Name), lastModifiedDate]
191
- .filter(Boolean)
192
- .join(" ") || null}
193
- </FieldItem>
194
- </FieldRow>
195
- </Section>
196
- </CardContent>
197
- </Card>
198
- </>
199
- );
200
- }
201
-
202
- function TelephoneField({ value }: { value?: string | null }) {
203
- if (!value) return null;
204
- return (
205
- <a href={`tel:${value}`} className="underline">
206
- {value}
207
- </a>
208
- );
209
- }
210
-
211
- function FieldItem({ label, children }: { label: string; children: React.ReactNode }) {
212
- return (
213
- <div>
214
- <dt className="text-sm text-muted-foreground">{label}</dt>
215
- <dd className="mt-0.5">{children ?? "—"}</dd>
216
- </div>
217
- );
218
- }
219
-
220
- function FieldRow({ children }: { children: React.ReactNode }) {
221
- return <div className="grid grid-cols-2 gap-x-8 gap-y-4">{children}</div>;
222
- }
223
-
224
- function Section({ title, children }: { title: string; children: React.ReactNode }) {
225
- const [open, setOpen] = useState(true);
226
- return (
227
- <Collapsible open={open} onOpenChange={setOpen}>
228
- <CollapsibleTrigger className="flex items-center gap-2 cursor-pointer text-lg font-semibold py-2">
229
- {open ? <ChevronDown className="size-5" /> : <ChevronRight className="size-5" />}
230
- {title}
231
- </CollapsibleTrigger>
232
- <CollapsibleContent>
233
- <div className="mt-2 space-y-4">{children}</div>
234
- </CollapsibleContent>
235
- </Collapsible>
236
- );
237
- }
238
-
239
- function AccountDetailError({ onBack }: { onBack: () => void }) {
240
- return (
241
- <>
242
- <Alert variant="destructive" role="alert">
243
- <AlertCircle />
244
- <AlertTitle>
245
- <h2>Failed to load account</h2>
246
- </AlertTitle>
247
- <AlertDescription>
248
- Something went wrong while loading this account. Please try again later.
249
- </AlertDescription>
250
- </Alert>
251
- <div className="mt-4 flex gap-3">
252
- <Button variant="outline" onClick={onBack}>
253
- ← Back
254
- </Button>
255
- <Button variant="outline" onClick={() => window.location.reload()}>
256
- Retry
257
- </Button>
258
- </div>
259
- </>
260
- );
261
- }
262
-
263
- function AccountDetailNotFound({ onBack }: { onBack: () => void }) {
264
- return (
265
- <Card>
266
- <CardContent className="flex flex-col items-center justify-center py-16 text-center">
267
- <FileQuestion className="size-12 text-muted-foreground mb-4" />
268
- <h2 className="text-lg font-semibold mb-1">Account not found</h2>
269
- <p className="text-sm text-muted-foreground mb-6">
270
- The account you're looking for doesn't exist or may have been deleted.
271
- </p>
272
- <Button variant="outline" onClick={onBack}>
273
- ← Go back
274
- </Button>
275
- </CardContent>
276
- </Card>
277
- );
278
- }
279
-
280
- function AccountDetailSkeleton() {
281
- return (
282
- <>
283
- <Skeleton className="h-8 w-56 mb-4" />
284
-
285
- <Card>
286
- <CardContent className="space-y-8 pt-6">
287
- {/* Top section: field rows */}
288
- <div>
289
- <div className="space-y-4">
290
- <SkeletonFieldRow />
291
- <SkeletonFieldRow />
292
- <SkeletonFieldRow />
293
- </div>
294
- </div>
295
-
296
- <Separator />
297
-
298
- {/* Additional Information */}
299
- <SkeletonSection />
300
-
301
- <Separator />
302
-
303
- {/* Address Information */}
304
- <div className="space-y-4">
305
- <Skeleton className="h-7 w-48 py-2" />
306
- <div className="grid grid-cols-2 gap-x-8 gap-y-4">
307
- <div>
308
- <Skeleton className="h-4 w-28 mb-1.5" />
309
- <Skeleton className="h-5 w-44 mb-1" />
310
- <Skeleton className="h-5 w-36 mb-1" />
311
- <Skeleton className="h-5 w-28" />
312
- </div>
313
- <div>
314
- <Skeleton className="h-4 w-32 mb-1.5" />
315
- <Skeleton className="h-5 w-44 mb-1" />
316
- <Skeleton className="h-5 w-36 mb-1" />
317
- <Skeleton className="h-5 w-28" />
318
- </div>
319
- </div>
320
- </div>
321
-
322
- <Separator />
323
-
324
- {/* System Information */}
325
- <div className="space-y-4">
326
- <Skeleton className="h-7 w-48 py-2" />
327
- <SkeletonFieldRow />
328
- </div>
329
- </CardContent>
330
- </Card>
331
- </>
332
- );
333
- }
334
-
335
- function SkeletonField() {
336
- return (
337
- <div>
338
- <Skeleton className="h-4 w-24 mb-1.5" />
339
- <Skeleton className="h-5 w-40" />
340
- </div>
341
- );
342
- }
343
-
344
- function SkeletonFieldRow() {
345
- return (
346
- <div className="grid grid-cols-2 gap-x-8 gap-y-4">
347
- <SkeletonField />
348
- <SkeletonField />
349
- </div>
350
- );
351
- }
352
-
353
- function SkeletonSection() {
354
- return (
355
- <div className="space-y-4">
356
- <Skeleton className="h-7 w-48 py-2" />
357
- <SkeletonFieldRow />
358
- <SkeletonFieldRow />
359
- </div>
360
- );
361
- }
@@ -1,305 +0,0 @@
1
- import { useMemo, useState } from "react";
2
- import { Link } from "react-router";
3
- import { AlertCircle, ChevronDown, SearchX } from "lucide-react";
4
- import {
5
- searchAccounts,
6
- fetchDistinctIndustries,
7
- fetchDistinctTypes,
8
- } from "../api/account/accountSearchService";
9
- import { useCachedAsyncData } from "../features/object-search/hooks/useCachedAsyncData";
10
- import { fieldValue } from "../features/object-search/utils/fieldUtils";
11
- import { useObjectSearchParams } from "../features/object-search/hooks/useObjectSearchParams";
12
- import { Alert, AlertTitle, AlertDescription } from "../components/ui/alert";
13
- import { Card, CardContent, CardHeader, CardTitle } from "../components/ui/card";
14
- import { Button } from "../components/ui/button";
15
- import {
16
- Collapsible,
17
- CollapsibleContent,
18
- CollapsibleTrigger,
19
- } from "../components/ui/collapsible";
20
- import { Skeleton } from "../components/ui/skeleton";
21
- import {
22
- FilterProvider,
23
- FilterResetButton,
24
- } from "../features/object-search/components/FilterContext";
25
- import { SearchFilter } from "../features/object-search/components/filters/SearchFilter";
26
- import { TextFilter } from "../features/object-search/components/filters/TextFilter";
27
- import { SelectFilter } from "../features/object-search/components/filters/SelectFilter";
28
- import { MultiSelectFilter } from "../features/object-search/components/filters/MultiSelectFilter";
29
- import { NumericRangeFilter } from "../features/object-search/components/filters/NumericRangeFilter";
30
- import { DateFilter } from "../features/object-search/components/filters/DateFilter";
31
- import { DateRangeFilter } from "../features/object-search/components/filters/DateRangeFilter";
32
- import { ActiveFilters } from "../features/object-search/components/ActiveFilters";
33
- import { SortControl } from "../features/object-search/components/SortControl";
34
- import type { FilterFieldConfig } from "../features/object-search/utils/filterUtils";
35
- import type { SortFieldConfig } from "../features/object-search/utils/sortUtils";
36
- import type { Account_Filter, Account_OrderBy } from "../api/graphql-operations-types";
37
- import type { AccountSearchResult } from "../api/account/accountSearchService";
38
- import { ObjectBreadcrumb } from "../features/object-search/components/ObjectBreadcrumb";
39
- import PaginationControls from "../features/object-search/components/PaginationControls";
40
- import type { PaginationConfig } from "../features/object-search/hooks/useObjectSearchParams";
41
-
42
- const PAGINATION_CONFIG: PaginationConfig = {
43
- defaultPageSize: 6,
44
- validPageSizes: [6, 12, 24, 48],
45
- };
46
-
47
- type AccountNode = NonNullable<
48
- NonNullable<NonNullable<AccountSearchResult["edges"]>[number]>["node"]
49
- >;
50
-
51
- const FILTER_CONFIGS: FilterFieldConfig[] = [
52
- {
53
- field: "search",
54
- label: "Search",
55
- type: "search",
56
- searchFields: ["Name", "Phone", "Industry"],
57
- placeholder: "Search by name, phone, or industry...",
58
- },
59
- { field: "Name", label: "Account Name", type: "text", placeholder: "Search by name..." },
60
- { field: "Industry", label: "Industry", type: "picklist" },
61
- { field: "Type", label: "Type", type: "multipicklist" },
62
- { field: "AnnualRevenue", label: "Annual Revenue", type: "numeric" },
63
- { field: "CreatedDate", label: "Created Date", type: "datetime" },
64
- { field: "LastModifiedDate", label: "Last Modified Date", type: "datetimerange" },
65
- ];
66
-
67
- const ACCOUNT_SORT_CONFIGS: SortFieldConfig<keyof Account_OrderBy>[] = [
68
- { field: "Name", label: "Name" },
69
- { field: "AnnualRevenue", label: "Annual Revenue" },
70
- { field: "Industry", label: "Industry" },
71
- { field: "CreatedDate", label: "Created Date" },
72
- ];
73
-
74
- // -- Component --------------------------------------------------------------
75
-
76
- export default function AccountSearch() {
77
- const [filtersOpen, setFiltersOpen] = useState(true);
78
- const { data: industryOptions } = useCachedAsyncData(fetchDistinctIndustries, [], {
79
- key: "distinctIndustries",
80
- ttl: 300_000,
81
- });
82
- const { data: typeOptions } = useCachedAsyncData(fetchDistinctTypes, [], {
83
- key: "distinctTypes",
84
- ttl: 300_000,
85
- });
86
-
87
- const { filters, sort, query, pagination, resetAll } = useObjectSearchParams<
88
- Account_Filter,
89
- Account_OrderBy
90
- >(FILTER_CONFIGS, ACCOUNT_SORT_CONFIGS, PAGINATION_CONFIG);
91
-
92
- const searchKey = `accounts:${JSON.stringify({ where: query.where, orderBy: query.orderBy, first: pagination.pageSize, after: pagination.afterCursor })}`;
93
- const { data, loading, error } = useCachedAsyncData(
94
- () =>
95
- searchAccounts({
96
- where: query.where,
97
- orderBy: query.orderBy,
98
- first: pagination.pageSize,
99
- after: pagination.afterCursor,
100
- }),
101
- [query.where, query.orderBy, pagination.pageSize, pagination.afterCursor],
102
- { key: searchKey },
103
- );
104
-
105
- const pageInfo = data?.pageInfo;
106
- const totalCount = data?.totalCount;
107
- const hasNextPage = pageInfo?.hasNextPage ?? false;
108
- const hasPreviousPage = pagination.pageIndex > 0;
109
-
110
- const validAccountNodes = useMemo(
111
- () =>
112
- (data?.edges ?? []).reduce<AccountNode[]>((acc, edge) => {
113
- if (edge?.node) acc.push(edge.node);
114
- return acc;
115
- }, []),
116
- [data?.edges],
117
- );
118
-
119
- return (
120
- <div className="max-w-6xl mx-auto px-4 sm:px-6 lg:px-8 py-6">
121
- <ObjectBreadcrumb listPath="/accounts" listLabel="Accounts" />
122
-
123
- <h1 className="text-2xl font-bold mb-4">Search Accounts</h1>
124
-
125
- <div className="flex flex-col lg:flex-row gap-6">
126
- {/* Sidebar — Filter Panel */}
127
- <aside className="w-full lg:w-80 shrink-0">
128
- <FilterProvider
129
- filters={filters.active}
130
- onFilterChange={filters.set}
131
- onFilterRemove={filters.remove}
132
- onReset={resetAll}
133
- >
134
- <Card>
135
- <Collapsible open={filtersOpen} onOpenChange={setFiltersOpen}>
136
- <CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
137
- <CardTitle className="text-base font-semibold">
138
- <h2>Filters</h2>
139
- </CardTitle>
140
- <div className="flex items-center gap-1">
141
- <FilterResetButton variant="destructive" size="sm" />
142
- <CollapsibleTrigger asChild>
143
- <Button variant="ghost" size="icon">
144
- <ChevronDown
145
- className={`h-4 w-4 transition-transform ${filtersOpen ? "" : "-rotate-90"}`}
146
- />
147
- <span className="sr-only">Toggle filters</span>
148
- </Button>
149
- </CollapsibleTrigger>
150
- </div>
151
- </CardHeader>
152
- <CollapsibleContent>
153
- <CardContent className="space-y-1 pt-0">
154
- <SearchFilter
155
- field="search"
156
- label="Search"
157
- placeholder="Search by name, phone, or industry..."
158
- />
159
- <TextFilter field="Name" label="Account Name" placeholder="Search by name..." />
160
- <SelectFilter
161
- field="Industry"
162
- label="Industry"
163
- options={industryOptions ?? []}
164
- />
165
- <MultiSelectFilter field="Type" label="Type" options={typeOptions ?? []} />
166
- <NumericRangeFilter field="AnnualRevenue" label="Annual Revenue" />
167
- <DateFilter field="CreatedDate" label="Created Date" filterType="datetime" />
168
- <DateRangeFilter
169
- field="LastModifiedDate"
170
- label="Last Modified Date"
171
- filterType="datetimerange"
172
- />
173
- </CardContent>
174
- </CollapsibleContent>
175
- </Collapsible>
176
- </Card>
177
- </FilterProvider>
178
- </aside>
179
-
180
- {/* Main area — Sort + Results */}
181
- <div className="flex-1 min-w-0">
182
- {/* Sort control + active filters */}
183
- <div className="flex flex-wrap items-center gap-2 mb-4">
184
- <SortControl
185
- configs={ACCOUNT_SORT_CONFIGS}
186
- sort={sort.current}
187
- onSortChange={sort.set}
188
- />
189
- <ActiveFilters filters={filters.active} onRemove={filters.remove} />
190
- </div>
191
-
192
- <div className="min-h-112">
193
- {/* Loading state */}
194
- {loading && (
195
- <>
196
- <Skeleton className="h-5 w-30 mb-3" />
197
- <div className="divide-y">
198
- {Array.from({ length: pagination.pageSize }, (_, i) => (
199
- <div key={i} className="flex items-center justify-between py-3">
200
- <div className="space-y-2">
201
- <Skeleton className="h-5 w-40" />
202
- <Skeleton className="h-4 w-28" />
203
- </div>
204
- <div className="space-y-2 flex flex-col items-end">
205
- <Skeleton className="h-4 w-24" />
206
- <Skeleton className="h-4 w-20" />
207
- </div>
208
- </div>
209
- ))}
210
- </div>
211
- </>
212
- )}
213
-
214
- {/* Error state */}
215
- {error && (
216
- <>
217
- <p className="text-sm text-muted-foreground mb-3">0 accounts found</p>
218
- <Alert variant="destructive" role="alert">
219
- <AlertCircle />
220
- <AlertTitle>Failed to load accounts</AlertTitle>
221
- <AlertDescription>
222
- Something went wrong while loading accounts. Please try again later.
223
- </AlertDescription>
224
- </Alert>
225
- </>
226
- )}
227
-
228
- {/* Results list */}
229
- {!loading && !error && validAccountNodes.length > 0 && (
230
- <>
231
- <p className="text-sm text-muted-foreground mb-3">
232
- {totalCount != null && (hasNextPage || hasPreviousPage)
233
- ? `${totalCount} account${totalCount !== 1 ? "s" : ""} found`
234
- : `Showing ${validAccountNodes.length} account${validAccountNodes.length !== 1 ? "s" : ""}`}
235
- </p>
236
- <AccountResultsList nodes={validAccountNodes} />
237
- </>
238
- )}
239
-
240
- {/* No results state */}
241
- {!loading && !error && validAccountNodes.length === 0 && (
242
- <div className="flex flex-col items-center justify-center py-16 text-center">
243
- <SearchX className="size-12 text-muted-foreground mb-4" />
244
- <h2 className="text-lg font-semibold mb-1">No accounts found</h2>
245
- <p className="text-sm text-muted-foreground">
246
- Try adjusting your filters or search criteria.
247
- </p>
248
- </div>
249
- )}
250
- </div>
251
-
252
- {/* Pagination — always visible, disabled while loading or on error */}
253
- <PaginationControls
254
- pageIndex={pagination.pageIndex}
255
- hasNextPage={hasNextPage}
256
- hasPreviousPage={hasPreviousPage}
257
- pageSize={pagination.pageSize}
258
- pageSizeOptions={PAGINATION_CONFIG.validPageSizes}
259
- onNextPage={() => {
260
- if (pageInfo?.endCursor) pagination.goToNextPage(pageInfo.endCursor);
261
- }}
262
- onPreviousPage={pagination.goToPreviousPage}
263
- onPageSizeChange={pagination.setPageSize}
264
- disabled={loading || !!error}
265
- />
266
- </div>
267
- </div>
268
- </div>
269
- );
270
- }
271
-
272
- // -- Result Components ------------------------------------------------------
273
-
274
- function AccountResultsList({ nodes }: { nodes: AccountNode[] }) {
275
- return (
276
- <ul className="divide-y">
277
- {nodes.map((node) => (
278
- <AccountResultItem key={node.Id} node={node} />
279
- ))}
280
- </ul>
281
- );
282
- }
283
-
284
- function AccountResultItem({ node }: { node: AccountNode }) {
285
- return (
286
- <li>
287
- <Link
288
- to={`/accounts/${node.Id}`}
289
- className="flex items-center justify-between py-3 px-3 -mx-3 rounded-md transition-colors hover:bg-accent"
290
- >
291
- <div>
292
- <span className="font-medium">{fieldValue(node.Name) ?? "\u2014"}</span>
293
- <p className="text-sm text-muted-foreground">
294
- {[fieldValue(node.Industry), fieldValue(node.Type)].filter(Boolean).join(" \u00B7 ") ||
295
- "\u2014"}
296
- </p>
297
- </div>
298
- <div className="text-right text-sm">
299
- <p>{fieldValue(node.Phone) ?? ""}</p>
300
- <p className="text-muted-foreground">{fieldValue(node.Owner?.Name) ?? ""}</p>
301
- </div>
302
- </Link>
303
- </li>
304
- );
305
- }
@@ -1,15 +0,0 @@
1
- import { RocketLaunchIcon } from "@heroicons/react/24/outline";
2
- import { EmptyState } from "@/components/library";
3
-
4
- export default function BlankDashboard() {
5
- return (
6
- <div className="flex min-h-screen items-center justify-center bg-slate-50 dark:bg-slate-950 transition-colors">
7
- <EmptyState
8
- size="lg"
9
- icon={<RocketLaunchIcon className="h-14 w-14" />}
10
- heading="Bespoke App Template"
11
- body="Component library loaded and ready to go."
12
- />
13
- </div>
14
- );
15
- }