@schandlergarcia/sf-web-components 2.2.1 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -2
- package/brands/engine/app/api/graphql-operations-types.ts +11260 -0
- package/brands/engine/app/api/graphqlClient.ts +25 -0
- package/brands/engine/app/api/partnerQueries.ts +212 -0
- package/brands/engine/app/appLayout.tsx +13 -0
- package/brands/engine/app/components/AgentforceConversationClient.tsx +201 -0
- package/brands/engine/app/components/__inherit_AgentforceConversationClient.tsx +3 -0
- package/brands/engine/app/components/alerts/status-alert.tsx +49 -0
- package/brands/engine/app/components/layouts/card-layout.tsx +29 -0
- package/brands/engine/app/components/workspace/CommandCenter.tsx +16 -0
- package/brands/engine/app/config/agentApi.ts +36 -0
- package/brands/engine/app/features/object-search/__examples__/api/accountSearchService.ts +46 -0
- package/brands/engine/app/features/object-search/__examples__/api/query/distinctAccountIndustries.graphql +19 -0
- package/brands/engine/app/features/object-search/__examples__/api/query/distinctAccountTypes.graphql +19 -0
- package/brands/engine/app/features/object-search/__examples__/api/query/getAccountDetail.graphql +121 -0
- package/brands/engine/app/features/object-search/__examples__/api/query/searchAccounts.graphql +51 -0
- package/brands/engine/app/features/object-search/__examples__/pages/AccountObjectDetailPage.tsx +357 -0
- package/brands/engine/app/features/object-search/__examples__/pages/AccountSearch.tsx +312 -0
- package/brands/engine/app/features/object-search/__examples__/pages/Home.tsx +34 -0
- package/brands/engine/app/features/object-search/api/objectSearchService.ts +84 -0
- package/brands/engine/app/features/object-search/components/ActiveFilters.tsx +89 -0
- package/brands/engine/app/features/object-search/components/FilterContext.tsx +83 -0
- package/brands/engine/app/features/object-search/components/ObjectBreadcrumb.tsx +66 -0
- package/brands/engine/app/features/object-search/components/PaginationControls.tsx +109 -0
- package/brands/engine/app/features/object-search/components/SearchBar.tsx +41 -0
- package/brands/engine/app/features/object-search/components/SortControl.tsx +143 -0
- package/brands/engine/app/features/object-search/components/filters/BooleanFilter.tsx +78 -0
- package/brands/engine/app/features/object-search/components/filters/DateFilter.tsx +128 -0
- package/brands/engine/app/features/object-search/components/filters/DateRangeFilter.tsx +70 -0
- package/brands/engine/app/features/object-search/components/filters/FilterFieldWrapper.tsx +33 -0
- package/brands/engine/app/features/object-search/components/filters/MultiSelectFilter.tsx +97 -0
- package/brands/engine/app/features/object-search/components/filters/NumericRangeFilter.tsx +163 -0
- package/brands/engine/app/features/object-search/components/filters/SearchFilter.tsx +50 -0
- package/brands/engine/app/features/object-search/components/filters/SelectFilter.tsx +97 -0
- package/brands/engine/app/features/object-search/components/filters/TextFilter.tsx +91 -0
- package/brands/engine/app/features/object-search/hooks/useAsyncData.ts +54 -0
- package/brands/engine/app/features/object-search/hooks/useCachedAsyncData.ts +184 -0
- package/brands/engine/app/features/object-search/hooks/useDebouncedCallback.ts +34 -0
- package/brands/engine/app/features/object-search/hooks/useObjectSearchParams.ts +252 -0
- package/brands/engine/app/features/object-search/utils/debounce.ts +25 -0
- package/brands/engine/app/features/object-search/utils/fieldUtils.ts +29 -0
- package/brands/engine/app/features/object-search/utils/filterUtils.ts +404 -0
- package/brands/engine/app/features/object-search/utils/sortUtils.ts +38 -0
- package/brands/engine/app/hooks/useEngineLiveData.ts +49 -0
- package/brands/engine/app/hooks/useEvaAgent.ts +288 -0
- package/brands/engine/app/hooks/usePartnerDashboardData.ts +141 -0
- package/brands/engine/app/navigationMenu.tsx +80 -0
- package/brands/engine/app/pages/AccountObjectDetailPage.tsx +361 -0
- package/brands/engine/app/pages/AccountSearch.tsx +305 -0
- package/brands/engine/app/pages/BlankDashboard.tsx +15 -0
- package/brands/engine/app/pages/DataTest.tsx +78 -0
- package/brands/engine/app/pages/Home.tsx +5 -0
- package/brands/engine/app/pages/NotFound.tsx +19 -0
- package/brands/engine/app/pages/PartnerHubDashboard.tsx +2010 -0
- package/brands/engine/app/pages/Search.tsx +13 -0
- package/brands/engine/app/router-utils.tsx +35 -0
- package/brands/engine/app/routes.tsx +39 -0
- package/brands/engine/app/styles/global.css +270 -0
- package/package.json +1 -1
- package/scripts/apply-brand.mjs +159 -76
- package/scripts/postinstall.mjs +6 -0
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Thin GraphQL client: createDataSDK + data.graphql with centralized error handling.
|
|
3
|
+
* Use with gql-tagged queries and generated operation types for type-safe calls.
|
|
4
|
+
*/
|
|
5
|
+
import { createDataSDK } from '@salesforce/sdk-data';
|
|
6
|
+
|
|
7
|
+
export async function executeGraphQL<TData, TVariables>(
|
|
8
|
+
query: string,
|
|
9
|
+
variables?: TVariables
|
|
10
|
+
): Promise<TData> {
|
|
11
|
+
const data = await createDataSDK();
|
|
12
|
+
// SDK types graphql() first param as string; at runtime it may accept gql DocumentNode too
|
|
13
|
+
const response = await data.graphql?.<TData, TVariables>(query, variables);
|
|
14
|
+
|
|
15
|
+
if (!response) {
|
|
16
|
+
throw new Error('GraphQL response is undefined');
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if (response?.errors?.length) {
|
|
20
|
+
const msg = response.errors.map(e => e.message).join('; ');
|
|
21
|
+
throw new Error(`GraphQL Error: ${msg}`);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return response.data;
|
|
25
|
+
}
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import { gql } from "@salesforce/sdk-data";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Partner Hub GraphQL Queries
|
|
5
|
+
*
|
|
6
|
+
* These queries fetch partner dashboard data from Salesforce using UI API GraphQL.
|
|
7
|
+
* All custom fields use @optional to handle null values gracefully.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
// Get current user
|
|
11
|
+
export const GET_CURRENT_USER = gql`
|
|
12
|
+
query GetCurrentUser {
|
|
13
|
+
uiapi {
|
|
14
|
+
currentUser {
|
|
15
|
+
Id
|
|
16
|
+
Name @optional { value }
|
|
17
|
+
Email @optional { value }
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
`;
|
|
22
|
+
|
|
23
|
+
// Get partner Account with custom fields
|
|
24
|
+
export const GET_PARTNER_ACCOUNT = gql`
|
|
25
|
+
query GetPartnerAccount($accountId: ID!) {
|
|
26
|
+
uiapi {
|
|
27
|
+
query {
|
|
28
|
+
Account(where: { Id: { eq: $accountId } }, first: 1) {
|
|
29
|
+
edges {
|
|
30
|
+
node {
|
|
31
|
+
Id
|
|
32
|
+
Name @optional { value }
|
|
33
|
+
Type @optional { value }
|
|
34
|
+
Partner_Tier__c @optional { value }
|
|
35
|
+
Commission_Rate__c @optional { value }
|
|
36
|
+
Partner_Status__c @optional { value }
|
|
37
|
+
Total_Properties__c @optional { value }
|
|
38
|
+
Total_Reservations__c @optional { value }
|
|
39
|
+
Total_Revenue__c @optional { value }
|
|
40
|
+
Contract_Start_Date__c @optional { value }
|
|
41
|
+
Contract_End_Date__c @optional { value }
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
`;
|
|
49
|
+
|
|
50
|
+
// Find first Partner account (when no partnerId provided)
|
|
51
|
+
export const FIND_PARTNER_ACCOUNT = gql`
|
|
52
|
+
query FindPartnerAccount {
|
|
53
|
+
uiapi {
|
|
54
|
+
query {
|
|
55
|
+
Account(where: { Type: { eq: "Partner" } }, first: 1) {
|
|
56
|
+
edges {
|
|
57
|
+
node {
|
|
58
|
+
Id
|
|
59
|
+
Name @optional { value }
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
`;
|
|
67
|
+
|
|
68
|
+
// Get contracts for partner
|
|
69
|
+
export const GET_CONTRACTS = gql`
|
|
70
|
+
query GetContracts($accountId: ID!) {
|
|
71
|
+
uiapi {
|
|
72
|
+
query {
|
|
73
|
+
Contract__c(where: { Hotel_Partner__c: { eq: $accountId } }, first: 50) {
|
|
74
|
+
edges {
|
|
75
|
+
node {
|
|
76
|
+
Id
|
|
77
|
+
Name @optional { value }
|
|
78
|
+
Contract_Status__c @optional { value }
|
|
79
|
+
Attrition_Calculation_Method__c @optional { value }
|
|
80
|
+
Attrition_Threshold_Percentage__c @optional { value }
|
|
81
|
+
Resale_Credit_Policy__c @optional { value }
|
|
82
|
+
Resale_Credit_Percentage__c @optional { value }
|
|
83
|
+
Commission_Rate__c @optional { value }
|
|
84
|
+
Start_Date__c @optional { value }
|
|
85
|
+
End_Date__c @optional { value }
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
`;
|
|
93
|
+
|
|
94
|
+
// Get invoices for partner
|
|
95
|
+
export const GET_INVOICES = gql`
|
|
96
|
+
query GetInvoices($accountId: ID!) {
|
|
97
|
+
uiapi {
|
|
98
|
+
query {
|
|
99
|
+
Invoice__c(where: { Hotel_Partner__c: { eq: $accountId } }, first: 50, orderBy: { Invoice_Date__c: { order: DESC } }) {
|
|
100
|
+
edges {
|
|
101
|
+
node {
|
|
102
|
+
Id
|
|
103
|
+
Name @optional { value }
|
|
104
|
+
Invoice_Status__c @optional { value }
|
|
105
|
+
Invoice_Date__c @optional { value }
|
|
106
|
+
Due_Date__c @optional { value }
|
|
107
|
+
Invoice_Period_Start__c @optional { value }
|
|
108
|
+
Invoice_Period_End__c @optional { value }
|
|
109
|
+
Invoice_Total__c @optional { value }
|
|
110
|
+
Total_Commission__c @optional { value }
|
|
111
|
+
Total_Attrition_Penalties__c @optional { value }
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
`;
|
|
119
|
+
|
|
120
|
+
// Get attrition penalties for partner (via Contract relationship)
|
|
121
|
+
export const GET_PENALTIES = gql`
|
|
122
|
+
query GetPenalties($accountId: ID!) {
|
|
123
|
+
uiapi {
|
|
124
|
+
query {
|
|
125
|
+
Attrition_Penalty__c(
|
|
126
|
+
where: {
|
|
127
|
+
Contract__r: { Hotel_Partner__c: { eq: $accountId } }
|
|
128
|
+
}
|
|
129
|
+
first: 50
|
|
130
|
+
) {
|
|
131
|
+
edges {
|
|
132
|
+
node {
|
|
133
|
+
Id
|
|
134
|
+
Name @optional { value }
|
|
135
|
+
Penalty_Status__c @optional { value }
|
|
136
|
+
Original_Room_Block__c @optional { value }
|
|
137
|
+
Actual_Rooms_Used__c @optional { value }
|
|
138
|
+
Unused_Rooms__c @optional { value }
|
|
139
|
+
Room_Rate__c @optional { value }
|
|
140
|
+
Number_of_Nights__c @optional { value }
|
|
141
|
+
Rooms_Resold__c @optional { value }
|
|
142
|
+
Penalty_Amount_Calculated__c @optional { value }
|
|
143
|
+
Resale_Credit_Applied__c @optional { value }
|
|
144
|
+
Final_Penalty_Amount__c @optional { value }
|
|
145
|
+
Penalty_Date__c @optional { value }
|
|
146
|
+
Contract__c @optional { value }
|
|
147
|
+
Property__r @optional {
|
|
148
|
+
Name @optional { value }
|
|
149
|
+
Property_Name__c @optional { value }
|
|
150
|
+
}
|
|
151
|
+
Customer_Company__r @optional {
|
|
152
|
+
Name @optional { value }
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
`;
|
|
161
|
+
|
|
162
|
+
// Get disputes (Cases with Partner_Dispute RecordType)
|
|
163
|
+
export const GET_DISPUTES = gql`
|
|
164
|
+
query GetDisputes($accountId: ID!) {
|
|
165
|
+
uiapi {
|
|
166
|
+
query {
|
|
167
|
+
Case(where: { AccountId: { eq: $accountId }, RecordType: { DeveloperName: { eq: "Partner_Dispute" } } }, first: 50) {
|
|
168
|
+
edges {
|
|
169
|
+
node {
|
|
170
|
+
Id
|
|
171
|
+
CaseNumber @optional { value }
|
|
172
|
+
Subject @optional { value }
|
|
173
|
+
Status @optional { value }
|
|
174
|
+
Priority @optional { value }
|
|
175
|
+
Dispute_Type__c @optional { value }
|
|
176
|
+
Disputed_Amount__c @optional { value }
|
|
177
|
+
Agent_Handled__c @optional { value }
|
|
178
|
+
Escalation_Reason__c @optional { value }
|
|
179
|
+
CreatedDate @optional { value }
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
`;
|
|
187
|
+
|
|
188
|
+
// Get properties for partner
|
|
189
|
+
export const GET_PROPERTIES = gql`
|
|
190
|
+
query GetProperties($accountId: ID!) {
|
|
191
|
+
uiapi {
|
|
192
|
+
query {
|
|
193
|
+
Property__c(where: { Hotel_Partner__c: { eq: $accountId } }, first: 50) {
|
|
194
|
+
edges {
|
|
195
|
+
node {
|
|
196
|
+
Id
|
|
197
|
+
Name @optional { value }
|
|
198
|
+
Property_Name__c @optional { value }
|
|
199
|
+
Property_Type__c @optional { value }
|
|
200
|
+
City__c @optional { value }
|
|
201
|
+
State__c @optional { value }
|
|
202
|
+
Country__c @optional { value }
|
|
203
|
+
Star_Rating__c @optional { value }
|
|
204
|
+
Total_Rooms__c @optional { value }
|
|
205
|
+
Active__c @optional { value }
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
`;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AgentforceConversationClient } from "./components/AgentforceConversationClient";
|
|
2
|
+
import { Outlet, Link, useLocation } from "react-router";
|
|
3
|
+
import { getAllRoutes } from "./router-utils";
|
|
4
|
+
import { useState } from "react";
|
|
5
|
+
|
|
6
|
+
export default function AppLayout() {
|
|
7
|
+
return (
|
|
8
|
+
<>
|
|
9
|
+
<Outlet />
|
|
10
|
+
<AgentforceConversationClient agentId="<USER_AGENT_ID_18_CHAR_0Xx...>" />
|
|
11
|
+
</>
|
|
12
|
+
);
|
|
13
|
+
}
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026, Salesforce, Inc.
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
* For full license text, see the LICENSE.txt file
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { embedAgentforceClient } from "@salesforce/agentforce-conversation-client";
|
|
8
|
+
import type { AgentforceClientConfig } from "@salesforce/agentforce-conversation-client";
|
|
9
|
+
import { useEffect, useMemo, useRef } from "react";
|
|
10
|
+
import type {
|
|
11
|
+
ResolvedEmbedOptions,
|
|
12
|
+
AgentforceConversationClientProps,
|
|
13
|
+
} from "../types/conversation";
|
|
14
|
+
|
|
15
|
+
const GLOBAL_HOST_ID = "agentforce-conversation-client-global-host";
|
|
16
|
+
|
|
17
|
+
const DEFAULT_STYLE_TOKENS: NonNullable<AgentforceClientConfig["styleTokens"]> = {
|
|
18
|
+
containerBackground: "#fafafa",
|
|
19
|
+
|
|
20
|
+
headerBlockBackground: "#372949",
|
|
21
|
+
headerBlockTextColor: "#ffffff",
|
|
22
|
+
headerBlockIconColor: "#ffffff",
|
|
23
|
+
headerBlockBorderBottomColor: "#3b0764",
|
|
24
|
+
headerBlockFocusBorder: "#c4b5fd",
|
|
25
|
+
|
|
26
|
+
messageBlockInboundBackgroundColor: "#ffffff",
|
|
27
|
+
messageBlockInboundTextColor: "#1f2937",
|
|
28
|
+
messageBlockInboundBorder: "1px solid #e5e7eb",
|
|
29
|
+
|
|
30
|
+
messageBlockOutboundBackgroundColor: "#ede9fe",
|
|
31
|
+
messageBlockOutboundTextColor: "#1f2937",
|
|
32
|
+
messageBlockOutboundBorder: "1px solid #d8b4fe",
|
|
33
|
+
|
|
34
|
+
messageInputTextColor: "#1f2937",
|
|
35
|
+
messageInputTextBackgroundColor: "#ffffff",
|
|
36
|
+
messageInputFooterBorderColor: "#d1d5db",
|
|
37
|
+
messageInputFooterBorderFocusColor: "#9ca3af",
|
|
38
|
+
messageInputFocusShadow: "0 0 0 3px rgba(156, 163, 175, 0.25)",
|
|
39
|
+
messageInputFooterPlaceholderText: "#6b7280",
|
|
40
|
+
|
|
41
|
+
messageInputFooterSendButton: "#7e22ce",
|
|
42
|
+
messageInputFooterSendButtonHoverColor: "#6b21a8",
|
|
43
|
+
messageInputSendButtonIconColor: "#ffffff",
|
|
44
|
+
messageInputSendButtonDisabledColor: "#e5e7eb",
|
|
45
|
+
messageInputActionButtonFocusBorder: "#a855f7",
|
|
46
|
+
};
|
|
47
|
+
const SINGLETON_KEY = "__agentforceConversationClientSingleton";
|
|
48
|
+
|
|
49
|
+
interface AgentforceConversationClientSingleton {
|
|
50
|
+
initPromise?: Promise<void>;
|
|
51
|
+
initialized: boolean;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
interface WindowWithAgentforceSingleton extends Window {
|
|
55
|
+
[SINGLETON_KEY]?: AgentforceConversationClientSingleton;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function getSingleton(): AgentforceConversationClientSingleton {
|
|
59
|
+
const win = window as WindowWithAgentforceSingleton;
|
|
60
|
+
if (!win[SINGLETON_KEY]) {
|
|
61
|
+
win[SINGLETON_KEY] = {
|
|
62
|
+
initialized: false,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
return win[SINGLETON_KEY]!;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function getOrCreateGlobalHost(): HTMLDivElement {
|
|
69
|
+
let host = document.getElementById(GLOBAL_HOST_ID) as HTMLDivElement | null;
|
|
70
|
+
if (!host) {
|
|
71
|
+
host = document.createElement("div");
|
|
72
|
+
host.id = GLOBAL_HOST_ID;
|
|
73
|
+
document.body.appendChild(host);
|
|
74
|
+
}
|
|
75
|
+
return host;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function getDefaultEmbedOptions(): ResolvedEmbedOptions {
|
|
79
|
+
return { salesforceOrigin: window.location.origin };
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* React wrapper that embeds the Agentforce Conversation Client (copilot/agent UI)
|
|
84
|
+
* using Lightning Out. Requires a valid Salesforce session for the given org.
|
|
85
|
+
* Config is passed through from the consumer to the embed client as-is.
|
|
86
|
+
*/
|
|
87
|
+
export function AgentforceConversationClient({
|
|
88
|
+
agentId,
|
|
89
|
+
agentLabel,
|
|
90
|
+
inline: inlineProp,
|
|
91
|
+
headerEnabled,
|
|
92
|
+
showHeaderIcon,
|
|
93
|
+
width,
|
|
94
|
+
height,
|
|
95
|
+
styleTokens,
|
|
96
|
+
salesforceOrigin,
|
|
97
|
+
frontdoorUrl,
|
|
98
|
+
}: AgentforceConversationClientProps) {
|
|
99
|
+
const containerRef = useRef<HTMLDivElement>(null);
|
|
100
|
+
const normalizedAgentforceClientConfig = useMemo<AgentforceClientConfig>(() => {
|
|
101
|
+
const renderingConfig: NonNullable<AgentforceClientConfig["renderingConfig"]> = {
|
|
102
|
+
mode: inlineProp ? "inline" : "floating",
|
|
103
|
+
...(headerEnabled !== undefined && { headerEnabled }),
|
|
104
|
+
...(showHeaderIcon !== undefined && { showHeaderIcon }),
|
|
105
|
+
...{ showAvatar: false },
|
|
106
|
+
...(width !== undefined && { width }),
|
|
107
|
+
...(height !== undefined && { height }),
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
return {
|
|
111
|
+
...(agentId !== undefined && { agentId }),
|
|
112
|
+
agentLabel: agentLabel ?? "Chat with us",
|
|
113
|
+
styleTokens: { ...DEFAULT_STYLE_TOKENS, ...styleTokens },
|
|
114
|
+
renderingConfig,
|
|
115
|
+
};
|
|
116
|
+
}, [agentId, agentLabel, inlineProp, headerEnabled, showHeaderIcon, width, height, styleTokens]);
|
|
117
|
+
|
|
118
|
+
const inline = normalizedAgentforceClientConfig?.renderingConfig?.mode === "inline";
|
|
119
|
+
|
|
120
|
+
useEffect(() => {
|
|
121
|
+
if (!normalizedAgentforceClientConfig?.agentId) {
|
|
122
|
+
throw new Error(
|
|
123
|
+
"AgentforceConversationClient requires agentId. " +
|
|
124
|
+
"Pass flat props only (agentId, agentLabel, inline, headerEnabled, showHeaderIcon, width, height, styleTokens).",
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
const singleton = getSingleton();
|
|
129
|
+
if (singleton.initialized || singleton.initPromise) {
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
if (inline && !containerRef.current) {
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const initialize = (options: ResolvedEmbedOptions) => {
|
|
138
|
+
if (singleton.initialized) {
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
const existingEmbed = document.querySelector('lightning-out-application[data-lo="acc"]');
|
|
142
|
+
if (existingEmbed) {
|
|
143
|
+
singleton.initialized = true;
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
const host = inline ? containerRef.current! : getOrCreateGlobalHost();
|
|
147
|
+
|
|
148
|
+
embedAgentforceClient({
|
|
149
|
+
container: host,
|
|
150
|
+
salesforceOrigin: salesforceOrigin ?? options.salesforceOrigin,
|
|
151
|
+
frontdoorUrl: frontdoorUrl ?? options.frontdoorUrl,
|
|
152
|
+
agentforceClientConfig: normalizedAgentforceClientConfig,
|
|
153
|
+
});
|
|
154
|
+
singleton.initialized = true;
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
const shouldFetchFrontdoor = window.location.hostname === "localhost";
|
|
158
|
+
|
|
159
|
+
if (shouldFetchFrontdoor) {
|
|
160
|
+
singleton.initPromise = fetch("/__lo/frontdoor")
|
|
161
|
+
.then(async (res) => {
|
|
162
|
+
if (!res.ok) {
|
|
163
|
+
console.error("frontdoor fetch failed");
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
const { frontdoorUrl: resolvedFrontdoorUrl } = await res.json();
|
|
167
|
+
initialize({ frontdoorUrl: resolvedFrontdoorUrl });
|
|
168
|
+
})
|
|
169
|
+
.catch((err) => {
|
|
170
|
+
console.error("AgentforceConversationClient: failed to fetch frontdoor URL", err);
|
|
171
|
+
})
|
|
172
|
+
.finally(() => {
|
|
173
|
+
singleton.initPromise = undefined;
|
|
174
|
+
});
|
|
175
|
+
} else {
|
|
176
|
+
singleton.initPromise = Promise.resolve()
|
|
177
|
+
.then(() => {
|
|
178
|
+
initialize(getDefaultEmbedOptions());
|
|
179
|
+
})
|
|
180
|
+
.catch((err) => {
|
|
181
|
+
console.error("AgentforceConversationClient: failed to embed Agentforce client", err);
|
|
182
|
+
})
|
|
183
|
+
.finally(() => {
|
|
184
|
+
singleton.initPromise = undefined;
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
return () => {
|
|
189
|
+
// Intentionally no cleanup:
|
|
190
|
+
// This component guarantees a single LO initialization per window.
|
|
191
|
+
};
|
|
192
|
+
}, [salesforceOrigin, frontdoorUrl, normalizedAgentforceClientConfig, inline]);
|
|
193
|
+
|
|
194
|
+
if (!inline) {
|
|
195
|
+
return null;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
return <div ref={containerRef} />;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
export default AgentforceConversationClient;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { cva, type VariantProps } from 'class-variance-authority';
|
|
2
|
+
import { AlertCircleIcon, CheckCircle2Icon } from 'lucide-react';
|
|
3
|
+
import { Alert, AlertDescription } from '../../components/ui/alert';
|
|
4
|
+
import { useId } from 'react';
|
|
5
|
+
|
|
6
|
+
const statusAlertVariants = cva('', {
|
|
7
|
+
variants: {
|
|
8
|
+
variant: {
|
|
9
|
+
error: '',
|
|
10
|
+
success: '',
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
defaultVariants: {
|
|
14
|
+
variant: 'error',
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
interface StatusAlertProps extends VariantProps<typeof statusAlertVariants> {
|
|
19
|
+
children?: React.ReactNode;
|
|
20
|
+
/** Alert variant type. @default "error" */
|
|
21
|
+
variant?: 'error' | 'success';
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Status alert component for displaying error or success messages.
|
|
26
|
+
* Returns null if no children are provided.
|
|
27
|
+
*/
|
|
28
|
+
export function StatusAlert({ children, variant = 'error' }: StatusAlertProps) {
|
|
29
|
+
const descriptionId = useId();
|
|
30
|
+
if (!children) return null;
|
|
31
|
+
|
|
32
|
+
const isError = variant === 'error';
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<Alert
|
|
36
|
+
variant={isError ? 'destructive' : 'default'}
|
|
37
|
+
className={statusAlertVariants({ variant })}
|
|
38
|
+
aria-describedby={descriptionId}
|
|
39
|
+
role={isError ? 'alert' : 'status'}
|
|
40
|
+
>
|
|
41
|
+
{isError ? (
|
|
42
|
+
<AlertCircleIcon aria-hidden="true" />
|
|
43
|
+
) : (
|
|
44
|
+
<CheckCircle2Icon aria-hidden="true" />
|
|
45
|
+
)}
|
|
46
|
+
<AlertDescription id={descriptionId}>{children}</AlertDescription>
|
|
47
|
+
</Alert>
|
|
48
|
+
);
|
|
49
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Card,
|
|
3
|
+
CardContent,
|
|
4
|
+
CardDescription,
|
|
5
|
+
CardHeader,
|
|
6
|
+
CardTitle,
|
|
7
|
+
} from '../../components/ui/card';
|
|
8
|
+
|
|
9
|
+
interface CardLayoutProps {
|
|
10
|
+
title: string;
|
|
11
|
+
description?: string;
|
|
12
|
+
children: React.ReactNode;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Card layout component for authentication pages.
|
|
17
|
+
* Provides CardHeader with title and optional description, and CardContent.
|
|
18
|
+
*/
|
|
19
|
+
export function CardLayout({ title, description, children }: CardLayoutProps) {
|
|
20
|
+
return (
|
|
21
|
+
<Card>
|
|
22
|
+
<CardHeader>
|
|
23
|
+
<CardTitle className="text-2xl">{title}</CardTitle>
|
|
24
|
+
{description && <CardDescription>{description}</CardDescription>}
|
|
25
|
+
</CardHeader>
|
|
26
|
+
<CardContent>{children}</CardContent>
|
|
27
|
+
</Card>
|
|
28
|
+
);
|
|
29
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import AppThemeProvider from "@/components/library/theme/AppThemeProvider";
|
|
2
|
+
import DataModeProvider from "@/components/library/data/DataModeProvider";
|
|
3
|
+
import { ENABLE_SAMPLE_DATA_CACHE } from "@/lib/dataStrategy";
|
|
4
|
+
import { Toaster } from "sonner";
|
|
5
|
+
import PartnerHubDashboard from "../../pages/PartnerHubDashboard";
|
|
6
|
+
|
|
7
|
+
export default function CommandCenter() {
|
|
8
|
+
return (
|
|
9
|
+
<AppThemeProvider initialMode="light">
|
|
10
|
+
<DataModeProvider initialMode={ENABLE_SAMPLE_DATA_CACHE ? "sample" : "live"}>
|
|
11
|
+
<PartnerHubDashboard />
|
|
12
|
+
<Toaster position="bottom-right" />
|
|
13
|
+
</DataModeProvider>
|
|
14
|
+
</AppThemeProvider>
|
|
15
|
+
);
|
|
16
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agentforce Agent API Configuration
|
|
3
|
+
*
|
|
4
|
+
* These values connect the ChatBar to the real Agentforce agent (Eva)
|
|
5
|
+
* via the REST-based Agent API instead of the iframe-based
|
|
6
|
+
* AgentforceConversationClient.
|
|
7
|
+
*
|
|
8
|
+
* Flow: OAuth token → create session → send messages → end session
|
|
9
|
+
*
|
|
10
|
+
* All requests are proxied through the Vite dev server to avoid CORS.
|
|
11
|
+
* See vite.config.ts proxy rules:
|
|
12
|
+
* /sf-oauth/* → myDomainUrl (for OAuth token)
|
|
13
|
+
* /sf-agent/* → agentApiBaseUrl (for Agent API calls)
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
export const AGENT_API_CONFIG = {
|
|
17
|
+
myDomainUrl: "https://tdx26-keynote-org-1com.my.salesforce.com",
|
|
18
|
+
|
|
19
|
+
clientId:
|
|
20
|
+
"3MVG9Gm6vbdjgMWSOIAuIN3VSB5Rju6PgYQ5rl1yH3bVTTg9E2as4.C61Q0cyT.zqv2vUWNaxrm.A7SW5o3t7",
|
|
21
|
+
clientSecret:
|
|
22
|
+
"9ADF795A183A6B074A2E4B4CB1748B8DF7090C74191AF1C190213B512A733E03",
|
|
23
|
+
|
|
24
|
+
agentId: "0Xxa5000000rQlxCAE",
|
|
25
|
+
|
|
26
|
+
agentApiBaseUrl: "https://api.salesforce.com",
|
|
27
|
+
|
|
28
|
+
bypassUser: true,
|
|
29
|
+
|
|
30
|
+
demoTraveler: {
|
|
31
|
+
contactId: "003a500000mj4TlAAI",
|
|
32
|
+
email: "sarah.chen@arcline.ai",
|
|
33
|
+
firstName: "Sarah",
|
|
34
|
+
lastName: "Chen",
|
|
35
|
+
},
|
|
36
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import SEARCH_ACCOUNTS_QUERY from "./query/searchAccounts.graphql?raw";
|
|
2
|
+
import DISTINCT_INDUSTRIES_QUERY from "./query/distinctAccountIndustries.graphql?raw";
|
|
3
|
+
import DISTINCT_TYPES_QUERY from "./query/distinctAccountTypes.graphql?raw";
|
|
4
|
+
import {
|
|
5
|
+
searchObjects,
|
|
6
|
+
fetchDistinctValues,
|
|
7
|
+
type ObjectSearchOptions,
|
|
8
|
+
type PicklistOption,
|
|
9
|
+
} from "../../api/objectSearchService";
|
|
10
|
+
import type {
|
|
11
|
+
SearchAccountsQuery,
|
|
12
|
+
SearchAccountsQueryVariables,
|
|
13
|
+
DistinctAccountIndustriesQuery,
|
|
14
|
+
DistinctAccountTypesQuery,
|
|
15
|
+
} from "../../../../api/graphql-operations-types";
|
|
16
|
+
|
|
17
|
+
export type AccountSearchResult = NonNullable<SearchAccountsQuery["uiapi"]["query"]["Account"]>;
|
|
18
|
+
|
|
19
|
+
export type AccountSearchOptions = ObjectSearchOptions<
|
|
20
|
+
SearchAccountsQueryVariables["where"],
|
|
21
|
+
SearchAccountsQueryVariables["orderBy"]
|
|
22
|
+
>;
|
|
23
|
+
|
|
24
|
+
export type { PicklistOption };
|
|
25
|
+
|
|
26
|
+
export async function searchAccounts(
|
|
27
|
+
options: AccountSearchOptions = {},
|
|
28
|
+
): Promise<AccountSearchResult> {
|
|
29
|
+
return searchObjects<AccountSearchResult, SearchAccountsQuery, SearchAccountsQueryVariables>(
|
|
30
|
+
SEARCH_ACCOUNTS_QUERY,
|
|
31
|
+
"Account",
|
|
32
|
+
options,
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export async function fetchDistinctIndustries(): Promise<PicklistOption[]> {
|
|
37
|
+
return fetchDistinctValues<DistinctAccountIndustriesQuery>(
|
|
38
|
+
DISTINCT_INDUSTRIES_QUERY,
|
|
39
|
+
"Account",
|
|
40
|
+
"Industry",
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export async function fetchDistinctTypes(): Promise<PicklistOption[]> {
|
|
45
|
+
return fetchDistinctValues<DistinctAccountTypesQuery>(DISTINCT_TYPES_QUERY, "Account", "Type");
|
|
46
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
query DistinctAccountIndustries {
|
|
2
|
+
uiapi {
|
|
3
|
+
aggregate {
|
|
4
|
+
Account(groupBy: { Industry: { group: true } }) {
|
|
5
|
+
edges {
|
|
6
|
+
node {
|
|
7
|
+
aggregate @optional {
|
|
8
|
+
Industry @optional {
|
|
9
|
+
value
|
|
10
|
+
displayValue
|
|
11
|
+
label
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|