@iblai/web-utils 1.0.0 → 1.1.1
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/dist/data-layer/src/features/mentor/api-slice.d.ts +70 -22
- package/dist/data-layer/src/features/stripe/api-slice.d.ts +22 -0
- package/dist/index.d.ts +24 -19
- package/dist/index.esm.js +167 -116
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +166 -115
- package/dist/index.js.map +1 -1
- package/dist/package.json +2 -2
- package/dist/web-utils/src/hooks/chat/use-advanced-chat.d.ts +1 -1
- package/dist/web-utils/src/hooks/use-mentor-settings.d.ts +18 -15
- package/dist/web-utils/src/providers/mentor-provider.d.ts +2 -1
- package/dist/web-utils/src/providers/tenant-provider.d.ts +2 -1
- package/package.json +3 -3
- package/dist/web-utils/tsconfig.tsbuildinfo +0 -1
package/dist/index.js
CHANGED
|
@@ -7415,10 +7415,11 @@ const stripeApiSlice = createApi({
|
|
|
7415
7415
|
providesTags: ['stripe-context'],
|
|
7416
7416
|
}),
|
|
7417
7417
|
getStripePricingPageSession: builder.query({
|
|
7418
|
-
query: ({ platform_key }) => ({
|
|
7418
|
+
query: ({ platform_key, params }) => ({
|
|
7419
7419
|
url: STRIPE_ENDPOINTS.GET_STRIPE_PRICING_PAGE_SESSION.path(platform_key),
|
|
7420
7420
|
service: STRIPE_ENDPOINTS.GET_STRIPE_PRICING_PAGE_SESSION.service,
|
|
7421
7421
|
method: 'GET',
|
|
7422
|
+
params,
|
|
7422
7423
|
}),
|
|
7423
7424
|
providesTags: ['stripe-context'],
|
|
7424
7425
|
}),
|
|
@@ -9851,6 +9852,7 @@ const useSubscriptionHandlerV2 = (subscriptionFlow) => {
|
|
|
9851
9852
|
});
|
|
9852
9853
|
}
|
|
9853
9854
|
catch (error) {
|
|
9855
|
+
console.error("Error getting user active app:", JSON.stringify(error));
|
|
9854
9856
|
return null;
|
|
9855
9857
|
}
|
|
9856
9858
|
};
|
|
@@ -9897,6 +9899,7 @@ const useSubscriptionHandlerV2 = (subscriptionFlow) => {
|
|
|
9897
9899
|
return await getUserActiveApp();
|
|
9898
9900
|
}
|
|
9899
9901
|
catch (error) {
|
|
9902
|
+
console.error("Error updating trial status:", JSON.stringify(error));
|
|
9900
9903
|
return null;
|
|
9901
9904
|
}
|
|
9902
9905
|
};
|
|
@@ -9989,6 +9992,7 @@ const useSubscriptionHandlerV2 = (subscriptionFlow) => {
|
|
|
9989
9992
|
return stripeContext.payment_link_url;
|
|
9990
9993
|
}
|
|
9991
9994
|
catch (error) {
|
|
9995
|
+
console.error("Error getting top up URL:", JSON.stringify(error));
|
|
9992
9996
|
return null;
|
|
9993
9997
|
}
|
|
9994
9998
|
};
|
|
@@ -10062,6 +10066,7 @@ const useSubscriptionHandlerV2 = (subscriptionFlow) => {
|
|
|
10062
10066
|
return stripeCustomerPortal === null || stripeCustomerPortal === void 0 ? void 0 : stripeCustomerPortal.url;
|
|
10063
10067
|
}
|
|
10064
10068
|
catch (error) {
|
|
10069
|
+
console.error("Error getting billing URL:", JSON.stringify(error));
|
|
10065
10070
|
return null;
|
|
10066
10071
|
}
|
|
10067
10072
|
};
|
|
@@ -10107,7 +10112,10 @@ const useSubscriptionHandlerV2 = (subscriptionFlow) => {
|
|
|
10107
10112
|
try {
|
|
10108
10113
|
subscriptionFlow.handleBeforePricingPageDisplayFlow();
|
|
10109
10114
|
const { data: stripeContext } = await getStripePricingPageSession({
|
|
10110
|
-
platform_key: subscriptionFlow.
|
|
10115
|
+
platform_key: subscriptionFlow.getMainTenantKey(),
|
|
10116
|
+
params: {
|
|
10117
|
+
source_platform_key: subscriptionFlow.getCurrentTenantKey(),
|
|
10118
|
+
},
|
|
10111
10119
|
}, false);
|
|
10112
10120
|
if (isStripeContextError ||
|
|
10113
10121
|
!stripeContext ||
|
|
@@ -10120,6 +10128,7 @@ const useSubscriptionHandlerV2 = (subscriptionFlow) => {
|
|
|
10120
10128
|
}, !hasCredits);
|
|
10121
10129
|
}
|
|
10122
10130
|
catch (error) {
|
|
10131
|
+
console.error("Error getting stripe pricing page session:", JSON.stringify(error));
|
|
10123
10132
|
subscriptionFlow.handleFailureOnPaymentFlow();
|
|
10124
10133
|
}
|
|
10125
10134
|
};
|
|
@@ -11507,7 +11516,7 @@ const useTenantContext = () => React.useContext(TenantContext);
|
|
|
11507
11516
|
* 4. Handles tenant-specific domain redirects
|
|
11508
11517
|
* 5. Maintains tenant access state
|
|
11509
11518
|
*/
|
|
11510
|
-
function TenantProvider({ children, fallback, onAuthSuccess, onAuthFailure, currentTenant, requestedTenant, saveCurrentTenant, saveUserTenants, handleTenantSwitch, saveVisitingTenant, removeVisitingTenant, saveUserTokens, saveTenant, onAutoJoinUserToTenant, redirectToAuthSpa, }) {
|
|
11519
|
+
function TenantProvider({ children, fallback, onAuthSuccess, onAuthFailure, currentTenant, requestedTenant, saveCurrentTenant, saveUserTenants, handleTenantSwitch, saveVisitingTenant, removeVisitingTenant, saveUserTokens, saveTenant, onAutoJoinUserToTenant, redirectToAuthSpa, username, }) {
|
|
11511
11520
|
const { userIsAccessingPublicRoute, setUserIsAccessingPublicRoute } = useAuthContext();
|
|
11512
11521
|
const [determineUserPath, setDetermineUserPath] = React.useState(false);
|
|
11513
11522
|
const [isLoading, setIsLoading] = React.useState(true);
|
|
@@ -11705,6 +11714,11 @@ function TenantProvider({ children, fallback, onAuthSuccess, onAuthFailure, curr
|
|
|
11705
11714
|
platform_name: data.platform_name,
|
|
11706
11715
|
is_advertising: (_a = data.metadata) === null || _a === void 0 ? void 0 : _a.is_advertising,
|
|
11707
11716
|
};
|
|
11717
|
+
if (!username) {
|
|
11718
|
+
saveVisitingTenant === null || saveVisitingTenant === void 0 ? void 0 : saveVisitingTenant(newCurrentTenant);
|
|
11719
|
+
// user is not authenticated so we don't need to do anything that concerns an authenticated user
|
|
11720
|
+
return;
|
|
11721
|
+
}
|
|
11708
11722
|
const { data: tenants } = await fetchUserTenants();
|
|
11709
11723
|
const enhancedTenants = await enhanceTenants(tenants, data);
|
|
11710
11724
|
saveUserTenants(enhancedTenants);
|
|
@@ -11846,7 +11860,7 @@ function TenantProvider({ children, fallback, onAuthSuccess, onAuthFailure, curr
|
|
|
11846
11860
|
* 3. Manages redirection based on mentor availability
|
|
11847
11861
|
* 4. Integrates with tenant context for access control
|
|
11848
11862
|
*/
|
|
11849
|
-
function MentorProvider({ children, fallback, onAuthSuccess, onAuthFailure, redirectToAuthSpa, redirectToMentor, onLoadMentorsPermissions, redirectToNoMentorsPage, redirectToCreateMentor, username, isAdmin, mainTenantKey, requestedMentorId, handleMentorNotFound, forceDetermineMentor = false, }) {
|
|
11863
|
+
function MentorProvider({ children, fallback, onAuthSuccess, onAuthFailure, redirectToAuthSpa, redirectToMentor, onLoadMentorsPermissions, redirectToNoMentorsPage, redirectToCreateMentor, username, isAdmin, mainTenantKey, requestedMentorId, handleMentorNotFound, forceDetermineMentor = false, onComplete, }) {
|
|
11850
11864
|
const [isLoading, setIsLoading] = React.useState(true);
|
|
11851
11865
|
const { userIsAccessingPublicRoute } = useAuthContext();
|
|
11852
11866
|
const { determineUserPath, tenantKey, metadata } = useTenantContext();
|
|
@@ -11873,6 +11887,33 @@ function MentorProvider({ children, fallback, onAuthSuccess, onAuthFailure, redi
|
|
|
11873
11887
|
}
|
|
11874
11888
|
catch (_a) { }
|
|
11875
11889
|
};
|
|
11890
|
+
/**
|
|
11891
|
+
* Gets the mentor database ID from public settings if not available on the mentor object
|
|
11892
|
+
*/
|
|
11893
|
+
const getMentorDbId = async (mentor) => {
|
|
11894
|
+
if (mentor === null || mentor === void 0 ? void 0 : mentor.id) {
|
|
11895
|
+
return mentor.id;
|
|
11896
|
+
}
|
|
11897
|
+
if (mentor === null || mentor === void 0 ? void 0 : mentor.unique_id) {
|
|
11898
|
+
try {
|
|
11899
|
+
const response = await getMentorPublicSettings({
|
|
11900
|
+
// @ts-ignore
|
|
11901
|
+
mentor: mentor.unique_id,
|
|
11902
|
+
org: tenantKey,
|
|
11903
|
+
// @ts-ignore
|
|
11904
|
+
userId: username,
|
|
11905
|
+
}).unwrap();
|
|
11906
|
+
return response === null || response === void 0 ? void 0 : response.mentor_id;
|
|
11907
|
+
}
|
|
11908
|
+
catch (error) {
|
|
11909
|
+
console.log("failed to fetch mentor ID from public settings", {
|
|
11910
|
+
error: error instanceof Error ? error.message : String(error),
|
|
11911
|
+
mentorUniqueId: mentor.unique_id,
|
|
11912
|
+
});
|
|
11913
|
+
}
|
|
11914
|
+
}
|
|
11915
|
+
return undefined;
|
|
11916
|
+
};
|
|
11876
11917
|
/**
|
|
11877
11918
|
* Determines which mentor to redirect the user to by following this priority:
|
|
11878
11919
|
* 1. Recently accessed mentors
|
|
@@ -11880,9 +11921,11 @@ function MentorProvider({ children, fallback, onAuthSuccess, onAuthFailure, redi
|
|
|
11880
11921
|
* 3. Non-featured mentors
|
|
11881
11922
|
* 4. Seeded mentors (for admin users)
|
|
11882
11923
|
* 5. Creation flow or no mentors page
|
|
11924
|
+
*
|
|
11925
|
+
* Returns the mentor object if found, undefined otherwise
|
|
11883
11926
|
*/
|
|
11884
11927
|
async function determineMentorToRedirectTo() {
|
|
11885
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o
|
|
11928
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
11886
11929
|
console.log("starting mentor determination process", JSON.stringify({
|
|
11887
11930
|
tenantKey,
|
|
11888
11931
|
username,
|
|
@@ -11903,13 +11946,7 @@ function MentorProvider({ children, fallback, onAuthSuccess, onAuthFailure, redi
|
|
|
11903
11946
|
metadata.skills_embedded_mentor_name) {
|
|
11904
11947
|
const defaultMentor = JSON.parse(metadata.skills_embedded_mentor_name);
|
|
11905
11948
|
if (defaultMentor === null || defaultMentor === void 0 ? void 0 : defaultMentor.unique_id) {
|
|
11906
|
-
|
|
11907
|
-
const rbacPermissions = await loadMentorsPermissions(defaultMentor === null || defaultMentor === void 0 ? void 0 : defaultMentor.id);
|
|
11908
|
-
onLoadMentorsPermissions === null || onLoadMentorsPermissions === void 0 ? void 0 : onLoadMentorsPermissions(rbacPermissions);
|
|
11909
|
-
}
|
|
11910
|
-
redirectToMentor(tenantKey, defaultMentor.unique_id);
|
|
11911
|
-
onAuthSuccess === null || onAuthSuccess === void 0 ? void 0 : onAuthSuccess();
|
|
11912
|
-
return;
|
|
11949
|
+
return defaultMentor;
|
|
11913
11950
|
}
|
|
11914
11951
|
}
|
|
11915
11952
|
// Check for recently accessed mentors (second choice)
|
|
@@ -11929,21 +11966,13 @@ function MentorProvider({ children, fallback, onAuthSuccess, onAuthFailure, redi
|
|
|
11929
11966
|
if (starredMentors.length > 0) {
|
|
11930
11967
|
const starredMentor = starredMentors[0];
|
|
11931
11968
|
if (starredMentor === null || starredMentor === void 0 ? void 0 : starredMentor.unique_id) {
|
|
11932
|
-
|
|
11933
|
-
onLoadMentorsPermissions === null || onLoadMentorsPermissions === void 0 ? void 0 : onLoadMentorsPermissions(rbacPermissions);
|
|
11934
|
-
redirectToMentor(tenantKey, starredMentor.unique_id);
|
|
11935
|
-
onAuthSuccess === null || onAuthSuccess === void 0 ? void 0 : onAuthSuccess();
|
|
11936
|
-
return;
|
|
11969
|
+
return starredMentor;
|
|
11937
11970
|
}
|
|
11938
11971
|
}
|
|
11939
11972
|
if (recentMentors.length > 0) {
|
|
11940
11973
|
const recentMentor = recentMentors[0];
|
|
11941
11974
|
if (recentMentor === null || recentMentor === void 0 ? void 0 : recentMentor.unique_id) {
|
|
11942
|
-
|
|
11943
|
-
onLoadMentorsPermissions === null || onLoadMentorsPermissions === void 0 ? void 0 : onLoadMentorsPermissions(rbacPermissions);
|
|
11944
|
-
redirectToMentor(tenantKey, recentMentor.unique_id);
|
|
11945
|
-
onAuthSuccess === null || onAuthSuccess === void 0 ? void 0 : onAuthSuccess();
|
|
11946
|
-
return;
|
|
11975
|
+
return recentMentor;
|
|
11947
11976
|
}
|
|
11948
11977
|
}
|
|
11949
11978
|
const recentMentorsResult = await fetchMentors({
|
|
@@ -11960,19 +11989,12 @@ function MentorProvider({ children, fallback, onAuthSuccess, onAuthFailure, redi
|
|
|
11960
11989
|
}));
|
|
11961
11990
|
// Check if we found recent mentors for the tenant
|
|
11962
11991
|
if (recentMentors.length > 0) {
|
|
11963
|
-
|
|
11964
|
-
|
|
11965
|
-
|
|
11966
|
-
selectedMentorId,
|
|
11967
|
-
mentorName: (_d = recentMentors[0]) === null || _d === void 0 ? void 0 : _d.name,
|
|
11992
|
+
console.log("found recent mentor", JSON.stringify({
|
|
11993
|
+
selectedMentorId: (_b = recentMentors[0]) === null || _b === void 0 ? void 0 : _b.unique_id,
|
|
11994
|
+
mentorName: (_c = recentMentors[0]) === null || _c === void 0 ? void 0 : _c.name,
|
|
11968
11995
|
tenantKey,
|
|
11969
11996
|
}));
|
|
11970
|
-
|
|
11971
|
-
// Select the most recent mentor as current mentor
|
|
11972
|
-
onLoadMentorsPermissions === null || onLoadMentorsPermissions === void 0 ? void 0 : onLoadMentorsPermissions(rbacPermissions);
|
|
11973
|
-
redirectToMentor(tenantKey, selectedMentorId);
|
|
11974
|
-
onAuthSuccess === null || onAuthSuccess === void 0 ? void 0 : onAuthSuccess();
|
|
11975
|
-
return;
|
|
11997
|
+
return recentMentors[0];
|
|
11976
11998
|
}
|
|
11977
11999
|
// If no recent mentors, get featured mentors
|
|
11978
12000
|
console.log("no recent mentors found, fetching featured mentors", {
|
|
@@ -11986,7 +12008,7 @@ function MentorProvider({ children, fallback, onAuthSuccess, onAuthFailure, redi
|
|
|
11986
12008
|
limit: QUERY_LIMIT,
|
|
11987
12009
|
orderBy: "recently_accessed_at",
|
|
11988
12010
|
});
|
|
11989
|
-
const featuredMentors = ((
|
|
12011
|
+
const featuredMentors = ((_d = featuredMentorsResult.data) === null || _d === void 0 ? void 0 : _d.results) || [];
|
|
11990
12012
|
console.log("featured mentors fetched", {
|
|
11991
12013
|
count: featuredMentors.length,
|
|
11992
12014
|
mentorIds: featuredMentors.map((m) => m === null || m === void 0 ? void 0 : m.unique_id),
|
|
@@ -12006,16 +12028,11 @@ function MentorProvider({ children, fallback, onAuthSuccess, onAuthFailure, redi
|
|
|
12006
12028
|
const defaultIblMentor = featuredMentors.find((mentor) => { var _a; return ((_a = mentor === null || mentor === void 0 ? void 0 : mentor.metadata) === null || _a === void 0 ? void 0 : _a.default) === true; });
|
|
12007
12029
|
// Check if found default featured mentor
|
|
12008
12030
|
if (defaultIblMentor) {
|
|
12009
|
-
console.log("
|
|
12031
|
+
console.log("found default IBL mentor", {
|
|
12010
12032
|
mentorId: defaultIblMentor === null || defaultIblMentor === void 0 ? void 0 : defaultIblMentor.unique_id,
|
|
12011
12033
|
mentorName: defaultIblMentor === null || defaultIblMentor === void 0 ? void 0 : defaultIblMentor.name,
|
|
12012
12034
|
});
|
|
12013
|
-
|
|
12014
|
-
const rbacPermissions = await loadMentorsPermissions(defaultIblMentorDbId);
|
|
12015
|
-
onLoadMentorsPermissions === null || onLoadMentorsPermissions === void 0 ? void 0 : onLoadMentorsPermissions(rbacPermissions);
|
|
12016
|
-
redirectToMentor === null || redirectToMentor === void 0 ? void 0 : redirectToMentor(tenantKey, (defaultIblMentor === null || defaultIblMentor === void 0 ? void 0 : defaultIblMentor.unique_id) || "");
|
|
12017
|
-
onAuthSuccess === null || onAuthSuccess === void 0 ? void 0 : onAuthSuccess();
|
|
12018
|
-
return;
|
|
12035
|
+
return defaultIblMentor;
|
|
12019
12036
|
}
|
|
12020
12037
|
}
|
|
12021
12038
|
else {
|
|
@@ -12026,30 +12043,19 @@ function MentorProvider({ children, fallback, onAuthSuccess, onAuthFailure, redi
|
|
|
12026
12043
|
// Check if there's a default featured mentor
|
|
12027
12044
|
const defaultFeatureMentor = featuredMentors.find((mentor) => { var _a; return ((_a = mentor === null || mentor === void 0 ? void 0 : mentor.metadata) === null || _a === void 0 ? void 0 : _a.default) === true; });
|
|
12028
12045
|
if (defaultFeatureMentor) {
|
|
12029
|
-
console.log("
|
|
12046
|
+
console.log("found default featured mentor", {
|
|
12030
12047
|
mentorId: defaultFeatureMentor === null || defaultFeatureMentor === void 0 ? void 0 : defaultFeatureMentor.unique_id,
|
|
12031
12048
|
mentorName: defaultFeatureMentor === null || defaultFeatureMentor === void 0 ? void 0 : defaultFeatureMentor.name,
|
|
12032
12049
|
});
|
|
12033
|
-
|
|
12034
|
-
const rbacPermissions = await loadMentorsPermissions(defaultFeatureMentorDbId);
|
|
12035
|
-
onLoadMentorsPermissions === null || onLoadMentorsPermissions === void 0 ? void 0 : onLoadMentorsPermissions(rbacPermissions);
|
|
12036
|
-
redirectToMentor(tenantKey, (defaultFeatureMentor === null || defaultFeatureMentor === void 0 ? void 0 : defaultFeatureMentor.unique_id) || "");
|
|
12037
|
-
onAuthSuccess === null || onAuthSuccess === void 0 ? void 0 : onAuthSuccess();
|
|
12038
|
-
return;
|
|
12050
|
+
return defaultFeatureMentor;
|
|
12039
12051
|
}
|
|
12040
12052
|
}
|
|
12041
12053
|
// If no default mentor, select the first featured mentor
|
|
12042
|
-
|
|
12043
|
-
|
|
12044
|
-
|
|
12045
|
-
mentorName: (_g = featuredMentors[0]) === null || _g === void 0 ? void 0 : _g.name,
|
|
12054
|
+
console.log("found first featured mentor", {
|
|
12055
|
+
mentorId: (_e = featuredMentors[0]) === null || _e === void 0 ? void 0 : _e.unique_id,
|
|
12056
|
+
mentorName: (_f = featuredMentors[0]) === null || _f === void 0 ? void 0 : _f.name,
|
|
12046
12057
|
});
|
|
12047
|
-
|
|
12048
|
-
const rbacPermissions = await loadMentorsPermissions(firstFeaturedMentorDbId);
|
|
12049
|
-
onLoadMentorsPermissions === null || onLoadMentorsPermissions === void 0 ? void 0 : onLoadMentorsPermissions(rbacPermissions);
|
|
12050
|
-
redirectToMentor(tenantKey, firstFeaturedMentorId);
|
|
12051
|
-
onAuthSuccess === null || onAuthSuccess === void 0 ? void 0 : onAuthSuccess();
|
|
12052
|
-
return;
|
|
12058
|
+
return featuredMentors[0];
|
|
12053
12059
|
}
|
|
12054
12060
|
// If no featured mentors, get non-featured mentors
|
|
12055
12061
|
console.log("no featured mentors found, fetching non-featured mentors", {
|
|
@@ -12063,24 +12069,18 @@ function MentorProvider({ children, fallback, onAuthSuccess, onAuthFailure, redi
|
|
|
12063
12069
|
limit: QUERY_LIMIT,
|
|
12064
12070
|
orderBy: "recently_accessed_at",
|
|
12065
12071
|
});
|
|
12066
|
-
const nonFeaturedMentors = ((
|
|
12072
|
+
const nonFeaturedMentors = ((_g = nonFeaturedMentorsResult.data) === null || _g === void 0 ? void 0 : _g.results) || [];
|
|
12067
12073
|
console.log("non-featured mentors fetched", {
|
|
12068
12074
|
count: nonFeaturedMentors.length,
|
|
12069
12075
|
mentorIds: nonFeaturedMentors.map((m) => m === null || m === void 0 ? void 0 : m.unique_id),
|
|
12070
12076
|
});
|
|
12071
12077
|
// Check if we found non-featured mentors
|
|
12072
12078
|
if (nonFeaturedMentors.length > 0) {
|
|
12073
|
-
|
|
12074
|
-
|
|
12075
|
-
|
|
12076
|
-
mentorName: (_l = nonFeaturedMentors[0]) === null || _l === void 0 ? void 0 : _l.name,
|
|
12079
|
+
console.log("found first non-featured mentor", {
|
|
12080
|
+
mentorId: (_h = nonFeaturedMentors[0]) === null || _h === void 0 ? void 0 : _h.unique_id,
|
|
12081
|
+
mentorName: (_j = nonFeaturedMentors[0]) === null || _j === void 0 ? void 0 : _j.name,
|
|
12077
12082
|
});
|
|
12078
|
-
|
|
12079
|
-
const rbacPermissions = await loadMentorsPermissions(firstNonFeaturedMentorDbId);
|
|
12080
|
-
onLoadMentorsPermissions === null || onLoadMentorsPermissions === void 0 ? void 0 : onLoadMentorsPermissions(rbacPermissions);
|
|
12081
|
-
redirectToMentor(tenantKey, firstNonFeaturedMentorId);
|
|
12082
|
-
onAuthSuccess === null || onAuthSuccess === void 0 ? void 0 : onAuthSuccess();
|
|
12083
|
-
return;
|
|
12083
|
+
return nonFeaturedMentors[0];
|
|
12084
12084
|
}
|
|
12085
12085
|
// If no mentors found, check if user is admin
|
|
12086
12086
|
console.log("no mentors found, checking admin status", {
|
|
@@ -12100,7 +12100,7 @@ function MentorProvider({ children, fallback, onAuthSuccess, onAuthFailure, redi
|
|
|
12100
12100
|
// @ts-ignore
|
|
12101
12101
|
userId: username,
|
|
12102
12102
|
});
|
|
12103
|
-
const seededMentorsDetails = (
|
|
12103
|
+
const seededMentorsDetails = (_k = seedMentorsResult.data) === null || _k === void 0 ? void 0 : _k.detail;
|
|
12104
12104
|
console.log("mentor seeding completed", {
|
|
12105
12105
|
success: !!seededMentorsDetails,
|
|
12106
12106
|
details: seededMentorsDetails,
|
|
@@ -12115,29 +12115,23 @@ function MentorProvider({ children, fallback, onAuthSuccess, onAuthFailure, redi
|
|
|
12115
12115
|
username,
|
|
12116
12116
|
limit: QUERY_LIMIT,
|
|
12117
12117
|
});
|
|
12118
|
-
const featuredMentorsAfterSeed = ((
|
|
12118
|
+
const featuredMentorsAfterSeed = ((_l = featuredMentorsAfterSeedResult.data) === null || _l === void 0 ? void 0 : _l.results) || [];
|
|
12119
12119
|
console.log("featured mentors after seeding", {
|
|
12120
12120
|
count: featuredMentorsAfterSeed.length,
|
|
12121
12121
|
mentorIds: featuredMentorsAfterSeed.map((m) => m === null || m === void 0 ? void 0 : m.unique_id),
|
|
12122
12122
|
});
|
|
12123
12123
|
if (featuredMentorsAfterSeed.length > 0) {
|
|
12124
|
-
|
|
12125
|
-
|
|
12126
|
-
|
|
12127
|
-
mentorName: (_r = featuredMentorsAfterSeed[0]) === null || _r === void 0 ? void 0 : _r.name,
|
|
12124
|
+
console.log("found seeded mentor", {
|
|
12125
|
+
mentorId: (_m = featuredMentorsAfterSeed[0]) === null || _m === void 0 ? void 0 : _m.unique_id,
|
|
12126
|
+
mentorName: (_o = featuredMentorsAfterSeed[0]) === null || _o === void 0 ? void 0 : _o.name,
|
|
12128
12127
|
});
|
|
12129
|
-
|
|
12130
|
-
const rbacPermissions = await loadMentorsPermissions(seededMentorDbId);
|
|
12131
|
-
onLoadMentorsPermissions === null || onLoadMentorsPermissions === void 0 ? void 0 : onLoadMentorsPermissions(rbacPermissions);
|
|
12132
|
-
redirectToMentor(tenantKey, seededMentorId);
|
|
12133
|
-
onAuthSuccess === null || onAuthSuccess === void 0 ? void 0 : onAuthSuccess();
|
|
12134
|
-
return;
|
|
12128
|
+
return featuredMentorsAfterSeed[0];
|
|
12135
12129
|
}
|
|
12136
12130
|
else {
|
|
12137
12131
|
console.log("no seeded mentors found, redirecting to create mentor");
|
|
12138
12132
|
redirectToCreateMentor();
|
|
12139
12133
|
onAuthSuccess === null || onAuthSuccess === void 0 ? void 0 : onAuthSuccess();
|
|
12140
|
-
return;
|
|
12134
|
+
return undefined;
|
|
12141
12135
|
}
|
|
12142
12136
|
}
|
|
12143
12137
|
else {
|
|
@@ -12145,7 +12139,7 @@ function MentorProvider({ children, fallback, onAuthSuccess, onAuthFailure, redi
|
|
|
12145
12139
|
// Prompt the user to create a mentor
|
|
12146
12140
|
redirectToCreateMentor();
|
|
12147
12141
|
onAuthSuccess === null || onAuthSuccess === void 0 ? void 0 : onAuthSuccess();
|
|
12148
|
-
return;
|
|
12142
|
+
return undefined;
|
|
12149
12143
|
}
|
|
12150
12144
|
}
|
|
12151
12145
|
else {
|
|
@@ -12156,7 +12150,7 @@ function MentorProvider({ children, fallback, onAuthSuccess, onAuthFailure, redi
|
|
|
12156
12150
|
// Redirect to no mentors page for non-admin users
|
|
12157
12151
|
redirectToNoMentorsPage();
|
|
12158
12152
|
onAuthSuccess === null || onAuthSuccess === void 0 ? void 0 : onAuthSuccess();
|
|
12159
|
-
return;
|
|
12153
|
+
return undefined;
|
|
12160
12154
|
}
|
|
12161
12155
|
}
|
|
12162
12156
|
catch (error) {
|
|
@@ -12172,9 +12166,11 @@ function MentorProvider({ children, fallback, onAuthSuccess, onAuthFailure, redi
|
|
|
12172
12166
|
error: errorMessage,
|
|
12173
12167
|
});
|
|
12174
12168
|
redirectToAuthSpa();
|
|
12169
|
+
return undefined;
|
|
12175
12170
|
}
|
|
12176
12171
|
finally {
|
|
12177
12172
|
setIsLoading(false);
|
|
12173
|
+
onComplete === null || onComplete === void 0 ? void 0 : onComplete();
|
|
12178
12174
|
}
|
|
12179
12175
|
}
|
|
12180
12176
|
async function mentorExistsInTenant(tenantKey, requestedMentorId) {
|
|
@@ -12210,6 +12206,7 @@ function MentorProvider({ children, fallback, onAuthSuccess, onAuthFailure, redi
|
|
|
12210
12206
|
console.log("starting mentor check process", determineUserPath, requestedMentorId, tenantKey);
|
|
12211
12207
|
if (userIsAccessingPublicRoute && !requestedMentorId) {
|
|
12212
12208
|
setIsLoading(false);
|
|
12209
|
+
onComplete === null || onComplete === void 0 ? void 0 : onComplete();
|
|
12213
12210
|
return;
|
|
12214
12211
|
}
|
|
12215
12212
|
setIsLoading(true);
|
|
@@ -12217,13 +12214,25 @@ function MentorProvider({ children, fallback, onAuthSuccess, onAuthFailure, redi
|
|
|
12217
12214
|
// then this mentor provider will redirect the user to the correct mentor.
|
|
12218
12215
|
if (determineUserPath || forceDetermineMentor) {
|
|
12219
12216
|
console.log("determine user path is true, starting mentor determination");
|
|
12220
|
-
await determineMentorToRedirectTo();
|
|
12217
|
+
const mentor = await determineMentorToRedirectTo();
|
|
12218
|
+
if (mentor === null || mentor === void 0 ? void 0 : mentor.unique_id) {
|
|
12219
|
+
// Get mentor DB ID - use existing ID or fetch from public settings
|
|
12220
|
+
let mentorDbId = mentor === null || mentor === void 0 ? void 0 : mentor.id;
|
|
12221
|
+
if (!mentorDbId) {
|
|
12222
|
+
mentorDbId = await getMentorDbId(mentor);
|
|
12223
|
+
}
|
|
12224
|
+
// Load permissions if we have a mentor DB ID
|
|
12225
|
+
if (mentorDbId) {
|
|
12226
|
+
const rbacPermissions = await loadMentorsPermissions(mentorDbId);
|
|
12227
|
+
onLoadMentorsPermissions === null || onLoadMentorsPermissions === void 0 ? void 0 : onLoadMentorsPermissions(rbacPermissions);
|
|
12228
|
+
}
|
|
12229
|
+
// Redirect to the mentor
|
|
12230
|
+
redirectToMentor(tenantKey, mentor.unique_id);
|
|
12231
|
+
onAuthSuccess === null || onAuthSuccess === void 0 ? void 0 : onAuthSuccess();
|
|
12232
|
+
}
|
|
12221
12233
|
return;
|
|
12222
12234
|
}
|
|
12223
12235
|
else if (requestedMentorId) {
|
|
12224
|
-
console.log(" ", {
|
|
12225
|
-
requestedMentorId,
|
|
12226
|
-
});
|
|
12227
12236
|
const [mentorExists, requestedMentorDbId] = await mentorExistsInTenant(tenantKey, requestedMentorId);
|
|
12228
12237
|
// If the mentor does not exist in the tenant, redirect the user to the correct mentor
|
|
12229
12238
|
if (!mentorExists) {
|
|
@@ -12238,7 +12247,22 @@ function MentorProvider({ children, fallback, onAuthSuccess, onAuthFailure, redi
|
|
|
12238
12247
|
}
|
|
12239
12248
|
else {
|
|
12240
12249
|
console.log("using default mentor determination fallback");
|
|
12241
|
-
await determineMentorToRedirectTo();
|
|
12250
|
+
const mentor = await determineMentorToRedirectTo();
|
|
12251
|
+
if (mentor === null || mentor === void 0 ? void 0 : mentor.unique_id) {
|
|
12252
|
+
// Get mentor DB ID - use existing ID or fetch from public settings
|
|
12253
|
+
let mentorDbId = mentor === null || mentor === void 0 ? void 0 : mentor.id;
|
|
12254
|
+
if (!mentorDbId) {
|
|
12255
|
+
mentorDbId = await getMentorDbId(mentor);
|
|
12256
|
+
}
|
|
12257
|
+
// Load permissions if we have a mentor DB ID
|
|
12258
|
+
if (mentorDbId) {
|
|
12259
|
+
const rbacPermissions = await loadMentorsPermissions(mentorDbId);
|
|
12260
|
+
onLoadMentorsPermissions === null || onLoadMentorsPermissions === void 0 ? void 0 : onLoadMentorsPermissions(rbacPermissions);
|
|
12261
|
+
}
|
|
12262
|
+
// Redirect to the mentor
|
|
12263
|
+
redirectToMentor(tenantKey, mentor.unique_id);
|
|
12264
|
+
onAuthSuccess === null || onAuthSuccess === void 0 ? void 0 : onAuthSuccess();
|
|
12265
|
+
}
|
|
12242
12266
|
}
|
|
12243
12267
|
return;
|
|
12244
12268
|
}
|
|
@@ -12249,16 +12273,24 @@ function MentorProvider({ children, fallback, onAuthSuccess, onAuthFailure, redi
|
|
|
12249
12273
|
onLoadMentorsPermissions === null || onLoadMentorsPermissions === void 0 ? void 0 : onLoadMentorsPermissions(rbacPermissions);
|
|
12250
12274
|
}
|
|
12251
12275
|
setIsLoading(false);
|
|
12276
|
+
onComplete === null || onComplete === void 0 ? void 0 : onComplete();
|
|
12252
12277
|
}
|
|
12253
12278
|
// If the user is navigating to a specific mentor, check if it exists in the tenant
|
|
12254
12279
|
}
|
|
12255
12280
|
else {
|
|
12256
12281
|
console.log("no specific mentor requested, loading complete");
|
|
12257
12282
|
setIsLoading(false);
|
|
12283
|
+
onComplete === null || onComplete === void 0 ? void 0 : onComplete();
|
|
12258
12284
|
}
|
|
12259
12285
|
}
|
|
12260
12286
|
checkMentor();
|
|
12261
|
-
}, [
|
|
12287
|
+
}, [
|
|
12288
|
+
requestedMentorId,
|
|
12289
|
+
determineUserPath,
|
|
12290
|
+
forceDetermineMentor,
|
|
12291
|
+
userIsAccessingPublicRoute,
|
|
12292
|
+
tenantKey,
|
|
12293
|
+
]);
|
|
12262
12294
|
// Show fallback component during mentor determination
|
|
12263
12295
|
if (isLoading) {
|
|
12264
12296
|
console.log("mentor provider showing fallback component");
|
|
@@ -13227,7 +13259,7 @@ const useChat = ({ wsUrl, wsToken, flowConfig, sessionId, stopGenerationWsUrl, e
|
|
|
13227
13259
|
await hapticFeedback.impactAsync("medium");
|
|
13228
13260
|
}
|
|
13229
13261
|
catch (error) {
|
|
13230
|
-
|
|
13262
|
+
errorHandler === null || errorHandler === void 0 ? void 0 : errorHandler("Haptic feedback failed", error);
|
|
13231
13263
|
}
|
|
13232
13264
|
}
|
|
13233
13265
|
}, [enableHaptics, hapticFeedback]);
|
|
@@ -13274,6 +13306,7 @@ const useChat = ({ wsUrl, wsToken, flowConfig, sessionId, stopGenerationWsUrl, e
|
|
|
13274
13306
|
onStreamingChange === null || onStreamingChange === void 0 ? void 0 : onStreamingChange(false);
|
|
13275
13307
|
});
|
|
13276
13308
|
socket.addEventListener("message", (event) => {
|
|
13309
|
+
var _a, _b, _c;
|
|
13277
13310
|
if (isWebSocketPaused.current)
|
|
13278
13311
|
return;
|
|
13279
13312
|
try {
|
|
@@ -13323,14 +13356,14 @@ const useChat = ({ wsUrl, wsToken, flowConfig, sessionId, stopGenerationWsUrl, e
|
|
|
13323
13356
|
if (messageData.data !== undefined || messageData.eos !== undefined) {
|
|
13324
13357
|
const messageText = messageData.data || "";
|
|
13325
13358
|
// If we have content to add
|
|
13326
|
-
if (messageText) {
|
|
13359
|
+
if (messageText && currentStreamingMessage.current) {
|
|
13327
13360
|
currentStreamingMessage.current = {
|
|
13328
13361
|
...currentStreamingMessage.current,
|
|
13329
13362
|
content: currentStreamingMessage.current.content + messageText,
|
|
13330
13363
|
};
|
|
13331
13364
|
onStreamingMessageUpdate === null || onStreamingMessageUpdate === void 0 ? void 0 : onStreamingMessageUpdate(currentStreamingMessage.current);
|
|
13332
13365
|
// Update or add message in Redux store
|
|
13333
|
-
if (currentStreamingMessage.current.id) {
|
|
13366
|
+
if ((_a = currentStreamingMessage.current) === null || _a === void 0 ? void 0 : _a.id) {
|
|
13334
13367
|
dispatch(chatActions.appendMessageToActiveTab({
|
|
13335
13368
|
id: currentStreamingMessage.current.id,
|
|
13336
13369
|
content: currentStreamingMessage.current.content,
|
|
@@ -13340,8 +13373,8 @@ const useChat = ({ wsUrl, wsToken, flowConfig, sessionId, stopGenerationWsUrl, e
|
|
|
13340
13373
|
// Handle end of stream
|
|
13341
13374
|
if (messageData.eos) {
|
|
13342
13375
|
// Final update to Redux store with complete message
|
|
13343
|
-
if (currentStreamingMessage.current.id &&
|
|
13344
|
-
currentStreamingMessage.current.content) {
|
|
13376
|
+
if (((_b = currentStreamingMessage.current) === null || _b === void 0 ? void 0 : _b.id) &&
|
|
13377
|
+
((_c = currentStreamingMessage.current) === null || _c === void 0 ? void 0 : _c.content)) {
|
|
13345
13378
|
dispatch(chatActions.appendMessageToActiveTab({
|
|
13346
13379
|
id: currentStreamingMessage.current.id,
|
|
13347
13380
|
content: currentStreamingMessage.current.content,
|
|
@@ -13356,13 +13389,13 @@ const useChat = ({ wsUrl, wsToken, flowConfig, sessionId, stopGenerationWsUrl, e
|
|
|
13356
13389
|
}
|
|
13357
13390
|
}
|
|
13358
13391
|
catch (error) {
|
|
13359
|
-
|
|
13392
|
+
errorHandler === null || errorHandler === void 0 ? void 0 : errorHandler("Error processing message", error);
|
|
13360
13393
|
onStreamingChange === null || onStreamingChange === void 0 ? void 0 : onStreamingChange(false);
|
|
13361
13394
|
onStatusChange("error");
|
|
13362
13395
|
}
|
|
13363
13396
|
});
|
|
13364
13397
|
socket.addEventListener("error", (error) => {
|
|
13365
|
-
|
|
13398
|
+
errorHandler === null || errorHandler === void 0 ? void 0 : errorHandler("WebSocket error", error);
|
|
13366
13399
|
onStreamingChange === null || onStreamingChange === void 0 ? void 0 : onStreamingChange(false);
|
|
13367
13400
|
onStatusChange("error");
|
|
13368
13401
|
});
|
|
@@ -13513,8 +13546,12 @@ const useChat = ({ wsUrl, wsToken, flowConfig, sessionId, stopGenerationWsUrl, e
|
|
|
13513
13546
|
}
|
|
13514
13547
|
};
|
|
13515
13548
|
const _initiateServerStopGeneration = () => {
|
|
13516
|
-
var _a;
|
|
13517
|
-
(_a =
|
|
13549
|
+
var _a, _b;
|
|
13550
|
+
if (!((_a = currentStreamingMessage.current) === null || _a === void 0 ? void 0 : _a.id)) {
|
|
13551
|
+
console.warn("Cannot stop generation: no active generation ID");
|
|
13552
|
+
return;
|
|
13553
|
+
}
|
|
13554
|
+
(_b = stopGenerationSocket === null || stopGenerationSocket === void 0 ? void 0 : stopGenerationSocket.current) === null || _b === void 0 ? void 0 : _b.send(JSON.stringify({
|
|
13518
13555
|
generation_id: currentStreamingMessage.current.id,
|
|
13519
13556
|
name: flowConfig.name,
|
|
13520
13557
|
tenant: flowConfig.tenant,
|
|
@@ -13574,7 +13611,7 @@ const useChat = ({ wsUrl, wsToken, flowConfig, sessionId, stopGenerationWsUrl, e
|
|
|
13574
13611
|
};
|
|
13575
13612
|
};
|
|
13576
13613
|
|
|
13577
|
-
function useMentorSettings({ mentorId, tenantKey, username }) {
|
|
13614
|
+
function useMentorSettings({ mentorId, tenantKey, username, }) {
|
|
13578
13615
|
var _a, _b, _c, _d;
|
|
13579
13616
|
const isLoggedIn = username !== ANONYMOUS_USERNAME;
|
|
13580
13617
|
const { data: mentorSettings } = useGetMentorSettingsQuery({
|
|
@@ -13610,6 +13647,9 @@ function useMentorSettings({ mentorId, tenantKey, username }) {
|
|
|
13610
13647
|
mentorUniqueId: isLoggedIn
|
|
13611
13648
|
? mentorSettings === null || mentorSettings === void 0 ? void 0 : mentorSettings.mentor_unique_id
|
|
13612
13649
|
: mentorPublicSettings === null || mentorPublicSettings === void 0 ? void 0 : mentorPublicSettings.mentor_unique_id,
|
|
13650
|
+
mentorVisibility: isLoggedIn
|
|
13651
|
+
? mentorSettings === null || mentorSettings === void 0 ? void 0 : mentorSettings.mentor_visibility
|
|
13652
|
+
: mentorPublicSettings === null || mentorPublicSettings === void 0 ? void 0 : mentorPublicSettings.mentor_visibility,
|
|
13613
13653
|
mentorName: (_a = mentorSettings === null || mentorSettings === void 0 ? void 0 : mentorSettings.mentor) !== null && _a !== void 0 ? _a : mentorPublicSettings === null || mentorPublicSettings === void 0 ? void 0 : mentorPublicSettings.mentor,
|
|
13614
13654
|
enableGuidedPrompts: isLoggedIn
|
|
13615
13655
|
? mentorSettings === null || mentorSettings === void 0 ? void 0 : mentorSettings.enable_guided_prompts
|
|
@@ -13629,7 +13669,7 @@ function useMentorSettings({ mentorId, tenantKey, username }) {
|
|
|
13629
13669
|
}
|
|
13630
13670
|
|
|
13631
13671
|
function useAdvancedChat({ tenantKey, mentorId, username = ANONYMOUS_USERNAME, token, wsUrl, stopGenerationWsUrl, redirectToAuthSpa, errorHandler, sendMessageToParentWebsite, isPreviewMode, mentorShareableToken, on402Error, cachedSessionId, onStartNewChat, }) {
|
|
13632
|
-
var _a, _b, _c, _d;
|
|
13672
|
+
var _a, _b, _c, _d, _e;
|
|
13633
13673
|
const dispatch = useDispatch();
|
|
13634
13674
|
const [createSessionId, { isLoading: isLoadingSessionIds }] = useCreateSessionIdMutation();
|
|
13635
13675
|
const chats = useSelector(selectChats);
|
|
@@ -13667,7 +13707,7 @@ function useAdvancedChat({ tenantKey, mentorId, username = ANONYMOUS_USERNAME, t
|
|
|
13667
13707
|
username,
|
|
13668
13708
|
pathway: mentorId,
|
|
13669
13709
|
},
|
|
13670
|
-
sessionId: cachedSessionId !== null &&
|
|
13710
|
+
sessionId: (_a = cachedSessionId === null || cachedSessionId === void 0 ? void 0 : cachedSessionId[mentorId]) !== null && _a !== void 0 ? _a : sessionIds[activeTab],
|
|
13671
13711
|
activeTab,
|
|
13672
13712
|
wsToken: token,
|
|
13673
13713
|
errorHandler,
|
|
@@ -13681,17 +13721,17 @@ function useAdvancedChat({ tenantKey, mentorId, username = ANONYMOUS_USERNAME, t
|
|
|
13681
13721
|
const [getSessionChats, { isError: isErrorGettingSessionChats }] = useLazyGetSessionIdQuery();
|
|
13682
13722
|
React.useEffect(() => {
|
|
13683
13723
|
const getChats = async () => {
|
|
13684
|
-
var _a;
|
|
13724
|
+
var _a, _b;
|
|
13685
13725
|
try {
|
|
13686
13726
|
const { data } = await getSessionChats({
|
|
13687
|
-
sessionId: cachedSessionId !== null &&
|
|
13727
|
+
sessionId: (_a = cachedSessionId === null || cachedSessionId === void 0 ? void 0 : cachedSessionId[mentorId]) !== null && _a !== void 0 ? _a : "",
|
|
13688
13728
|
org: tenantKey,
|
|
13689
13729
|
share: true,
|
|
13690
13730
|
});
|
|
13691
13731
|
let previousChats = [];
|
|
13692
13732
|
try {
|
|
13693
13733
|
previousChats =
|
|
13694
|
-
((
|
|
13734
|
+
((_b = data === null || data === void 0 ? void 0 : data.results) === null || _b === void 0 ? void 0 : _b.map((result) => {
|
|
13695
13735
|
return {
|
|
13696
13736
|
...result,
|
|
13697
13737
|
role: result.type === "human" ? "user" : "assistant",
|
|
@@ -13707,14 +13747,21 @@ function useAdvancedChat({ tenantKey, mentorId, username = ANONYMOUS_USERNAME, t
|
|
|
13707
13747
|
catch (error) {
|
|
13708
13748
|
console.error(JSON.stringify(error));
|
|
13709
13749
|
}
|
|
13750
|
+
// Ensures that the first AI response due to a Proactive prompt
|
|
13751
|
+
// doesn't show up as part of the chats
|
|
13752
|
+
if ((data === null || data === void 0 ? void 0 : data.proactive_prompt) &&
|
|
13753
|
+
previousChats.length > 0 &&
|
|
13754
|
+
previousChats[0].type === "ai") {
|
|
13755
|
+
previousChats.splice(0, 1);
|
|
13756
|
+
}
|
|
13710
13757
|
dispatch(chatActions.setNewMessages(previousChats));
|
|
13711
13758
|
}
|
|
13712
13759
|
catch (error) {
|
|
13713
13760
|
console.error(JSON.stringify(error));
|
|
13714
13761
|
}
|
|
13715
13762
|
};
|
|
13716
|
-
if (cachedSessionId) {
|
|
13717
|
-
dispatch(chatActions.updateSessionIds(cachedSessionId));
|
|
13763
|
+
if (cachedSessionId === null || cachedSessionId === void 0 ? void 0 : cachedSessionId[mentorId]) {
|
|
13764
|
+
dispatch(chatActions.updateSessionIds(cachedSessionId === null || cachedSessionId === void 0 ? void 0 : cachedSessionId[mentorId]));
|
|
13718
13765
|
getChats();
|
|
13719
13766
|
}
|
|
13720
13767
|
}, [cachedSessionId]);
|
|
@@ -13752,9 +13799,12 @@ function useAdvancedChat({ tenantKey, mentorId, username = ANONYMOUS_USERNAME, t
|
|
|
13752
13799
|
onStartNewChat === null || onStartNewChat === void 0 ? void 0 : onStartNewChat(response.session_id);
|
|
13753
13800
|
}
|
|
13754
13801
|
catch (error) {
|
|
13755
|
-
|
|
13756
|
-
|
|
13757
|
-
|
|
13802
|
+
if (mentorSettings.mentorVisibility !==
|
|
13803
|
+
iblaiApi.MentorVisibilityEnum.VIEWABLE_BY_ANYONE) {
|
|
13804
|
+
errorHandler === null || errorHandler === void 0 ? void 0 : errorHandler(`Failed to start new chat: ${JSON.stringify(error)}`);
|
|
13805
|
+
console.log("[auth-redirect] Failed to start new chat", JSON.stringify({ error }));
|
|
13806
|
+
redirectToAuthSpa(undefined, undefined, true);
|
|
13807
|
+
}
|
|
13758
13808
|
}
|
|
13759
13809
|
}, [
|
|
13760
13810
|
isPreviewMode,
|
|
@@ -13768,7 +13818,8 @@ function useAdvancedChat({ tenantKey, mentorId, username = ANONYMOUS_USERNAME, t
|
|
|
13768
13818
|
]);
|
|
13769
13819
|
React.useEffect(() => {
|
|
13770
13820
|
if (!showingSharedChat || mentorSettings.allowAnonymous) {
|
|
13771
|
-
if (mentorSettings.allowAnonymous !== undefined &&
|
|
13821
|
+
if (mentorSettings.allowAnonymous !== undefined &&
|
|
13822
|
+
!(cachedSessionId === null || cachedSessionId === void 0 ? void 0 : cachedSessionId[mentorId])) {
|
|
13772
13823
|
startNewChat();
|
|
13773
13824
|
}
|
|
13774
13825
|
}
|
|
@@ -13840,9 +13891,9 @@ function useAdvancedChat({ tenantKey, mentorId, username = ANONYMOUS_USERNAME, t
|
|
|
13840
13891
|
currentStreamingMessage,
|
|
13841
13892
|
activeTab,
|
|
13842
13893
|
uniqueMentorId: mentorId,
|
|
13843
|
-
mentorName: (
|
|
13844
|
-
profileImage: (
|
|
13845
|
-
enabledGuidedPrompts: (
|
|
13894
|
+
mentorName: (_b = mentorSettings === null || mentorSettings === void 0 ? void 0 : mentorSettings.mentorName) !== null && _b !== void 0 ? _b : "",
|
|
13895
|
+
profileImage: (_c = mentorSettings === null || mentorSettings === void 0 ? void 0 : mentorSettings.profileImage) !== null && _c !== void 0 ? _c : "",
|
|
13896
|
+
enabledGuidedPrompts: (_d = mentorSettings === null || mentorSettings === void 0 ? void 0 : mentorSettings.enableGuidedPrompts) !== null && _d !== void 0 ? _d : true,
|
|
13846
13897
|
sendMessage,
|
|
13847
13898
|
stopGenerating,
|
|
13848
13899
|
setMessage,
|
|
@@ -13854,7 +13905,7 @@ function useAdvancedChat({ tenantKey, mentorId, username = ANONYMOUS_USERNAME, t
|
|
|
13854
13905
|
isConnected,
|
|
13855
13906
|
messageQueue,
|
|
13856
13907
|
sessionIds,
|
|
13857
|
-
enableSafetyDisclaimer: (
|
|
13908
|
+
enableSafetyDisclaimer: (_e = mentorSettings === null || mentorSettings === void 0 ? void 0 : mentorSettings.safetyDisclaimer) !== null && _e !== void 0 ? _e : false,
|
|
13858
13909
|
resetConnection,
|
|
13859
13910
|
};
|
|
13860
13911
|
}
|