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