@schandlergarcia/sf-web-components 2.3.16 → 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.
- package/CHANGELOG.md +27 -0
- package/CLAUDE.md +12 -13
- package/README.md +0 -15
- package/dist/styles/global.css +46 -48
- package/package.json +1 -2
- package/scripts/apply-brand.mjs +47 -30
- package/scripts/postinstall.mjs +1 -11
- package/src/styles/global.css +46 -48
- package/brands/engine/PARTNER_HUB_PRD.md +0 -584
- package/brands/engine/agentApiConfig.ts +0 -36
- package/brands/engine/app/api/graphql-operations-types.ts +0 -11260
- package/brands/engine/app/api/graphqlClient.ts +0 -25
- package/brands/engine/app/api/partnerQueries.ts +0 -212
- package/brands/engine/app/appLayout.tsx +0 -5
- package/brands/engine/app/components/AgentPanel.tsx +0 -402
- package/brands/engine/app/components/AgentforceConversationClient.tsx +0 -201
- package/brands/engine/app/components/__inherit_AgentforceConversationClient.tsx +0 -3
- package/brands/engine/app/components/alerts/status-alert.tsx +0 -49
- package/brands/engine/app/components/layouts/card-layout.tsx +0 -29
- package/brands/engine/app/components/workspace/CommandCenter.tsx +0 -16
- package/brands/engine/app/config/agentApi.ts +0 -36
- package/brands/engine/app/features/object-search/__examples__/api/accountSearchService.ts +0 -46
- package/brands/engine/app/features/object-search/__examples__/api/query/distinctAccountIndustries.graphql +0 -19
- package/brands/engine/app/features/object-search/__examples__/api/query/distinctAccountTypes.graphql +0 -19
- package/brands/engine/app/features/object-search/__examples__/api/query/getAccountDetail.graphql +0 -121
- package/brands/engine/app/features/object-search/__examples__/api/query/searchAccounts.graphql +0 -51
- package/brands/engine/app/features/object-search/__examples__/pages/AccountObjectDetailPage.tsx +0 -357
- package/brands/engine/app/features/object-search/__examples__/pages/AccountSearch.tsx +0 -312
- package/brands/engine/app/features/object-search/__examples__/pages/Home.tsx +0 -34
- package/brands/engine/app/features/object-search/api/objectSearchService.ts +0 -84
- package/brands/engine/app/features/object-search/components/ActiveFilters.tsx +0 -89
- package/brands/engine/app/features/object-search/components/FilterContext.tsx +0 -83
- package/brands/engine/app/features/object-search/components/ObjectBreadcrumb.tsx +0 -66
- package/brands/engine/app/features/object-search/components/PaginationControls.tsx +0 -109
- package/brands/engine/app/features/object-search/components/SearchBar.tsx +0 -41
- package/brands/engine/app/features/object-search/components/SortControl.tsx +0 -143
- package/brands/engine/app/features/object-search/components/filters/BooleanFilter.tsx +0 -78
- package/brands/engine/app/features/object-search/components/filters/DateFilter.tsx +0 -128
- package/brands/engine/app/features/object-search/components/filters/DateRangeFilter.tsx +0 -70
- package/brands/engine/app/features/object-search/components/filters/FilterFieldWrapper.tsx +0 -33
- package/brands/engine/app/features/object-search/components/filters/MultiSelectFilter.tsx +0 -97
- package/brands/engine/app/features/object-search/components/filters/NumericRangeFilter.tsx +0 -163
- package/brands/engine/app/features/object-search/components/filters/SearchFilter.tsx +0 -50
- package/brands/engine/app/features/object-search/components/filters/SelectFilter.tsx +0 -97
- package/brands/engine/app/features/object-search/components/filters/TextFilter.tsx +0 -91
- package/brands/engine/app/features/object-search/hooks/useAsyncData.ts +0 -54
- package/brands/engine/app/features/object-search/hooks/useCachedAsyncData.ts +0 -184
- package/brands/engine/app/features/object-search/hooks/useDebouncedCallback.ts +0 -34
- package/brands/engine/app/features/object-search/hooks/useObjectSearchParams.ts +0 -252
- package/brands/engine/app/features/object-search/utils/debounce.ts +0 -25
- package/brands/engine/app/features/object-search/utils/fieldUtils.ts +0 -29
- package/brands/engine/app/features/object-search/utils/filterUtils.ts +0 -404
- package/brands/engine/app/features/object-search/utils/sortUtils.ts +0 -38
- package/brands/engine/app/hooks/useEngineLiveData.ts +0 -49
- package/brands/engine/app/hooks/useEvaAgent.ts +0 -288
- package/brands/engine/app/hooks/usePartnerDashboardData.ts +0 -141
- package/brands/engine/app/navigationMenu.tsx +0 -80
- package/brands/engine/app/pages/AccountObjectDetailPage.tsx +0 -361
- package/brands/engine/app/pages/AccountSearch.tsx +0 -305
- package/brands/engine/app/pages/BlankDashboard.tsx +0 -15
- package/brands/engine/app/pages/DataTest.tsx +0 -78
- package/brands/engine/app/pages/Home.tsx +0 -5
- package/brands/engine/app/pages/NotFound.tsx +0 -19
- package/brands/engine/app/pages/PartnerHubDashboard.tsx +0 -2077
- package/brands/engine/app/pages/Search.tsx +0 -13
- package/brands/engine/app/router-utils.tsx +0 -35
- package/brands/engine/app/routes.tsx +0 -39
- package/brands/engine/app/styles/global.css +0 -269
- package/brands/engine/brand.css +0 -40
- package/brands/engine/engine-command-center-prd.md +0 -575
- package/brands/engine/engine-live-data.js +0 -135
- package/brands/engine/engine-sample-data.js +0 -378
- package/brands/engine/engine_logo.png +0 -0
- package/brands/engine/global.css +0 -269
- package/brands/engine/partner-hub-sample-data.js +0 -281
- package/brands/engine/schema.graphql +0 -292
- package/brands/engine/useEngineLiveData.ts +0 -49
- package/brands/engine/useEvaAgent.ts +0 -288
|
@@ -1,25 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,212 +0,0 @@
|
|
|
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
|
-
`;
|
|
@@ -1,402 +0,0 @@
|
|
|
1
|
-
import React, { useState, useRef, useEffect, useCallback } from "react";
|
|
2
|
-
import { createPortal } from "react-dom";
|
|
3
|
-
import { SparklesIcon } from "@heroicons/react/24/solid";
|
|
4
|
-
import {
|
|
5
|
-
PaperAirplaneIcon,
|
|
6
|
-
ChevronDownIcon,
|
|
7
|
-
} from "@heroicons/react/24/outline";
|
|
8
|
-
|
|
9
|
-
interface Message {
|
|
10
|
-
id: string;
|
|
11
|
-
role: "user" | "agent";
|
|
12
|
-
text: string;
|
|
13
|
-
timestamp: string;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
interface ScriptStep {
|
|
17
|
-
role: "user" | "agent";
|
|
18
|
-
text: string;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const SCRIPT: ScriptStep[] = [
|
|
22
|
-
// --- Auto-play greeting ---
|
|
23
|
-
{
|
|
24
|
-
role: "agent",
|
|
25
|
-
text: "Hi Jamie! 👋 I'm your Partner Hub assistant. How can I help you today?",
|
|
26
|
-
},
|
|
27
|
-
|
|
28
|
-
// --- Prompt 1: Ask about the canceled booking ---
|
|
29
|
-
{
|
|
30
|
-
role: "user",
|
|
31
|
-
text: "I just got an alert that a block booking was canceled at our Austin Convention Center for next week. What happened?",
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
role: "agent",
|
|
35
|
-
text: "Let me pull up that reservation for you...",
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
role: "agent",
|
|
39
|
-
text: "🔴 CANCELED BOOKING\n\n🏨 Summit Austin Convention Center\n🏢 Client: TechCorp Inc.\n\n📋 Details:\n• Original block: 40 rooms\n• Dates: May 19 – 21 (3 nights)\n• Room rate: $200/night\n• Lost revenue: $24,000\n\n📅 Canceled: Apr 11, 2026\n⚠️ Status: Within penalty window",
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
role: "agent",
|
|
43
|
-
text: "TechCorp canceled their 40-room block for May 19–21. The reason given was that their annual conference is moving to a virtual format this year. This was within the attrition penalty window, so a penalty may apply — but that still leaves 40 rooms open for next week.",
|
|
44
|
-
},
|
|
45
|
-
|
|
46
|
-
// --- Prompt 2: What can be done ---
|
|
47
|
-
{
|
|
48
|
-
role: "user",
|
|
49
|
-
text: "That's a lot of empty rooms. Is there anything we can do to fill them on short notice?",
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
role: "agent",
|
|
53
|
-
text: "Actually, yes — I have an idea. Let me put together an option for you.",
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
role: "agent",
|
|
57
|
-
text: "⚡ ENGINE NETWORK PROMOTION\nFill your open rooms through Engine's network\n\n━━━━━━━━━━━━━━━━━━━━━━━━━\nSummit Austin Convention Center\n40 rooms · May 19–21 · 3 nights\n━━━━━━━━━━━━━━━━━━━━━━━━━\n\n💰 YOUR RATE\n$159/night (20% off rack rate)\n\n📡 ENGINE PROMOTES TO\n2,400+ corporate travel managers\n\n📉 COMMISSION\n12% standard → 8% promotional\nYou save $1,526 vs. standard bookings\n\n━━━━━━━━━━━━━━━━━━━━━━━━━\n📈 PROJECTED OUTCOME\n• Est. fill: 28 rooms (70%)\n• Revenue: $13,356\n• Net after commission: $12,287\n━━━━━━━━━━━━━━━━━━━━━━━━━",
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
role: "agent",
|
|
61
|
-
text: "Here's the play: we run a targeted promotion across Engine's corporate travel network — 2,400+ travel managers get notified about discounted rates at Summit Austin for May 19–21.\n\nWe'd list the rooms at $159/night, and your commission drops from 12% to 8% for promo bookings. On a projected 70% fill, that's $12,287 net — versus $0 if the rooms sit empty.\n\nWant to launch it?",
|
|
62
|
-
},
|
|
63
|
-
|
|
64
|
-
// --- Prompt 3: Accept the offer ---
|
|
65
|
-
{
|
|
66
|
-
role: "user",
|
|
67
|
-
text: "That makes sense — empty rooms earn nothing. Let's launch it.",
|
|
68
|
-
},
|
|
69
|
-
{
|
|
70
|
-
role: "agent",
|
|
71
|
-
text: "Launching your promotion now...",
|
|
72
|
-
},
|
|
73
|
-
{
|
|
74
|
-
role: "agent",
|
|
75
|
-
text: "✅ PROMOTION LIVE\n\n🆔 PROMO-SUM-0519\n🏨 Summit Austin Convention Center\n📅 May 19–21 (3 nights)\n💰 Rate: $159/night\n📉 Commission: 8% (promotional)\n📡 Distribution: Engine corporate travel network\n\nYour promotion is live and going out to 2,400+ travel managers now. I'll send you a fill-rate update in 48 hours.",
|
|
76
|
-
},
|
|
77
|
-
];
|
|
78
|
-
|
|
79
|
-
function typingDelay(text: string): number {
|
|
80
|
-
const base = 900;
|
|
81
|
-
const perChar = 10;
|
|
82
|
-
const jitter = Math.random() * 500;
|
|
83
|
-
return Math.min(base + text.length * perChar + jitter, 5500);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
function now() {
|
|
87
|
-
return new Date().toLocaleTimeString([], { hour: "numeric", minute: "2-digit" });
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
function TypingIndicator() {
|
|
91
|
-
return (
|
|
92
|
-
<div className="flex items-center gap-1 px-4 py-1.5">
|
|
93
|
-
<div className="flex items-end gap-3">
|
|
94
|
-
<div className="flex-shrink-0 h-7 w-7 rounded-full bg-[var(--color-dash-dark)] flex items-center justify-center">
|
|
95
|
-
<SparklesIcon className="h-3.5 w-3.5 text-white" />
|
|
96
|
-
</div>
|
|
97
|
-
<div className="bg-[var(--color-dash-surface)] dark:bg-[var(--color-dash-muted)]/20 rounded-2xl rounded-bl-md px-4 py-3">
|
|
98
|
-
<div className="flex items-center gap-1.5">
|
|
99
|
-
<span className="h-2 w-2 rounded-full bg-[var(--color-dash-label)] animate-bounce" style={{ animationDelay: "0ms" }} />
|
|
100
|
-
<span className="h-2 w-2 rounded-full bg-[var(--color-dash-label)] animate-bounce" style={{ animationDelay: "150ms" }} />
|
|
101
|
-
<span className="h-2 w-2 rounded-full bg-[var(--color-dash-label)] animate-bounce" style={{ animationDelay: "300ms" }} />
|
|
102
|
-
</div>
|
|
103
|
-
</div>
|
|
104
|
-
</div>
|
|
105
|
-
</div>
|
|
106
|
-
);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
function AgentMessage({ text, timestamp }: { text: string; timestamp: string }) {
|
|
110
|
-
return (
|
|
111
|
-
<div className="px-4 py-1.5">
|
|
112
|
-
<div className="flex items-end gap-3">
|
|
113
|
-
<div className="flex-shrink-0 h-7 w-7 rounded-full bg-[var(--color-dash-dark)] flex items-center justify-center">
|
|
114
|
-
<SparklesIcon className="h-3.5 w-3.5 text-white" />
|
|
115
|
-
</div>
|
|
116
|
-
<div className="max-w-[80%]">
|
|
117
|
-
<div className="bg-[var(--color-dash-surface)] dark:bg-[var(--color-dash-muted)]/20 rounded-2xl rounded-bl-md px-4 py-3 border border-[var(--color-dash-border)]/30 dark:border-[var(--color-dash-muted)]/30">
|
|
118
|
-
<p className="text-sm text-[var(--color-dash-text)] dark:text-white leading-relaxed whitespace-pre-wrap">
|
|
119
|
-
{text}
|
|
120
|
-
</p>
|
|
121
|
-
</div>
|
|
122
|
-
<p className="text-[10px] text-[var(--color-dash-label)] mt-1 ml-1">{timestamp}</p>
|
|
123
|
-
</div>
|
|
124
|
-
</div>
|
|
125
|
-
</div>
|
|
126
|
-
);
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
function UserMessage({ text, timestamp }: { text: string; timestamp: string }) {
|
|
130
|
-
return (
|
|
131
|
-
<div className="px-4 py-1.5">
|
|
132
|
-
<div className="flex items-end justify-end gap-3">
|
|
133
|
-
<div className="max-w-[80%]">
|
|
134
|
-
<div className="bg-[var(--color-dash-accent)] rounded-2xl rounded-br-md px-4 py-3">
|
|
135
|
-
<p className="text-sm text-white leading-relaxed">{text}</p>
|
|
136
|
-
</div>
|
|
137
|
-
<p className="text-[10px] text-[var(--color-dash-label)] mt-1 text-right mr-1">{timestamp}</p>
|
|
138
|
-
</div>
|
|
139
|
-
</div>
|
|
140
|
-
</div>
|
|
141
|
-
);
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
export default function AgentPanel() {
|
|
145
|
-
const [isOpen, setIsOpen] = useState(false);
|
|
146
|
-
const [messages, setMessages] = useState<Message[]>([]);
|
|
147
|
-
const [isTyping, setIsTyping] = useState(false);
|
|
148
|
-
const [inputValue, setInputValue] = useState("");
|
|
149
|
-
const [scriptIndex, setScriptIndex] = useState(0);
|
|
150
|
-
const [isAnimating, setIsAnimating] = useState(false);
|
|
151
|
-
const hasStartedRef = useRef(false);
|
|
152
|
-
const messagesEndRef = useRef<HTMLDivElement>(null);
|
|
153
|
-
const inputRef = useRef<HTMLInputElement>(null);
|
|
154
|
-
|
|
155
|
-
useEffect(() => {
|
|
156
|
-
messagesEndRef.current?.scrollIntoView({ behavior: "smooth" });
|
|
157
|
-
}, [messages, isTyping]);
|
|
158
|
-
|
|
159
|
-
useEffect(() => {
|
|
160
|
-
if (isOpen) {
|
|
161
|
-
setTimeout(() => inputRef.current?.focus(), 300);
|
|
162
|
-
}
|
|
163
|
-
}, [isOpen]);
|
|
164
|
-
|
|
165
|
-
// Auto-play the first agent message when panel opens
|
|
166
|
-
useEffect(() => {
|
|
167
|
-
if (isOpen && !hasStartedRef.current && scriptIndex === 0) {
|
|
168
|
-
hasStartedRef.current = true;
|
|
169
|
-
playNextStep();
|
|
170
|
-
}
|
|
171
|
-
}, [isOpen]);
|
|
172
|
-
|
|
173
|
-
const playNextStep = useCallback(async () => {
|
|
174
|
-
if (scriptIndex >= SCRIPT.length || isAnimating) return;
|
|
175
|
-
|
|
176
|
-
const step = SCRIPT[scriptIndex];
|
|
177
|
-
setIsAnimating(true);
|
|
178
|
-
|
|
179
|
-
if (step.role === "agent") {
|
|
180
|
-
setIsTyping(true);
|
|
181
|
-
await delay(typingDelay(step.text));
|
|
182
|
-
setIsTyping(false);
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
const msg: Message = {
|
|
186
|
-
id: `msg-${Date.now()}`,
|
|
187
|
-
role: step.role,
|
|
188
|
-
text: step.text,
|
|
189
|
-
timestamp: now(),
|
|
190
|
-
};
|
|
191
|
-
setMessages((prev) => [...prev, msg]);
|
|
192
|
-
setScriptIndex((prev) => prev + 1);
|
|
193
|
-
setIsAnimating(false);
|
|
194
|
-
|
|
195
|
-
// If we just played a user message, auto-play all following agent messages
|
|
196
|
-
const nextIndex = scriptIndex + 1;
|
|
197
|
-
if (step.role === "user" && nextIndex < SCRIPT.length && SCRIPT[nextIndex].role === "agent") {
|
|
198
|
-
await delay(400);
|
|
199
|
-
await playAgentChain(nextIndex);
|
|
200
|
-
}
|
|
201
|
-
}, [scriptIndex, isAnimating]);
|
|
202
|
-
|
|
203
|
-
async function playAgentChain(startIndex: number) {
|
|
204
|
-
let idx = startIndex;
|
|
205
|
-
setIsAnimating(true);
|
|
206
|
-
while (idx < SCRIPT.length && SCRIPT[idx].role === "agent") {
|
|
207
|
-
const step = SCRIPT[idx];
|
|
208
|
-
setIsTyping(true);
|
|
209
|
-
await delay(typingDelay(step.text));
|
|
210
|
-
setIsTyping(false);
|
|
211
|
-
|
|
212
|
-
const msg: Message = {
|
|
213
|
-
id: `msg-${Date.now()}-${idx}`,
|
|
214
|
-
role: "agent",
|
|
215
|
-
text: step.text,
|
|
216
|
-
timestamp: now(),
|
|
217
|
-
};
|
|
218
|
-
setMessages((prev) => [...prev, msg]);
|
|
219
|
-
setScriptIndex(idx + 1);
|
|
220
|
-
idx++;
|
|
221
|
-
if (idx < SCRIPT.length && SCRIPT[idx].role === "agent") {
|
|
222
|
-
await delay(500);
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
setIsAnimating(false);
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
// Right arrow key stages the next user message into the input
|
|
229
|
-
useEffect(() => {
|
|
230
|
-
function onKey(e: KeyboardEvent) {
|
|
231
|
-
if (e.key === "ArrowRight" && isOpen && !isAnimating && scriptIndex < SCRIPT.length) {
|
|
232
|
-
e.preventDefault();
|
|
233
|
-
const next = SCRIPT[scriptIndex];
|
|
234
|
-
if (next.role === "user") {
|
|
235
|
-
setInputValue(next.text);
|
|
236
|
-
inputRef.current?.focus();
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
document.addEventListener("keydown", onKey);
|
|
241
|
-
return () => document.removeEventListener("keydown", onKey);
|
|
242
|
-
}, [isOpen, scriptIndex, isAnimating]);
|
|
243
|
-
|
|
244
|
-
function handleSend() {
|
|
245
|
-
const text = inputValue.trim();
|
|
246
|
-
if (!text) return;
|
|
247
|
-
setInputValue("");
|
|
248
|
-
|
|
249
|
-
// Check if this matches the next scripted user message
|
|
250
|
-
if (scriptIndex < SCRIPT.length && SCRIPT[scriptIndex].role === "user" && text === SCRIPT[scriptIndex].text) {
|
|
251
|
-
playNextStep();
|
|
252
|
-
return;
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
const userMsg: Message = {
|
|
256
|
-
id: `u-${Date.now()}`,
|
|
257
|
-
role: "user",
|
|
258
|
-
text,
|
|
259
|
-
timestamp: now(),
|
|
260
|
-
};
|
|
261
|
-
setMessages((prev) => [...prev, userMsg]);
|
|
262
|
-
|
|
263
|
-
setIsTyping(true);
|
|
264
|
-
setTimeout(() => {
|
|
265
|
-
setIsTyping(false);
|
|
266
|
-
const agentMsg: Message = {
|
|
267
|
-
id: `a-${Date.now()}`,
|
|
268
|
-
role: "agent",
|
|
269
|
-
text: "I'm looking into that for you — one moment please.",
|
|
270
|
-
timestamp: now(),
|
|
271
|
-
};
|
|
272
|
-
setMessages((prev) => [...prev, agentMsg]);
|
|
273
|
-
}, 1500);
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
const scriptDone = scriptIndex >= SCRIPT.length;
|
|
277
|
-
|
|
278
|
-
const panel = isOpen
|
|
279
|
-
? createPortal(
|
|
280
|
-
<>
|
|
281
|
-
<div
|
|
282
|
-
className="fixed inset-0 z-[9998] bg-black/20 backdrop-blur-sm lg:hidden"
|
|
283
|
-
onClick={() => setIsOpen(false)}
|
|
284
|
-
/>
|
|
285
|
-
<div
|
|
286
|
-
className="fixed z-[9999] bottom-6 right-6 w-[380px] h-[520px] flex flex-col rounded-2xl shadow-2xl border border-[var(--color-dash-label)]/20 dark:border-[var(--color-dash-muted)]/30 overflow-hidden"
|
|
287
|
-
style={{
|
|
288
|
-
animation: "agent-panel-in 0.25s cubic-bezier(0.16, 1, 0.3, 1)",
|
|
289
|
-
}}
|
|
290
|
-
>
|
|
291
|
-
{/* Header */}
|
|
292
|
-
<div className="bg-[var(--color-dash-dark)] px-5 py-4 flex items-center justify-between flex-shrink-0">
|
|
293
|
-
<div className="flex items-center gap-3">
|
|
294
|
-
<div className="h-8 w-8 rounded-full bg-white/10 flex items-center justify-center">
|
|
295
|
-
<SparklesIcon className="h-4 w-4 text-white" />
|
|
296
|
-
</div>
|
|
297
|
-
<div>
|
|
298
|
-
<h3 className="text-sm font-semibold text-white">
|
|
299
|
-
Partner Hub Agent
|
|
300
|
-
</h3>
|
|
301
|
-
<p className="text-xs text-white/60">Agentforce · Online</p>
|
|
302
|
-
</div>
|
|
303
|
-
</div>
|
|
304
|
-
<button
|
|
305
|
-
onClick={() => setIsOpen(false)}
|
|
306
|
-
className="rounded-lg p-1.5 text-white/60 hover:text-white hover:bg-white/10 transition-colors"
|
|
307
|
-
>
|
|
308
|
-
<ChevronDownIcon className="h-5 w-5" />
|
|
309
|
-
</button>
|
|
310
|
-
</div>
|
|
311
|
-
|
|
312
|
-
{/* Messages */}
|
|
313
|
-
<div className="flex-1 overflow-y-auto bg-white dark:bg-[var(--color-dash-text)] py-4">
|
|
314
|
-
{messages.length === 0 && !isTyping && (
|
|
315
|
-
<div className="flex flex-col items-center justify-center h-full gap-3 px-6 text-center">
|
|
316
|
-
<div className="h-12 w-12 rounded-full bg-[var(--color-dash-accent)]/10 flex items-center justify-center">
|
|
317
|
-
<SparklesIcon className="h-6 w-6 text-[var(--color-dash-accent)]" />
|
|
318
|
-
</div>
|
|
319
|
-
<p className="text-sm text-[var(--color-dash-muted)] dark:text-[var(--color-dash-label)]">
|
|
320
|
-
Eva is connecting...
|
|
321
|
-
</p>
|
|
322
|
-
</div>
|
|
323
|
-
)}
|
|
324
|
-
{messages.map((msg) =>
|
|
325
|
-
msg.role === "agent" ? (
|
|
326
|
-
<AgentMessage key={msg.id} text={msg.text} timestamp={msg.timestamp} />
|
|
327
|
-
) : (
|
|
328
|
-
<UserMessage key={msg.id} text={msg.text} timestamp={msg.timestamp} />
|
|
329
|
-
)
|
|
330
|
-
)}
|
|
331
|
-
{isTyping && <TypingIndicator />}
|
|
332
|
-
<div ref={messagesEndRef} />
|
|
333
|
-
</div>
|
|
334
|
-
|
|
335
|
-
{/* Input */}
|
|
336
|
-
<div className="flex-shrink-0 bg-white dark:bg-[var(--color-dash-text)] border-t border-[var(--color-dash-label)]/20 dark:border-[var(--color-dash-muted)]/30 px-4 py-3">
|
|
337
|
-
<form
|
|
338
|
-
onSubmit={(e) => {
|
|
339
|
-
e.preventDefault();
|
|
340
|
-
handleSend();
|
|
341
|
-
}}
|
|
342
|
-
className="flex items-center gap-2"
|
|
343
|
-
>
|
|
344
|
-
<input
|
|
345
|
-
ref={inputRef}
|
|
346
|
-
type="text"
|
|
347
|
-
value={inputValue}
|
|
348
|
-
onChange={(e) => setInputValue(e.target.value)}
|
|
349
|
-
placeholder="Type your message..."
|
|
350
|
-
className="flex-1 bg-[var(--color-dash-surface)] dark:bg-[var(--color-dash-muted)]/10 border border-[var(--color-dash-label)]/20 dark:border-[var(--color-dash-muted)]/30 rounded-xl px-4 py-2.5 text-sm text-[var(--color-dash-text)] dark:text-white placeholder:text-[var(--color-dash-label)] focus:outline-none focus:ring-2 focus:ring-[var(--color-dash-accent)]/30 focus:border-[var(--color-dash-accent)] transition-all"
|
|
351
|
-
/>
|
|
352
|
-
<button
|
|
353
|
-
type="submit"
|
|
354
|
-
disabled={!inputValue.trim()}
|
|
355
|
-
className="flex-shrink-0 h-10 w-10 rounded-xl bg-[var(--color-dash-accent)] hover:brightness-110 disabled:opacity-40 disabled:cursor-not-allowed flex items-center justify-center transition-all"
|
|
356
|
-
>
|
|
357
|
-
<PaperAirplaneIcon className="h-4 w-4 text-white" />
|
|
358
|
-
</button>
|
|
359
|
-
</form>
|
|
360
|
-
<p className="text-[10px] text-[var(--color-dash-label)] text-center mt-2">
|
|
361
|
-
Powered by Agentforce
|
|
362
|
-
</p>
|
|
363
|
-
</div>
|
|
364
|
-
</div>
|
|
365
|
-
</>,
|
|
366
|
-
document.body
|
|
367
|
-
)
|
|
368
|
-
: null;
|
|
369
|
-
|
|
370
|
-
return (
|
|
371
|
-
<>
|
|
372
|
-
{panel}
|
|
373
|
-
|
|
374
|
-
{!isOpen && (
|
|
375
|
-
<button
|
|
376
|
-
onClick={() => setIsOpen(true)}
|
|
377
|
-
className="fixed z-[9999] bottom-6 right-6 h-14 w-14 rounded-full bg-[var(--color-dash-dark)] hover:scale-110 shadow-xl hover:shadow-2xl flex items-center justify-center transition-all duration-200"
|
|
378
|
-
style={{
|
|
379
|
-
animation: "agent-bubble-in 0.3s cubic-bezier(0.16, 1, 0.3, 1)",
|
|
380
|
-
}}
|
|
381
|
-
>
|
|
382
|
-
<SparklesIcon className="h-6 w-6 text-white" />
|
|
383
|
-
</button>
|
|
384
|
-
)}
|
|
385
|
-
|
|
386
|
-
<style>{`
|
|
387
|
-
@keyframes agent-panel-in {
|
|
388
|
-
from { opacity: 0; transform: translateY(20px) scale(0.95); }
|
|
389
|
-
to { opacity: 1; transform: translateY(0) scale(1); }
|
|
390
|
-
}
|
|
391
|
-
@keyframes agent-bubble-in {
|
|
392
|
-
from { opacity: 0; transform: scale(0.5); }
|
|
393
|
-
to { opacity: 1; transform: scale(1); }
|
|
394
|
-
}
|
|
395
|
-
`}</style>
|
|
396
|
-
</>
|
|
397
|
-
);
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
function delay(ms: number) {
|
|
401
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
402
|
-
}
|