@iblai/iblai-js 1.5.4 → 1.6.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/playwright/billing-tab-helpers.d.ts +88 -0
- package/dist/data-layer/playwright/credit-balance-helpers.d.ts +73 -0
- package/dist/data-layer/playwright/index.d.ts +4 -0
- package/dist/playwright/index.cjs +438 -0
- package/dist/playwright/index.cjs.map +1 -1
- package/dist/playwright/index.d.ts +162 -2
- package/dist/playwright/index.esm.js +408 -1
- package/dist/playwright/index.esm.js.map +1 -1
- package/dist/playwright/playwright/billing-tab-helpers.d.ts +88 -0
- package/dist/playwright/playwright/credit-balance-helpers.d.ts +73 -0
- package/dist/playwright/playwright/index.d.ts +4 -0
- package/dist/web-containers/playwright/billing-tab-helpers.d.ts +88 -0
- package/dist/web-containers/playwright/credit-balance-helpers.d.ts +73 -0
- package/dist/web-containers/playwright/index.d.ts +4 -0
- package/dist/web-containers/source/index.esm.js +562 -176
- package/dist/web-containers/source/next/index.esm.js +274 -212
- package/dist/web-utils/playwright/billing-tab-helpers.d.ts +88 -0
- package/dist/web-utils/playwright/credit-balance-helpers.d.ts +73 -0
- package/dist/web-utils/playwright/index.d.ts +4 -0
- package/package.json +5 -5
|
@@ -7,9 +7,9 @@ import Link$2 from 'next/link';
|
|
|
7
7
|
import * as ReactDOM from 'react-dom';
|
|
8
8
|
import ReactDOM__default from 'react-dom';
|
|
9
9
|
import { z as z$1 } from 'zod';
|
|
10
|
-
import { useGetUserMetadataQuery, useGetUserMetadataEdxQuery, useUpdateUserMetadataMutation, useUpdateUserMetadataEdxMutation, useUploadProfileImageMutation, useResetPasswordMutation, useSelfRetireMutation, useCreateUserInstitutionMutation, useGetUserInstitutionsQuery, useCreateUserEducationMutation, useUpdateUserEducationMutation, useDeleteUserEducationMutation, useGetUserEducationQuery, useCreateUserCompanyMutation, useGetUserCompaniesQuery, useCreateUserExperienceMutation, useUpdateUserExperienceMutation, useDeleteUserExperienceMutation, useGetUserExperienceQuery, useGetUserResumeQuery, useCreateUserResumeMutation, useGetMySubscriptionsQuery, useGetItemSubscriptionQuery, useCancelSubscriptionMutation, useCreateGlobalMemoryMutation, useGetMemsearchStatusQuery, useGetUserMemorySettingsQuery, useUpdateUserMemorySettingsMutation, useGetGlobalMemoriesQuery, useDeleteGlobalMemoryMutation, useInviteUserMutation, usePlatformInvitationsQuery, useCreateCatalogInvitationCourseBulkMutation, useGetCatalogInvitationsCourseQuery, useLazyPlatformUsersQuery, useLazyPlatformUserGroupsQuery, useGetPersonnalizedSearchQuery, useCreateCatalogInvitationProgramBulkMutation, useGetCatalogInvitationsProgramQuery, useLazyGetCourseMetaDataQuery, useLazyGetCourseCompletionOutlinesQuery, useLazyGetCourseEligibilityQuery, useLazyGetEdxSSOTokenQuery, useCreateCourseEnrollmentMutation, useCreateStripeCheckoutSessionMutation, useLazyGetCourseProgressQuery, useLazyGetCourseCompletionQuery, useUpdateExamAttemptMutation, useStartExamMutation, useLazyGetExamInfoQuery, useUpdateUserRoleMutation, useUpdateUserStatusMutation, useUpdatePlatformUserRoleWithPoliciesMutation, usePlatformUsersQuery, isPoliciesResponse, platformApiSlice, featureTags, useLazyGetRbacTeamsAccessListQuery, useCreateRbacTeamsAccessMutation, useGetRbacGroupsQuery, usePlatformUserGroupsQuery, useCreateRbacGroupMutation, useUpdateRbacGroupMutation, useDeleteRbacGroupMutation, useCreatePlatformUserGroupMutation, useUpdatePlatformUserGroupMutation, useDeletePlatformUserGroupMutation, useGetRbacGroupDetailsQuery, useGetPlatformUserGroupDetailsQuery, useGetRbacPermissionsMutation, useGetRbacRolesQuery, useCreateRbacRoleMutation, useUpdateRbacRoleMutation, useDeleteRbacRoleMutation, useGetRbacRoleDetailsQuery, useGetRbacPoliciesQuery, useCreateRbacPolicyMutation, useUpdateRbacPolicyMutation, useDeleteRbacPolicyMutation, useGetRbacPolicyDetailsQuery, useUploadLightLogoMutation, useUploadDarkLogoMutation, useUpdatePlatformInfoMutation, useUpdateTenantMetadataMutation, LOGO_ENDPOINTS, useDeleteApiKeyMutation, useGetApiKeysQuery, useCreateApiKeyMutation, useCreateLLMCredentialMutation, useGetCredentialsSchemaQuery, useGetMaskedLLMCredentialsQuery, useGetLlmsQuery, useDeleteIntegrationCredentialMutation, useDeleteCredentialMutation, useCreateIntegrationCredentialMutation, useGetIntegrationCredentialsSchemaQuery, useGetMaskedIntegrationCredentialsQuery,
|
|
10
|
+
import { useGetUserMetadataQuery, useGetUserMetadataEdxQuery, useUpdateUserMetadataMutation, useUpdateUserMetadataEdxMutation, useUploadProfileImageMutation, useResetPasswordMutation, useSelfRetireMutation, useCreateUserInstitutionMutation, useGetUserInstitutionsQuery, useCreateUserEducationMutation, useUpdateUserEducationMutation, useDeleteUserEducationMutation, useGetUserEducationQuery, useCreateUserCompanyMutation, useGetUserCompaniesQuery, useCreateUserExperienceMutation, useUpdateUserExperienceMutation, useDeleteUserExperienceMutation, useGetUserExperienceQuery, useGetUserResumeQuery, useCreateUserResumeMutation, useGetMySubscriptionsQuery, useGetItemSubscriptionQuery, useCancelSubscriptionMutation, useCreateGlobalMemoryMutation, useGetMemsearchStatusQuery, useGetUserMemorySettingsQuery, useUpdateUserMemorySettingsMutation, useGetGlobalMemoriesQuery, useDeleteGlobalMemoryMutation, useInviteUserMutation, usePlatformInvitationsQuery, useCreateCatalogInvitationCourseBulkMutation, useGetCatalogInvitationsCourseQuery, useLazyPlatformUsersQuery, useLazyPlatformUserGroupsQuery, useGetPersonnalizedSearchQuery, useCreateCatalogInvitationProgramBulkMutation, useGetCatalogInvitationsProgramQuery, useLazyGetCourseMetaDataQuery, useLazyGetCourseCompletionOutlinesQuery, useLazyGetCourseEligibilityQuery, useLazyGetEdxSSOTokenQuery, useCreateCourseEnrollmentMutation, useCreateStripeCheckoutSessionMutation, useLazyGetCourseProgressQuery, useLazyGetCourseCompletionQuery, useUpdateExamAttemptMutation, useStartExamMutation, useLazyGetExamInfoQuery, useGetAccountBillingInfoQuery, useUpdateAutoRechargeInfoMutation, useTriggerAutoRechargeMutation, useUpdateUserRoleMutation, useUpdateUserStatusMutation, useUpdatePlatformUserRoleWithPoliciesMutation, usePlatformUsersQuery, isPoliciesResponse, platformApiSlice, featureTags, useLazyGetRbacTeamsAccessListQuery, useCreateRbacTeamsAccessMutation, useGetRbacGroupsQuery, usePlatformUserGroupsQuery, useCreateRbacGroupMutation, useUpdateRbacGroupMutation, useDeleteRbacGroupMutation, useCreatePlatformUserGroupMutation, useUpdatePlatformUserGroupMutation, useDeletePlatformUserGroupMutation, useGetRbacGroupDetailsQuery, useGetPlatformUserGroupDetailsQuery, useGetRbacPermissionsMutation, useGetRbacRolesQuery, useCreateRbacRoleMutation, useUpdateRbacRoleMutation, useDeleteRbacRoleMutation, useGetRbacRoleDetailsQuery, useGetRbacPoliciesQuery, useCreateRbacPolicyMutation, useUpdateRbacPolicyMutation, useDeleteRbacPolicyMutation, useGetRbacPolicyDetailsQuery, useUploadLightLogoMutation, useUploadDarkLogoMutation, useUpdatePlatformInfoMutation, useUpdateTenantMetadataMutation, LOGO_ENDPOINTS, useDeleteApiKeyMutation, useGetApiKeysQuery, useCreateApiKeyMutation, useCreateLLMCredentialMutation, useGetCredentialsSchemaQuery, useGetMaskedLLMCredentialsQuery, useGetLlmsQuery, useDeleteIntegrationCredentialMutation, useDeleteCredentialMutation, useCreateIntegrationCredentialMutation, useGetIntegrationCredentialsSchemaQuery, useGetMaskedIntegrationCredentialsQuery, useCreateStripeCustomerPortalMutation, useSetPlatformConfigurationsMutation, useGetPlatformConfigurationsQuery, useUpdatePlatformMembershipMutation, useGetPlatformMembershipQuery, useGetCustomDomainsQuery, useCreateCustomDomainMutation, useDeleteCustomDomainMutation, useGetStudentMentorCreationStatusQuery, useSetStudentMentorCreationStatusMutation, coreApiSlice, recommendationPromptTypeEnum, useGetRecommendedPromptsListQuery, useCreateRecommendedPromptMutation, useUpdateRecommendedPromptMutation, useDeleteRecommendedPromptMutation, useLazyGetPublicPlatformImageAssetFileUrlQuery, useCreatePlatformImageAssetMutation, useGetProviderConfigQuery, useCreateProviderConfigMutation, useDeleteProviderConfigMutation, useGetExternalMappingQuery, useGetCredentialsListQuery, useCreateExternalMappingMutation, useDeleteExternalMappingMutation, useGetMemsearchConfigQuery, useUpdateMemsearchConfigMutation, useGetCustomMentorsQuery, useGetStripeConnectStatusQuery, useStartStripeConnectOnboardingMutation, useLazyGetStripeConnectDashboardQuery, useListPricesQuery, useCreatePriceMutation, useUpdatePriceMutation, useDeletePriceMutation, useGetPaywallConfigQuery, useEnablePaywallMutation, useDisablePaywallMutation, useListPaywallsQuery, useGetAiSearchMentorsQuery, useCreateSessionIdMutation, useGetMentorCategoriesQuery, useGetMentorSettingsQuery, useEditMentorMutation, useDeleteMentorMutation, useForkMentorMutation, useGetToolsQuery, useGetMentorMemoriesQuery, useGetMemoryCategoriesAdminQuery, useDeleteMentorMemoryMutation, useUpdateMentorMemoryMutation, useCreateMentorMemoryMutation, useGetPromptCategoriesQuery, useGetMentorPublicSettingsQuery, useGetChatHistoryFilterQuery, useGetChatHistoryQuery, useGetMentorSummariesQuery, useGetConversationMemoriesQuery, useEditTrainingDocumentMutation, useGetTrainingDocumentsQuery, useCreatePromptMutation, useGetPromptsSearchQuery, useUpdatePromptMutation, useCreateRedirectTokenMutation, useGetShareableLinkQuery, useCreateShareableLinkMutation, useUpdateShareableLinkMutation, useCreateDisclaimerMutation, useUpdateDisclaimerMutation, useGetDisclaimersQuery, useUpdateRbacMentorAccessMutation, useGetRbacMentorAccessListQuery, useStarMentorMutation, useUnstarMentorMutation, useGetPersonnalizedMentorsQuery, useDeleteTrainingDocumentMutation, useGetTrainingDocumentRetrainScheduleQuery, useCreateTrainingDocumentRetrainScheduleMutation } from '@iblai/data-layer';
|
|
11
11
|
import { toast, Toaster as Toaster$1 } from 'sonner';
|
|
12
|
-
import { getInitials, useTenantMetadata, isAlphaNumeric32, checkRbacPermission, WithPermissions, useTenantContext, CHAT_AREA_SIZE, TimeTracker, advancedTabsProperties, defaultSessionIds, chatActions, WithFormPermissions } from '@iblai/web-utils';
|
|
12
|
+
import { getInitials, useTenantMetadata, isAlphaNumeric32, checkRbacPermission, WithPermissions, useTenantContext, useStripeUpgrade, CHAT_AREA_SIZE, TimeTracker, advancedTabsProperties, defaultSessionIds, chatActions, WithFormPermissions } from '@iblai/web-utils';
|
|
13
13
|
import { MentorVisibilityEnum, PromptVisibilityEnum } from '@iblai/iblai-api';
|
|
14
14
|
import '@reduxjs/toolkit/query';
|
|
15
15
|
import * as DialogPrimitive from '@radix-ui/react-dialog';
|
|
@@ -72973,12 +72973,12 @@ const __iconNode$5J = [
|
|
|
72973
72973
|
["path", { d: "M16 5a4 3 0 0 0-8 0c0 4 8 3 8 7a4 3 0 0 1-8 0", key: "vqan6v" }],
|
|
72974
72974
|
["path", { d: "M8 19a4 3 0 0 0 8 0c0-4-8-3-8-7a4 3 0 0 1 8 0", key: "wdjd8o" }]
|
|
72975
72975
|
];
|
|
72976
|
-
const Section = createLucideIcon("section", __iconNode$5J);
|
|
72976
|
+
const Section$1 = createLucideIcon("section", __iconNode$5J);
|
|
72977
72977
|
|
|
72978
72978
|
var section = /*#__PURE__*/Object.freeze({
|
|
72979
72979
|
__proto__: null,
|
|
72980
72980
|
__iconNode: __iconNode$5J,
|
|
72981
|
-
default: Section
|
|
72981
|
+
default: Section$1
|
|
72982
72982
|
});
|
|
72983
72983
|
|
|
72984
72984
|
/**
|
|
@@ -119807,7 +119807,7 @@ function MemoryTab({ org, username }) {
|
|
|
119807
119807
|
const renderLucideIcon = (Icon) => function RenderedIcon(props) {
|
|
119808
119808
|
return jsx(Icon, { ...props });
|
|
119809
119809
|
};
|
|
119810
|
-
function Profile({ tenant, username, onClose, customization = {}, isAdmin = false, targetTab = 'basic', onAccountDeleted, enableMemoryTab = false, localLLMProps, }) {
|
|
119810
|
+
function Profile({ tenant, username, tenants, onClose, customization = {}, isAdmin = false, targetTab = 'basic', onAccountDeleted, enableMemoryTab = false, localLLMProps, }) {
|
|
119811
119811
|
var _a, _b, _c, _d;
|
|
119812
119812
|
console.log('[Profile] localLLMProps received:', {
|
|
119813
119813
|
isAvailable: localLLMProps === null || localLLMProps === void 0 ? void 0 : localLLMProps.isAvailable,
|
|
@@ -119826,13 +119826,17 @@ function Profile({ tenant, username, onClose, customization = {}, isAdmin = fals
|
|
|
119826
119826
|
});
|
|
119827
119827
|
// Show memory tab if enabled for this platform AND memsearch is enabled (or status API is unavailable)
|
|
119828
119828
|
const isMemoryEnabled = enableMemoryTab && (isMemsearchStatusError || ((_a = memsearchStatus === null || memsearchStatus === void 0 ? void 0 : memsearchStatus.enable_memsearch) !== null && _a !== void 0 ? _a : false));
|
|
119829
|
+
const currentTenant = tenants.find((t) => t.key === tenant);
|
|
119830
|
+
const isPurchasesEnabled = currentTenant === null || currentTenant === void 0 ? void 0 : currentTenant.show_paywall;
|
|
119829
119831
|
const baseTabs = [
|
|
119830
119832
|
{ id: 'basic', label: 'Basic', renderIcon: renderLucideIcon(User) },
|
|
119831
119833
|
{ id: 'social', label: 'Social', renderIcon: renderLucideIcon(Globe) },
|
|
119832
119834
|
{ id: 'education', label: 'Education', renderIcon: renderLucideIcon(BookOpen) },
|
|
119833
119835
|
{ id: 'experience', label: 'Experience', renderIcon: renderLucideIcon(Briefcase) },
|
|
119834
119836
|
{ id: 'resume', label: 'Resume', renderIcon: renderLucideIcon(FileText) },
|
|
119835
|
-
|
|
119837
|
+
...(isPurchasesEnabled
|
|
119838
|
+
? [{ id: 'purchases', label: 'Purchases', renderIcon: renderLucideIcon(ShoppingBag) }]
|
|
119839
|
+
: []),
|
|
119836
119840
|
...(isMemoryEnabled
|
|
119837
119841
|
? [{ id: 'memory', label: 'Memory', renderIcon: renderLucideIcon(Archive) }]
|
|
119838
119842
|
: []),
|
|
@@ -160983,6 +160987,180 @@ AlertDialogAction.displayName = Action.displayName;
|
|
|
160983
160987
|
const AlertDialogCancel = React.forwardRef(({ className, ...props }, ref) => (jsx(Cancel, { ref: ref, className: cn(buttonVariants({ variant: 'outline' }), 'mt-2 sm:mt-0', className), ...props })));
|
|
160984
160988
|
AlertDialogCancel.displayName = Cancel.displayName;
|
|
160985
160989
|
|
|
160990
|
+
const AUTO_RECHARGE_DEFAULTS = {
|
|
160991
|
+
THRESHOLD_USD: '5',
|
|
160992
|
+
AMOUNT_USD: '16',
|
|
160993
|
+
};
|
|
160994
|
+
function isEmptyOrZeroAmount(value) {
|
|
160995
|
+
if (!value)
|
|
160996
|
+
return true;
|
|
160997
|
+
const num = parseFloat(value);
|
|
160998
|
+
return isNaN(num) || num === 0;
|
|
160999
|
+
}
|
|
161000
|
+
|
|
161001
|
+
function formatCurrencyInput(value) {
|
|
161002
|
+
if (value === null || value === undefined || value === '')
|
|
161003
|
+
return '';
|
|
161004
|
+
const num = typeof value === 'string' ? parseFloat(value) : value;
|
|
161005
|
+
if (isNaN(num))
|
|
161006
|
+
return '';
|
|
161007
|
+
return num.toString();
|
|
161008
|
+
}
|
|
161009
|
+
function AutoRechargeModal({ isOpen, onClose, tenant }) {
|
|
161010
|
+
const { data: autoRechargeInfo, isLoading, refetch, } = useGetAccountBillingInfoQuery({ platform_key: tenant });
|
|
161011
|
+
const [updateAutoRecharge, { isLoading: isUpdating }] = useUpdateAutoRechargeInfoMutation();
|
|
161012
|
+
const [threshold, setThreshold] = useState('');
|
|
161013
|
+
const [amount, setAmount] = useState('');
|
|
161014
|
+
const [spendingLimit, setSpendingLimit] = useState('');
|
|
161015
|
+
const [isUnlimited, setIsUnlimited] = useState(false);
|
|
161016
|
+
const [isEnabled, setIsEnabled] = useState(false);
|
|
161017
|
+
// Sync form state with fetched data
|
|
161018
|
+
useEffect(() => {
|
|
161019
|
+
if (autoRechargeInfo) {
|
|
161020
|
+
setThreshold(formatCurrencyInput(autoRechargeInfo.auto_recharge_threshold_usd));
|
|
161021
|
+
setAmount(formatCurrencyInput(autoRechargeInfo.auto_recharge_amount_usd));
|
|
161022
|
+
const limitValue = parseFloat(autoRechargeInfo.auto_recharge_spending_limit_usd || '0');
|
|
161023
|
+
const unlimited = limitValue === 0;
|
|
161024
|
+
setIsUnlimited(unlimited);
|
|
161025
|
+
setSpendingLimit(unlimited ? '' : formatCurrencyInput(autoRechargeInfo.auto_recharge_spending_limit_usd));
|
|
161026
|
+
setIsEnabled(autoRechargeInfo.auto_recharge_enabled || false);
|
|
161027
|
+
}
|
|
161028
|
+
}, [autoRechargeInfo]);
|
|
161029
|
+
const handleEnableToggle = async (checked) => {
|
|
161030
|
+
setIsEnabled(checked);
|
|
161031
|
+
if (!checked)
|
|
161032
|
+
return;
|
|
161033
|
+
let nextThreshold = threshold;
|
|
161034
|
+
let nextAmount = amount;
|
|
161035
|
+
if (isEmptyOrZeroAmount(threshold)) {
|
|
161036
|
+
nextThreshold = AUTO_RECHARGE_DEFAULTS.THRESHOLD_USD;
|
|
161037
|
+
setThreshold(nextThreshold);
|
|
161038
|
+
}
|
|
161039
|
+
if (isEmptyOrZeroAmount(amount)) {
|
|
161040
|
+
nextAmount = AUTO_RECHARGE_DEFAULTS.AMOUNT_USD;
|
|
161041
|
+
setAmount(nextAmount);
|
|
161042
|
+
}
|
|
161043
|
+
try {
|
|
161044
|
+
await updateAutoRecharge({
|
|
161045
|
+
auto_recharge_threshold_usd: nextThreshold || '0',
|
|
161046
|
+
auto_recharge_amount_usd: nextAmount || '0',
|
|
161047
|
+
auto_recharge_spending_limit_usd: isUnlimited ? '0' : spendingLimit || '0',
|
|
161048
|
+
auto_recharge_enabled: true,
|
|
161049
|
+
platform_key: tenant,
|
|
161050
|
+
}).unwrap();
|
|
161051
|
+
refetch();
|
|
161052
|
+
}
|
|
161053
|
+
catch (_a) {
|
|
161054
|
+
toast.error('Failed to enable auto recharge');
|
|
161055
|
+
}
|
|
161056
|
+
};
|
|
161057
|
+
const handleSubmit = async (e) => {
|
|
161058
|
+
e.preventDefault();
|
|
161059
|
+
if (!threshold || !amount || (!isUnlimited && !spendingLimit)) {
|
|
161060
|
+
toast.error('Please fill in all fields');
|
|
161061
|
+
return;
|
|
161062
|
+
}
|
|
161063
|
+
const thresholdNum = parseFloat(threshold);
|
|
161064
|
+
const amountNum = parseFloat(amount);
|
|
161065
|
+
const spendingLimitNum = isUnlimited ? 0 : parseFloat(spendingLimit);
|
|
161066
|
+
if (isNaN(thresholdNum) || thresholdNum < 0) {
|
|
161067
|
+
toast.error('Please enter a valid threshold amount');
|
|
161068
|
+
return;
|
|
161069
|
+
}
|
|
161070
|
+
if (isNaN(amountNum) || amountNum <= 0) {
|
|
161071
|
+
toast.error('Please enter a valid recharge amount greater than 0');
|
|
161072
|
+
return;
|
|
161073
|
+
}
|
|
161074
|
+
if (!isUnlimited && (isNaN(spendingLimitNum) || spendingLimitNum < 0)) {
|
|
161075
|
+
toast.error('Please enter a valid spending limit');
|
|
161076
|
+
return;
|
|
161077
|
+
}
|
|
161078
|
+
try {
|
|
161079
|
+
await updateAutoRecharge({
|
|
161080
|
+
auto_recharge_threshold_usd: threshold,
|
|
161081
|
+
auto_recharge_amount_usd: amount,
|
|
161082
|
+
auto_recharge_spending_limit_usd: isUnlimited ? '0' : spendingLimit,
|
|
161083
|
+
auto_recharge_enabled: isEnabled,
|
|
161084
|
+
platform_key: tenant,
|
|
161085
|
+
}).unwrap();
|
|
161086
|
+
toast.success('Usage settings updated successfully');
|
|
161087
|
+
refetch();
|
|
161088
|
+
onClose();
|
|
161089
|
+
}
|
|
161090
|
+
catch (error) {
|
|
161091
|
+
toast.error('Failed to update usage settings');
|
|
161092
|
+
}
|
|
161093
|
+
};
|
|
161094
|
+
const handleClose = () => {
|
|
161095
|
+
// Reset form to original values on close
|
|
161096
|
+
if (autoRechargeInfo) {
|
|
161097
|
+
setThreshold(formatCurrencyInput(autoRechargeInfo.auto_recharge_threshold_usd));
|
|
161098
|
+
setAmount(formatCurrencyInput(autoRechargeInfo.auto_recharge_amount_usd));
|
|
161099
|
+
const limitValue = parseFloat(autoRechargeInfo.auto_recharge_spending_limit_usd || '0');
|
|
161100
|
+
const unlimited = limitValue === 0;
|
|
161101
|
+
setIsUnlimited(unlimited);
|
|
161102
|
+
setSpendingLimit(unlimited ? '' : formatCurrencyInput(autoRechargeInfo.auto_recharge_spending_limit_usd));
|
|
161103
|
+
setIsEnabled(autoRechargeInfo.auto_recharge_enabled || false);
|
|
161104
|
+
}
|
|
161105
|
+
onClose();
|
|
161106
|
+
};
|
|
161107
|
+
const formatLastTriggered = (dateString, includeTime = true) => {
|
|
161108
|
+
if (!dateString)
|
|
161109
|
+
return 'Never';
|
|
161110
|
+
const date = new Date(dateString);
|
|
161111
|
+
const options = {
|
|
161112
|
+
month: 'short',
|
|
161113
|
+
day: 'numeric',
|
|
161114
|
+
year: 'numeric',
|
|
161115
|
+
};
|
|
161116
|
+
if (includeTime) {
|
|
161117
|
+
options.hour = '2-digit';
|
|
161118
|
+
options.minute = '2-digit';
|
|
161119
|
+
}
|
|
161120
|
+
return date.toLocaleDateString('en-US', options);
|
|
161121
|
+
};
|
|
161122
|
+
return (jsx(Dialog, { open: isOpen, onOpenChange: handleClose, children: jsxs(DialogContent, { className: "max-w-md", children: [jsxs(DialogHeader, { children: [jsx(DialogTitle, { children: "Manage Usage" }), jsx(DialogDescription, { children: "Configure automatic recharge and spending limits." })] }), isLoading ? (jsx("div", { className: "flex items-center justify-center py-8", children: jsx(LoaderCircle, { className: "h-8 w-8 animate-spin text-primary" }) })) : (jsxs("form", { onSubmit: handleSubmit, className: "space-y-6", children: [jsxs("div", { className: "bg-slate-50 dark:bg-slate-800/50 rounded-lg p-4 border border-slate-200 dark:border-slate-700", children: [(parseFloat((autoRechargeInfo === null || autoRechargeInfo === void 0 ? void 0 : autoRechargeInfo.auto_recharge_total_charged_usd) || '0') > 0 ||
|
|
161123
|
+
(autoRechargeInfo === null || autoRechargeInfo === void 0 ? void 0 : autoRechargeInfo.auto_recharge_period_ends_at)) && (jsxs("div", { className: "flex items-center justify-between gap-4 mb-4 pb-4 border-b border-slate-200 dark:border-slate-700", children: [parseFloat((autoRechargeInfo === null || autoRechargeInfo === void 0 ? void 0 : autoRechargeInfo.auto_recharge_total_charged_usd) || '0') > 0 && (jsxs("div", { className: "flex-1", children: [jsx("p", { className: "text-xs text-slate-500 dark:text-slate-400 mb-1", children: "Total Spent" }), jsxs("div", { className: "inline-flex items-center gap-1 px-2.5 py-1 bg-blue-100 dark:bg-blue-900/40 text-blue-700 dark:text-blue-300 rounded-full text-sm font-medium", children: [jsx(DollarSign, { className: "h-3.5 w-3.5" }), formatCurrencyInput(autoRechargeInfo === null || autoRechargeInfo === void 0 ? void 0 : autoRechargeInfo.auto_recharge_total_charged_usd)] })] })), (autoRechargeInfo === null || autoRechargeInfo === void 0 ? void 0 : autoRechargeInfo.auto_recharge_period_ends_at) && (jsxs("div", { className: "flex-1 text-right", children: [jsx("p", { className: "text-xs text-slate-500 dark:text-slate-400 mb-1", children: "Resets On" }), jsxs("div", { className: "inline-flex items-center gap-1 text-sm text-slate-700 dark:text-slate-300", children: [jsx(Calendar$1, { className: "h-3.5 w-3.5" }), formatLastTriggered(autoRechargeInfo.auto_recharge_period_ends_at, false)] })] }))] })), jsxs("div", { className: "flex items-center justify-between", children: [jsxs("div", { className: "space-y-1", children: [jsx(Label, { htmlFor: "auto-recharge-toggle", className: "text-sm font-medium text-slate-700 dark:text-slate-300", children: "Enable Auto Recharge" }), jsx("p", { className: "text-xs text-slate-500 dark:text-slate-400", children: "Automatically top up credits when balance is low" })] }), jsx(Switch, { id: "auto-recharge-toggle", checked: isEnabled, onCheckedChange: handleEnableToggle, className: "data-[state=checked]:bg-blue-500" })] }), (autoRechargeInfo === null || autoRechargeInfo === void 0 ? void 0 : autoRechargeInfo.auto_recharge_last_triggered_at) && (jsxs("div", { className: "text-xs text-slate-500 dark:text-slate-400 mt-3 pt-3 border-t border-slate-200 dark:border-slate-700", children: [jsx("span", { children: "Last triggered: " }), jsx("span", { className: "font-medium", children: formatLastTriggered(autoRechargeInfo === null || autoRechargeInfo === void 0 ? void 0 : autoRechargeInfo.auto_recharge_last_triggered_at) })] }))] }), isEnabled && (jsxs(Fragment$1, { children: [jsxs("div", { className: "space-y-2", children: [jsxs("div", { className: "flex items-center justify-between", children: [jsx(Label, { htmlFor: "spending-limit", className: "text-sm font-medium", children: "Spending Limit" }), jsxs("div", { className: "flex items-center gap-2", children: [jsx(Switch, { id: "unlimited-toggle", checked: isUnlimited, onCheckedChange: (checked) => {
|
|
161124
|
+
setIsUnlimited(checked);
|
|
161125
|
+
if (checked)
|
|
161126
|
+
setSpendingLimit('');
|
|
161127
|
+
}, className: "data-[state=checked]:bg-blue-500 scale-75" }), jsx(Label, { htmlFor: "unlimited-toggle", className: "text-xs text-slate-500 dark:text-slate-400 cursor-pointer", children: "Unlimited" })] })] }), jsxs("div", { className: "relative", children: [jsx(DollarSign, { className: "absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-slate-400" }), jsx(Input, { id: "spending-limit", type: "number", min: "0.01", step: "0.01", placeholder: isUnlimited ? 'Unlimited' : '100.00', value: spendingLimit, onChange: (e) => setSpendingLimit(e.target.value), disabled: isUnlimited, className: "pl-9" })] }), jsx("p", { className: "text-xs text-slate-500 dark:text-slate-400", children: "Maximum amount that can be auto-charged per billing period" })] }), jsxs("div", { className: "space-y-2", children: [jsx(Label, { htmlFor: "amount", className: "text-sm font-medium", children: "Recharge Amount" }), jsxs("div", { className: "relative", children: [jsx(DollarSign, { className: "absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-slate-400" }), jsx(Input, { id: "amount", type: "number", min: "0.01", step: "0.01", placeholder: "50.00", value: amount, onChange: (e) => setAmount(e.target.value), className: "pl-9" })] }), jsx("p", { className: "text-xs text-slate-500 dark:text-slate-400", children: "Amount to add to your balance when auto recharge triggers" })] }), jsxs("div", { className: "space-y-2", children: [jsx(Label, { htmlFor: "threshold", className: "text-sm font-medium", children: "Recharge Threshold" }), jsxs("div", { className: "relative", children: [jsx(DollarSign, { className: "absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-slate-400" }), jsx(Input, { id: "threshold", type: "number", min: "0", step: "0.01", placeholder: "10.00", value: threshold, onChange: (e) => setThreshold(e.target.value), className: "pl-9" })] }), jsx("p", { className: "text-xs text-slate-500 dark:text-slate-400", children: "Auto recharge will trigger when your balance falls below this amount" })] })] })), jsxs("div", { className: "flex items-start gap-2 p-3 bg-blue-50 dark:bg-blue-900/20 rounded-lg border border-blue-100 dark:border-blue-800", children: [jsx(CircleAlert, { className: "h-4 w-4 text-blue-500 mt-0.5 flex-shrink-0" }), jsx("p", { className: "text-xs text-blue-700 dark:text-blue-300", children: "Your payment method on file will be charged automatically when your credit balance drops below the threshold." })] }), jsxs(DialogFooter, { className: "gap-2 sm:gap-0", children: [jsx(Button$1, { type: "button", variant: "outline", onClick: handleClose, children: "Cancel" }), jsx(Button$1, { type: "submit", disabled: isUpdating, className: "bg-gradient-to-r from-[#2563EB] to-[#93C5FD] hover:opacity-90 text-white", children: isUpdating ? (jsxs(Fragment$1, { children: [jsx(LoaderCircle, { className: "mr-2 h-4 w-4 animate-spin" }), "Saving..."] })) : ('Save Settings') })] })] }))] }) }));
|
|
161128
|
+
}
|
|
161129
|
+
|
|
161130
|
+
function AddCreditsModal({ isOpen, onClose, tenant }) {
|
|
161131
|
+
const [triggerAutoRecharge, { isLoading }] = useTriggerAutoRechargeMutation();
|
|
161132
|
+
const [amount, setAmount] = useState('');
|
|
161133
|
+
const handleSubmit = async (e) => {
|
|
161134
|
+
e.preventDefault();
|
|
161135
|
+
if (!amount) {
|
|
161136
|
+
toast.error('Please enter an amount');
|
|
161137
|
+
return;
|
|
161138
|
+
}
|
|
161139
|
+
const amountNum = parseFloat(amount);
|
|
161140
|
+
if (isNaN(amountNum) || amountNum <= 0) {
|
|
161141
|
+
toast.error('Please enter a valid amount greater than 0');
|
|
161142
|
+
return;
|
|
161143
|
+
}
|
|
161144
|
+
try {
|
|
161145
|
+
await triggerAutoRecharge({
|
|
161146
|
+
amount_usd: amount,
|
|
161147
|
+
platform_key: tenant,
|
|
161148
|
+
}).unwrap();
|
|
161149
|
+
toast.success('Credits added successfully');
|
|
161150
|
+
setAmount('');
|
|
161151
|
+
onClose();
|
|
161152
|
+
}
|
|
161153
|
+
catch (error) {
|
|
161154
|
+
toast.error((error === null || error === void 0 ? void 0 : error.detail) || 'Failed to add credits');
|
|
161155
|
+
}
|
|
161156
|
+
};
|
|
161157
|
+
const handleClose = () => {
|
|
161158
|
+
setAmount('');
|
|
161159
|
+
onClose();
|
|
161160
|
+
};
|
|
161161
|
+
return (jsx(Dialog, { open: isOpen, onOpenChange: handleClose, children: jsxs(DialogContent, { className: "max-w-md", children: [jsxs(DialogHeader, { children: [jsx(DialogTitle, { children: "Add Credits" }), jsx(DialogDescription, { children: "Add credits to your account using your payment method on file." })] }), jsxs("form", { onSubmit: handleSubmit, className: "space-y-6", children: [jsxs("div", { className: "space-y-2", children: [jsx(Label, { htmlFor: "credit-amount", className: "text-sm font-medium", children: "Amount (USD)" }), jsxs("div", { className: "relative", children: [jsx(DollarSign, { className: "absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-slate-400" }), jsx(Input, { id: "credit-amount", type: "number", min: "0.01", step: "0.01", placeholder: "50.00", value: amount, onChange: (e) => setAmount(e.target.value), className: "pl-9" })] }), jsx("p", { className: "text-xs text-slate-500 dark:text-slate-400", children: "Enter the amount you want to add to your credit balance" })] }), jsxs("div", { className: "flex items-start gap-2 p-3 bg-blue-50 dark:bg-blue-900/20 rounded-lg border border-blue-100 dark:border-blue-800", children: [jsx(CircleAlert, { className: "h-4 w-4 text-blue-500 mt-0.5 flex-shrink-0" }), jsx("p", { className: "text-xs text-blue-700 dark:text-blue-300", children: "Your payment method on file will be charged for this amount." })] }), jsxs(DialogFooter, { className: "gap-2 sm:gap-0", children: [jsx(Button$1, { type: "button", variant: "outline", onClick: handleClose, children: "Cancel" }), jsx(Button$1, { type: "submit", disabled: isLoading, className: "bg-gradient-to-r from-[#2563EB] to-[#93C5FD] hover:opacity-90 text-white", children: isLoading ? (jsxs(Fragment$1, { children: [jsx(LoaderCircle, { className: "mr-2 h-4 w-4 animate-spin" }), "Processing..."] })) : ('Add Credits') })] })] })] }) }));
|
|
161162
|
+
}
|
|
161163
|
+
|
|
160986
161164
|
const AdvancedPagination = ({ currentPage, totalPages, onPageChange, siblingCount = 1, }) => {
|
|
160987
161165
|
const generateRange = () => {
|
|
160988
161166
|
const totalNumbers = siblingCount * 2 + 5;
|
|
@@ -163045,149 +163223,13 @@ function IntegrationsTab({ tenantKey, username, }) {
|
|
|
163045
163223
|
return (jsxs("div", { className: "container mx-auto max-w-7xl !mt-0", children: [jsxs(Tabs, { value: activeTab, onValueChange: setActiveTab, className: "w-full px-2 sm:px-0", children: [jsxs("div", { className: "flex flex-col gap-3 sm:flex-row sm:justify-between sm:items-center mb-6", children: [jsxs(TabsList, { className: "sm:grid sm:w-fit sm:grid-cols-3 h-auto sm:h-[35px] gap-2 sm:gap-0", children: [jsx(TabsTrigger, { value: "llms", className: activeTab === "llms" ? "w-full" : undefined, children: "LLMs" }), jsx(TabsTrigger, { value: "data-sources", className: activeTab === "data-sources" ? "w-full" : undefined, children: "Data Sources" }), jsx(TabsTrigger, { value: "generated", className: activeTab === "generated" ? "w-full" : undefined, children: "APIs" })] }), jsxs("div", { className: "flex gap-2 w-full sm:w-auto", children: [activeTab === "llms" && (jsxs(Button$1, { className: "bg-gradient-to-r from-[#2563EB] to-[#93C5FD] hover:opacity-90 text-white h-[35px] w-full sm:w-auto", onClick: openCreateLLMModal, children: [jsx(Plus, { className: "w-4 h-4 mr-2" }), "Add LLM"] })), activeTab === "data-sources" && (jsxs(Button$1, { className: "bg-gradient-to-r from-[#2563EB] to-[#93C5FD] hover:opacity-90 text-white h-[35px] w-full sm:w-auto", onClick: openCreateDataSourceModal, children: [jsx(Plus, { className: "w-4 h-4 mr-2" }), "Add Data Source"] })), activeTab === "generated" && (jsxs(Button$1, { className: "bg-gradient-to-r from-[#2563EB] to-[#93C5FD] hover:opacity-90 text-white h-[35px] w-full sm:w-auto", onClick: openCreateApiModal, children: [jsx(Plus, { className: "w-4 h-4 mr-2" }), "Add API"] }))] })] }), jsx(TabsContent, { value: "generated", className: "space-y-4", children: jsx(IntegrationAutogeneratedTab, { tenantKey: tenantKey }) }), jsx(TabsContent, { value: "llms", className: "space-y-4", children: jsx(IntegrationLLMsTab, { tenantKey: tenantKey }) }), jsx(TabsContent, { value: "data-sources", className: "space-y-4", children: jsx(IntegrationDataSourcesTab, { tenantKey: tenantKey }) })] }), jsx(CreateApiModal$1, { isOpen: showCreateApiModal, onClose: closeCreateApiModal, tenantKey: tenantKey, username: username }), jsx(CreateLLMModal, { isOpen: showCreateLLMModal, onClose: closeCreateLLMModal, tenantKey: tenantKey }), jsx(CreateDataSourceModal, { isOpen: showCreateDataSourceModal, onClose: closeCreateDataSourceModal, tenantKey: tenantKey })] }));
|
|
163046
163224
|
}
|
|
163047
163225
|
|
|
163048
|
-
function formatCurrencyInput(value) {
|
|
163049
|
-
if (value === null || value === undefined || value === '')
|
|
163050
|
-
return '';
|
|
163051
|
-
const num = typeof value === 'string' ? parseFloat(value) : value;
|
|
163052
|
-
if (isNaN(num))
|
|
163053
|
-
return '';
|
|
163054
|
-
return num.toString();
|
|
163055
|
-
}
|
|
163056
|
-
function AutoRechargeModal({ isOpen, onClose, tenant }) {
|
|
163057
|
-
const { data: autoRechargeInfo, isLoading, refetch, } = useGetAccountBillingInfoQuery({ platform_key: tenant });
|
|
163058
|
-
const [updateAutoRecharge, { isLoading: isUpdating }] = useUpdateAutoRechargeInfoMutation();
|
|
163059
|
-
const [threshold, setThreshold] = useState('');
|
|
163060
|
-
const [amount, setAmount] = useState('');
|
|
163061
|
-
const [spendingLimit, setSpendingLimit] = useState('');
|
|
163062
|
-
const [isUnlimited, setIsUnlimited] = useState(false);
|
|
163063
|
-
const [isEnabled, setIsEnabled] = useState(false);
|
|
163064
|
-
// Sync form state with fetched data
|
|
163065
|
-
useEffect(() => {
|
|
163066
|
-
if (autoRechargeInfo) {
|
|
163067
|
-
setThreshold(formatCurrencyInput(autoRechargeInfo.auto_recharge_threshold_usd));
|
|
163068
|
-
setAmount(formatCurrencyInput(autoRechargeInfo.auto_recharge_amount_usd));
|
|
163069
|
-
const limitValue = parseFloat(autoRechargeInfo.auto_recharge_spending_limit_usd || '0');
|
|
163070
|
-
const unlimited = limitValue === 0;
|
|
163071
|
-
setIsUnlimited(unlimited);
|
|
163072
|
-
setSpendingLimit(unlimited ? '' : formatCurrencyInput(autoRechargeInfo.auto_recharge_spending_limit_usd));
|
|
163073
|
-
setIsEnabled(autoRechargeInfo.auto_recharge_enabled || false);
|
|
163074
|
-
}
|
|
163075
|
-
}, [autoRechargeInfo]);
|
|
163076
|
-
const handleSubmit = async (e) => {
|
|
163077
|
-
e.preventDefault();
|
|
163078
|
-
if (!threshold || !amount || (!isUnlimited && !spendingLimit)) {
|
|
163079
|
-
toast.error('Please fill in all fields');
|
|
163080
|
-
return;
|
|
163081
|
-
}
|
|
163082
|
-
const thresholdNum = parseFloat(threshold);
|
|
163083
|
-
const amountNum = parseFloat(amount);
|
|
163084
|
-
const spendingLimitNum = isUnlimited ? 0 : parseFloat(spendingLimit);
|
|
163085
|
-
if (isNaN(thresholdNum) || thresholdNum < 0) {
|
|
163086
|
-
toast.error('Please enter a valid threshold amount');
|
|
163087
|
-
return;
|
|
163088
|
-
}
|
|
163089
|
-
if (isNaN(amountNum) || amountNum <= 0) {
|
|
163090
|
-
toast.error('Please enter a valid recharge amount greater than 0');
|
|
163091
|
-
return;
|
|
163092
|
-
}
|
|
163093
|
-
if (!isUnlimited && (isNaN(spendingLimitNum) || spendingLimitNum < 0)) {
|
|
163094
|
-
toast.error('Please enter a valid spending limit');
|
|
163095
|
-
return;
|
|
163096
|
-
}
|
|
163097
|
-
try {
|
|
163098
|
-
await updateAutoRecharge({
|
|
163099
|
-
auto_recharge_threshold_usd: threshold,
|
|
163100
|
-
auto_recharge_amount_usd: amount,
|
|
163101
|
-
auto_recharge_spending_limit_usd: isUnlimited ? '0' : spendingLimit,
|
|
163102
|
-
auto_recharge_enabled: isEnabled,
|
|
163103
|
-
platform_key: tenant,
|
|
163104
|
-
}).unwrap();
|
|
163105
|
-
toast.success('Usage settings updated successfully');
|
|
163106
|
-
refetch();
|
|
163107
|
-
onClose();
|
|
163108
|
-
}
|
|
163109
|
-
catch (error) {
|
|
163110
|
-
toast.error('Failed to update usage settings');
|
|
163111
|
-
}
|
|
163112
|
-
};
|
|
163113
|
-
const handleClose = () => {
|
|
163114
|
-
// Reset form to original values on close
|
|
163115
|
-
if (autoRechargeInfo) {
|
|
163116
|
-
setThreshold(formatCurrencyInput(autoRechargeInfo.auto_recharge_threshold_usd));
|
|
163117
|
-
setAmount(formatCurrencyInput(autoRechargeInfo.auto_recharge_amount_usd));
|
|
163118
|
-
const limitValue = parseFloat(autoRechargeInfo.auto_recharge_spending_limit_usd || '0');
|
|
163119
|
-
const unlimited = limitValue === 0;
|
|
163120
|
-
setIsUnlimited(unlimited);
|
|
163121
|
-
setSpendingLimit(unlimited ? '' : formatCurrencyInput(autoRechargeInfo.auto_recharge_spending_limit_usd));
|
|
163122
|
-
setIsEnabled(autoRechargeInfo.auto_recharge_enabled || false);
|
|
163123
|
-
}
|
|
163124
|
-
onClose();
|
|
163125
|
-
};
|
|
163126
|
-
const formatLastTriggered = (dateString, includeTime = true) => {
|
|
163127
|
-
if (!dateString)
|
|
163128
|
-
return 'Never';
|
|
163129
|
-
const date = new Date(dateString);
|
|
163130
|
-
const options = {
|
|
163131
|
-
month: 'short',
|
|
163132
|
-
day: 'numeric',
|
|
163133
|
-
year: 'numeric',
|
|
163134
|
-
};
|
|
163135
|
-
if (includeTime) {
|
|
163136
|
-
options.hour = '2-digit';
|
|
163137
|
-
options.minute = '2-digit';
|
|
163138
|
-
}
|
|
163139
|
-
return date.toLocaleDateString('en-US', options);
|
|
163140
|
-
};
|
|
163141
|
-
return (jsx(Dialog, { open: isOpen, onOpenChange: handleClose, children: jsxs(DialogContent, { className: "max-w-md", children: [jsxs(DialogHeader, { children: [jsx(DialogTitle, { children: "Manage Usage" }), jsx(DialogDescription, { children: "Configure automatic recharge and spending limits." })] }), isLoading ? (jsx("div", { className: "flex items-center justify-center py-8", children: jsx(LoaderCircle, { className: "h-8 w-8 animate-spin text-primary" }) })) : (jsxs("form", { onSubmit: handleSubmit, className: "space-y-6", children: [jsxs("div", { className: "bg-slate-50 dark:bg-slate-800/50 rounded-lg p-4 border border-slate-200 dark:border-slate-700", children: [(parseFloat((autoRechargeInfo === null || autoRechargeInfo === void 0 ? void 0 : autoRechargeInfo.auto_recharge_total_charged_usd) || '0') > 0 ||
|
|
163142
|
-
(autoRechargeInfo === null || autoRechargeInfo === void 0 ? void 0 : autoRechargeInfo.auto_recharge_period_ends_at)) && (jsxs("div", { className: "flex items-center justify-between gap-4 mb-4 pb-4 border-b border-slate-200 dark:border-slate-700", children: [parseFloat((autoRechargeInfo === null || autoRechargeInfo === void 0 ? void 0 : autoRechargeInfo.auto_recharge_total_charged_usd) || '0') > 0 && (jsxs("div", { className: "flex-1", children: [jsx("p", { className: "text-xs text-slate-500 dark:text-slate-400 mb-1", children: "Total Spent" }), jsxs("div", { className: "inline-flex items-center gap-1 px-2.5 py-1 bg-blue-100 dark:bg-blue-900/40 text-blue-700 dark:text-blue-300 rounded-full text-sm font-medium", children: [jsx(DollarSign, { className: "h-3.5 w-3.5" }), formatCurrencyInput(autoRechargeInfo === null || autoRechargeInfo === void 0 ? void 0 : autoRechargeInfo.auto_recharge_total_charged_usd)] })] })), (autoRechargeInfo === null || autoRechargeInfo === void 0 ? void 0 : autoRechargeInfo.auto_recharge_period_ends_at) && (jsxs("div", { className: "flex-1 text-right", children: [jsx("p", { className: "text-xs text-slate-500 dark:text-slate-400 mb-1", children: "Resets On" }), jsxs("div", { className: "inline-flex items-center gap-1 text-sm text-slate-700 dark:text-slate-300", children: [jsx(Calendar$1, { className: "h-3.5 w-3.5" }), formatLastTriggered(autoRechargeInfo.auto_recharge_period_ends_at, false)] })] }))] })), jsxs("div", { className: "flex items-center justify-between", children: [jsxs("div", { className: "space-y-1", children: [jsx(Label, { htmlFor: "auto-recharge-toggle", className: "text-sm font-medium text-slate-700 dark:text-slate-300", children: "Enable Auto Recharge" }), jsx("p", { className: "text-xs text-slate-500 dark:text-slate-400", children: "Automatically top up credits when balance is low" })] }), jsx(Switch, { id: "auto-recharge-toggle", checked: isEnabled, onCheckedChange: setIsEnabled, className: "data-[state=checked]:bg-blue-500" })] }), (autoRechargeInfo === null || autoRechargeInfo === void 0 ? void 0 : autoRechargeInfo.auto_recharge_last_triggered_at) && (jsxs("div", { className: "text-xs text-slate-500 dark:text-slate-400 mt-3 pt-3 border-t border-slate-200 dark:border-slate-700", children: [jsx("span", { children: "Last triggered: " }), jsx("span", { className: "font-medium", children: formatLastTriggered(autoRechargeInfo === null || autoRechargeInfo === void 0 ? void 0 : autoRechargeInfo.auto_recharge_last_triggered_at) })] }))] }), isEnabled && (jsxs(Fragment$1, { children: [jsxs("div", { className: "space-y-2", children: [jsxs("div", { className: "flex items-center justify-between", children: [jsx(Label, { htmlFor: "spending-limit", className: "text-sm font-medium", children: "Spending Limit" }), jsxs("div", { className: "flex items-center gap-2", children: [jsx(Switch, { id: "unlimited-toggle", checked: isUnlimited, onCheckedChange: (checked) => {
|
|
163143
|
-
setIsUnlimited(checked);
|
|
163144
|
-
if (checked)
|
|
163145
|
-
setSpendingLimit('');
|
|
163146
|
-
}, className: "data-[state=checked]:bg-blue-500 scale-75" }), jsx(Label, { htmlFor: "unlimited-toggle", className: "text-xs text-slate-500 dark:text-slate-400 cursor-pointer", children: "Unlimited" })] })] }), jsxs("div", { className: "relative", children: [jsx(DollarSign, { className: "absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-slate-400" }), jsx(Input, { id: "spending-limit", type: "number", min: "0.01", step: "0.01", placeholder: isUnlimited ? 'Unlimited' : '100.00', value: spendingLimit, onChange: (e) => setSpendingLimit(e.target.value), disabled: isUnlimited, className: "pl-9" })] }), jsx("p", { className: "text-xs text-slate-500 dark:text-slate-400", children: "Maximum amount that can be auto-charged per billing period" })] }), jsxs("div", { className: "space-y-2", children: [jsx(Label, { htmlFor: "amount", className: "text-sm font-medium", children: "Recharge Amount" }), jsxs("div", { className: "relative", children: [jsx(DollarSign, { className: "absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-slate-400" }), jsx(Input, { id: "amount", type: "number", min: "0.01", step: "0.01", placeholder: "50.00", value: amount, onChange: (e) => setAmount(e.target.value), className: "pl-9" })] }), jsx("p", { className: "text-xs text-slate-500 dark:text-slate-400", children: "Amount to add to your balance when auto recharge triggers" })] }), jsxs("div", { className: "space-y-2", children: [jsx(Label, { htmlFor: "threshold", className: "text-sm font-medium", children: "Recharge Threshold" }), jsxs("div", { className: "relative", children: [jsx(DollarSign, { className: "absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-slate-400" }), jsx(Input, { id: "threshold", type: "number", min: "0", step: "0.01", placeholder: "10.00", value: threshold, onChange: (e) => setThreshold(e.target.value), className: "pl-9" })] }), jsx("p", { className: "text-xs text-slate-500 dark:text-slate-400", children: "Auto recharge will trigger when your balance falls below this amount" })] })] })), jsxs("div", { className: "flex items-start gap-2 p-3 bg-blue-50 dark:bg-blue-900/20 rounded-lg border border-blue-100 dark:border-blue-800", children: [jsx(CircleAlert, { className: "h-4 w-4 text-blue-500 mt-0.5 flex-shrink-0" }), jsx("p", { className: "text-xs text-blue-700 dark:text-blue-300", children: "Your payment method on file will be charged automatically when your credit balance drops below the threshold." })] }), jsxs(DialogFooter, { className: "gap-2 sm:gap-0", children: [jsx(Button$1, { type: "button", variant: "outline", onClick: handleClose, children: "Cancel" }), jsx(Button$1, { type: "submit", disabled: isUpdating, className: "bg-gradient-to-r from-[#2563EB] to-[#93C5FD] hover:opacity-90 text-white", children: isUpdating ? (jsxs(Fragment$1, { children: [jsx(LoaderCircle, { className: "mr-2 h-4 w-4 animate-spin" }), "Saving..."] })) : ('Save Settings') })] })] }))] }) }));
|
|
163147
|
-
}
|
|
163148
|
-
|
|
163149
|
-
function AddCreditsModal({ isOpen, onClose, tenant }) {
|
|
163150
|
-
const [triggerAutoRecharge, { isLoading }] = useTriggerAutoRechargeMutation();
|
|
163151
|
-
const [amount, setAmount] = useState('');
|
|
163152
|
-
const handleSubmit = async (e) => {
|
|
163153
|
-
e.preventDefault();
|
|
163154
|
-
if (!amount) {
|
|
163155
|
-
toast.error('Please enter an amount');
|
|
163156
|
-
return;
|
|
163157
|
-
}
|
|
163158
|
-
const amountNum = parseFloat(amount);
|
|
163159
|
-
if (isNaN(amountNum) || amountNum <= 0) {
|
|
163160
|
-
toast.error('Please enter a valid amount greater than 0');
|
|
163161
|
-
return;
|
|
163162
|
-
}
|
|
163163
|
-
try {
|
|
163164
|
-
await triggerAutoRecharge({
|
|
163165
|
-
amount_usd: amount,
|
|
163166
|
-
platform_key: tenant,
|
|
163167
|
-
}).unwrap();
|
|
163168
|
-
toast.success('Credits added successfully');
|
|
163169
|
-
setAmount('');
|
|
163170
|
-
onClose();
|
|
163171
|
-
}
|
|
163172
|
-
catch (error) {
|
|
163173
|
-
toast.error((error === null || error === void 0 ? void 0 : error.detail) || 'Failed to add credits');
|
|
163174
|
-
}
|
|
163175
|
-
};
|
|
163176
|
-
const handleClose = () => {
|
|
163177
|
-
setAmount('');
|
|
163178
|
-
onClose();
|
|
163179
|
-
};
|
|
163180
|
-
return (jsx(Dialog, { open: isOpen, onOpenChange: handleClose, children: jsxs(DialogContent, { className: "max-w-md", children: [jsxs(DialogHeader, { children: [jsx(DialogTitle, { children: "Add Credits" }), jsx(DialogDescription, { children: "Add credits to your account using your payment method on file." })] }), jsxs("form", { onSubmit: handleSubmit, className: "space-y-6", children: [jsxs("div", { className: "space-y-2", children: [jsx(Label, { htmlFor: "credit-amount", className: "text-sm font-medium", children: "Amount (USD)" }), jsxs("div", { className: "relative", children: [jsx(DollarSign, { className: "absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-slate-400" }), jsx(Input, { id: "credit-amount", type: "number", min: "0.01", step: "0.01", placeholder: "50.00", value: amount, onChange: (e) => setAmount(e.target.value), className: "pl-9" })] }), jsx("p", { className: "text-xs text-slate-500 dark:text-slate-400", children: "Enter the amount you want to add to your credit balance" })] }), jsxs("div", { className: "flex items-start gap-2 p-3 bg-blue-50 dark:bg-blue-900/20 rounded-lg border border-blue-100 dark:border-blue-800", children: [jsx(CircleAlert, { className: "h-4 w-4 text-blue-500 mt-0.5 flex-shrink-0" }), jsx("p", { className: "text-xs text-blue-700 dark:text-blue-300", children: "Your payment method on file will be charged for this amount." })] }), jsxs(DialogFooter, { className: "gap-2 sm:gap-0", children: [jsx(Button$1, { type: "button", variant: "outline", onClick: handleClose, children: "Cancel" }), jsx(Button$1, { type: "submit", disabled: isLoading, className: "bg-gradient-to-r from-[#2563EB] to-[#93C5FD] hover:opacity-90 text-white", children: isLoading ? (jsxs(Fragment$1, { children: [jsx(LoaderCircle, { className: "mr-2 h-4 w-4 animate-spin" }), "Processing..."] })) : ('Add Credits') })] })] })] }) }));
|
|
163181
|
-
}
|
|
163182
|
-
|
|
163183
163226
|
function formatCredits(credits) {
|
|
163184
163227
|
if (credits === null || credits === undefined || Number.isNaN(credits))
|
|
163185
163228
|
return '0';
|
|
163186
|
-
return credits.toLocaleString();
|
|
163229
|
+
return credits.toLocaleString('en-US');
|
|
163187
163230
|
}
|
|
163188
163231
|
function formatRenewalDate(dateString) {
|
|
163189
|
-
|
|
163190
|
-
return date.toLocaleDateString('en-US', {
|
|
163232
|
+
return new Date(dateString).toLocaleDateString('en-US', {
|
|
163191
163233
|
month: 'short',
|
|
163192
163234
|
day: 'numeric',
|
|
163193
163235
|
year: 'numeric',
|
|
@@ -163200,18 +163242,42 @@ function getDaysRemaining(dateString) {
|
|
|
163200
163242
|
const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24));
|
|
163201
163243
|
return Math.max(0, diffDays);
|
|
163202
163244
|
}
|
|
163203
|
-
function
|
|
163204
|
-
|
|
163245
|
+
function formatPlanLabel(plan) {
|
|
163246
|
+
if (plan === 'free_trial')
|
|
163247
|
+
return 'Trial';
|
|
163248
|
+
if (!plan || plan.toLowerCase().includes('free'))
|
|
163249
|
+
return 'Free';
|
|
163250
|
+
return 'Premium';
|
|
163251
|
+
}
|
|
163252
|
+
function formatUsd(value) {
|
|
163253
|
+
if (value === null || value === undefined || value === '')
|
|
163254
|
+
return '—';
|
|
163255
|
+
const num = typeof value === 'string' ? parseFloat(value) : value;
|
|
163256
|
+
if (isNaN(num))
|
|
163257
|
+
return '—';
|
|
163258
|
+
return `$${num.toFixed(2)}`;
|
|
163259
|
+
}
|
|
163260
|
+
function Section({ title, description, action, children, testId }) {
|
|
163261
|
+
return (jsxs("div", { "data-testid": testId, className: "rounded-lg border border-[#e5e5e5] bg-white shadow-[0_1px_2px_0_rgba(0,0,0,0.05)] dark:bg-zinc-900 dark:border-zinc-800", children: [jsxs("div", { className: "flex flex-col gap-2 p-4 sm:flex-row sm:items-start sm:justify-between", children: [jsxs("div", { className: "space-y-0.5", children: [jsx("h3", { className: "text-[16px] font-medium leading-6 text-[#101828] dark:text-gray-100", children: title }), description && (jsx("p", { className: "text-[13px] font-normal leading-5 text-[#4a5565] dark:text-gray-400", children: description }))] }), action && jsx("div", { className: "shrink-0", children: action })] }), children && (jsx("div", { className: "border-t border-[#e5e7eb] dark:border-zinc-800 px-4 py-3", children: children }))] }));
|
|
163262
|
+
}
|
|
163263
|
+
function Stat({ label, value, hint }) {
|
|
163264
|
+
return (jsxs("div", { className: "space-y-0.5", children: [jsx("p", { className: "text-[11px] font-medium uppercase tracking-wide text-[#6a7282] dark:text-gray-400", children: label }), jsx("p", { className: "text-[18px] font-semibold leading-6 text-[#101828] dark:text-gray-100", children: value }), hint && (jsx("p", { className: "text-[12px] font-normal leading-4 text-[#6a7282] dark:text-gray-500", children: hint }))] }));
|
|
163265
|
+
}
|
|
163266
|
+
function SectionSkeleton({ withBody = false }) {
|
|
163267
|
+
return (jsxs("div", { className: "rounded-lg border border-[#e5e5e5] bg-white shadow-[0_1px_2px_0_rgba(0,0,0,0.05)] dark:bg-zinc-900 dark:border-zinc-800", children: [jsxs("div", { className: "flex flex-col gap-2 p-4 sm:flex-row sm:items-start sm:justify-between", children: [jsxs("div", { className: "space-y-2", children: [jsx(Skeleton, { className: "h-5 w-32" }), jsx(Skeleton, { className: "h-4 w-56" })] }), jsx(Skeleton, { className: "h-9 w-32" })] }), withBody && (jsx("div", { className: "border-t border-[#e5e7eb] dark:border-zinc-800 px-4 py-3", children: jsx("div", { className: "grid grid-cols-1 gap-4 sm:grid-cols-3", children: [0, 1, 2].map((i) => (jsxs("div", { className: "space-y-2", children: [jsx(Skeleton, { className: "h-3 w-20" }), jsx(Skeleton, { className: "h-6 w-24" })] }, i))) }) }))] }));
|
|
163268
|
+
}
|
|
163269
|
+
function BillingTab({ tenant, userActiveApp = null, username, mainPlatformKey, currentUserEmail, redirectUrl, }) {
|
|
163270
|
+
var _a;
|
|
163205
163271
|
const [isAutoRechargeModalOpen, setIsAutoRechargeModalOpen] = useState(false);
|
|
163206
163272
|
const [isAddCreditsModalOpen, setIsAddCreditsModalOpen] = useState(false);
|
|
163207
163273
|
const [isRedirectingToPaymentSettings, setIsRedirectingToPaymentSettings] = useState(false);
|
|
163208
|
-
const
|
|
163209
|
-
|
|
163210
|
-
|
|
163211
|
-
|
|
163212
|
-
|
|
163213
|
-
refetchOnMountOrArgChange: true,
|
|
163274
|
+
const { isLoading: isUpgrading, handleUpgrade } = useStripeUpgrade({
|
|
163275
|
+
redirectUrl: redirectUrl !== null && redirectUrl !== void 0 ? redirectUrl : (typeof window !== 'undefined' ? window.location.href : ''),
|
|
163276
|
+
sourcePlatformKey: tenant,
|
|
163277
|
+
mainPlatformKey,
|
|
163278
|
+
currentUserEmail,
|
|
163214
163279
|
});
|
|
163280
|
+
const { data: billingInfo, isLoading: isBillingInfoLoading } = useGetAccountBillingInfoQuery({ platform_key: tenant }, { refetchOnMountOrArgChange: true });
|
|
163215
163281
|
const [createStripePortal] = useCreateStripeCustomerPortalMutation();
|
|
163216
163282
|
const handleBilling = async ({ extraRequestBody = {}, }) => {
|
|
163217
163283
|
return await createStripePortal({
|
|
@@ -163224,24 +163290,6 @@ function BillingTab({ topUpURL, tenant, userActiveApp = null, username, onUpgrad
|
|
|
163224
163290
|
},
|
|
163225
163291
|
}).unwrap();
|
|
163226
163292
|
};
|
|
163227
|
-
const handleManageSubscription = async () => {
|
|
163228
|
-
setIsRedirectingToBilling(true);
|
|
163229
|
-
try {
|
|
163230
|
-
const result = await handleBilling({});
|
|
163231
|
-
if (result === null || result === void 0 ? void 0 : result.url) {
|
|
163232
|
-
// Keep loading state - page will navigate away
|
|
163233
|
-
window.location.href = result.url;
|
|
163234
|
-
}
|
|
163235
|
-
else {
|
|
163236
|
-
setIsRedirectingToBilling(false);
|
|
163237
|
-
toast.error('Failed to open billing page');
|
|
163238
|
-
}
|
|
163239
|
-
}
|
|
163240
|
-
catch (_a) {
|
|
163241
|
-
setIsRedirectingToBilling(false);
|
|
163242
|
-
toast.error('Failed to open billing page');
|
|
163243
|
-
}
|
|
163244
|
-
};
|
|
163245
163293
|
const handleSetupPaymentMethod = async () => {
|
|
163246
163294
|
setIsRedirectingToPaymentSettings(true);
|
|
163247
163295
|
try {
|
|
@@ -163252,7 +163300,6 @@ function BillingTab({ topUpURL, tenant, userActiveApp = null, username, onUpgrad
|
|
|
163252
163300
|
},
|
|
163253
163301
|
});
|
|
163254
163302
|
if (result === null || result === void 0 ? void 0 : result.url) {
|
|
163255
|
-
// Keep loading state - page will navigate away
|
|
163256
163303
|
window.location.href = result.url;
|
|
163257
163304
|
}
|
|
163258
163305
|
else {
|
|
@@ -163265,20 +163312,47 @@ function BillingTab({ topUpURL, tenant, userActiveApp = null, username, onUpgrad
|
|
|
163265
163312
|
toast.error('Failed to open payment settings');
|
|
163266
163313
|
}
|
|
163267
163314
|
};
|
|
163268
|
-
const availableCredits = (_a = Number(billingInfo === null || billingInfo === void 0 ? void 0 : billingInfo.available_credits)) !== null && _a !== void 0 ? _a : 0;
|
|
163269
|
-
const canSeeUpgradeButton = !((_b = userActiveApp === null || userActiveApp === void 0 ? void 0 : userActiveApp.subscription) === null || _b === void 0 ? void 0 : _b.active) ||
|
|
163270
|
-
((billingInfo === null || billingInfo === void 0 ? void 0 : billingInfo.current_plan) &&
|
|
163271
|
-
((_c = billingInfo === null || billingInfo === void 0 ? void 0 : billingInfo.pricing_table) === null || _c === void 0 ? void 0 : _c.pricing_table_id) &&
|
|
163272
|
-
!billingInfo.current_plan.toLowerCase().includes('pro'));
|
|
163273
|
-
const onFreePlan = !((_d = userActiveApp === null || userActiveApp === void 0 ? void 0 : userActiveApp.subscription) === null || _d === void 0 ? void 0 : _d.active) ||
|
|
163274
|
-
((_f = (_e = userActiveApp === null || userActiveApp === void 0 ? void 0 : userActiveApp.subscription) === null || _e === void 0 ? void 0 : _e.product_sku) === null || _f === void 0 ? void 0 : _f.includes('free'));
|
|
163275
163315
|
if (isBillingInfoLoading) {
|
|
163276
|
-
return (jsx("div", { className: "container
|
|
163277
|
-
}
|
|
163278
|
-
|
|
163279
|
-
|
|
163280
|
-
|
|
163281
|
-
|
|
163316
|
+
return (jsx("div", { className: "container max-w-3xl !mt-0", children: jsxs("div", { className: "space-y-4", children: [jsx(SectionSkeleton, {}), jsx(SectionSkeleton, { withBody: true }), jsx(SectionSkeleton, { withBody: true })] }) }));
|
|
163317
|
+
}
|
|
163318
|
+
const billing = billingInfo;
|
|
163319
|
+
const isFreePlan = formatPlanLabel(billing === null || billing === void 0 ? void 0 : billing.current_plan) === 'Free' ||
|
|
163320
|
+
(Boolean(billing === null || billing === void 0 ? void 0 : billing.free_trial) && (billing === null || billing === void 0 ? void 0 : billing.platform_key) !== mainPlatformKey);
|
|
163321
|
+
const isTrialPlan = Boolean(billing === null || billing === void 0 ? void 0 : billing.free_trial) && (billing === null || billing === void 0 ? void 0 : billing.platform_key) === mainPlatformKey;
|
|
163322
|
+
const planLabel = isFreePlan
|
|
163323
|
+
? 'Free'
|
|
163324
|
+
: isTrialPlan
|
|
163325
|
+
? 'Trial'
|
|
163326
|
+
: 'Premium';
|
|
163327
|
+
const availableCredits = (_a = Number(billing === null || billing === void 0 ? void 0 : billing.available_credits)) !== null && _a !== void 0 ? _a : 0;
|
|
163328
|
+
const consumedCredits = (billing === null || billing === void 0 ? void 0 : billing.consumed_credits) != null ? parseInt(billing.consumed_credits, 10) : null;
|
|
163329
|
+
const hasPaymentMethod = Boolean(billing === null || billing === void 0 ? void 0 : billing.has_payment_method);
|
|
163330
|
+
const isAutoRechargeEnabled = Boolean(billing === null || billing === void 0 ? void 0 : billing.auto_recharge_enabled);
|
|
163331
|
+
const spendingLimitRaw = billing === null || billing === void 0 ? void 0 : billing.auto_recharge_spending_limit_usd;
|
|
163332
|
+
const isUnlimitedSpendingLimit = !spendingLimitRaw || parseFloat(spendingLimitRaw || '0') === 0;
|
|
163333
|
+
const subscription = userActiveApp === null || userActiveApp === void 0 ? void 0 : userActiveApp.subscription;
|
|
163334
|
+
const onActiveSubscription = Boolean((subscription === null || subscription === void 0 ? void 0 : subscription.active) && (subscription === null || subscription === void 0 ? void 0 : subscription.subscription_ends) && (subscription === null || subscription === void 0 ? void 0 : subscription.subscription_starts));
|
|
163335
|
+
const planDescription = (() => {
|
|
163336
|
+
if (planLabel === 'Trial' && (subscription === null || subscription === void 0 ? void 0 : subscription.subscription_ends)) {
|
|
163337
|
+
return `Trial ends on ${formatRenewalDate(subscription.subscription_ends)} · ${getDaysRemaining(subscription.subscription_ends)} days remaining`;
|
|
163338
|
+
}
|
|
163339
|
+
if (planLabel === 'Premium' && onActiveSubscription && (subscription === null || subscription === void 0 ? void 0 : subscription.subscription_ends)) {
|
|
163340
|
+
return `Renews on ${formatRenewalDate(subscription.subscription_ends)}`;
|
|
163341
|
+
}
|
|
163342
|
+
if (planLabel === 'Free') {
|
|
163343
|
+
return 'You are on the Free plan';
|
|
163344
|
+
}
|
|
163345
|
+
return 'Manage your subscription and billing details';
|
|
163346
|
+
})();
|
|
163347
|
+
return (jsxs("div", { className: "container mx-auto max-w-3xl !mt-0", children: [jsxs("div", { className: "space-y-4", children: [jsx(Section, { title: "Plan", testId: "billing-plan-section", description: planDescription, action: isFreePlan || isTrialPlan ? (jsxs(Button$1, { onClick: () => handleUpgrade('premium'), disabled: isUpgrading, className: "h-9 px-4 text-[14px] font-medium text-white bg-gradient-to-r from-[rgb(56,161,229)] to-[rgb(114,132,255)] hover:opacity-90 disabled:opacity-70", children: [isUpgrading ? (jsx(LoaderCircle, { className: "h-4 w-4 animate-spin" })) : (jsx(Sparkles, { className: "h-4 w-4" })), isUpgrading ? 'Redirecting...' : 'Upgrade'] })) : undefined, children: jsxs("div", { className: "flex items-center gap-2", children: [jsx("span", { "data-testid": "billing-plan-label", className: "text-[18px] font-semibold leading-7 text-[#101828] dark:text-gray-100", children: planLabel }), jsx("span", { className: "rounded-full px-2.5 py-0.5 text-[12px] font-medium", style: {
|
|
163348
|
+
backgroundColor: '#f5f8ff',
|
|
163349
|
+
color: '#155dfc',
|
|
163350
|
+
border: '1px solid #d0e0ff',
|
|
163351
|
+
}, children: "Current" })] }) }), jsx(Section, { title: "Credits", testId: "billing-credits-section", description: "Track your available credits and usage.", action: isFreePlan || isTrialPlan ? undefined : hasPaymentMethod ? (jsx(Button$1, { variant: "outline", onClick: () => setIsAddCreditsModalOpen(true), className: "h-9 px-4 text-[14px] font-medium", children: "Add Credits" })) : (jsxs(Button$1, { onClick: handleSetupPaymentMethod, disabled: isRedirectingToPaymentSettings, className: "h-9 px-4 text-[14px] font-medium bg-gradient-to-r from-[#2563EB] to-[#93C5FD] hover:opacity-90 text-white", children: [isRedirectingToPaymentSettings ? (jsx(LoaderCircle, { className: "h-4 w-4 animate-spin" })) : (jsx(Wallet, { className: "h-4 w-4" })), isRedirectingToPaymentSettings ? 'Redirecting...' : 'Manage Billing'] })), children: jsxs("div", { className: "grid grid-cols-1 gap-4 sm:grid-cols-3", children: [jsx(Stat, { label: "Available", value: `${formatCredits(availableCredits)} Credits`, hint: "Credits remaining" }), consumedCredits != null && (jsx(Stat, { label: "Consumed", value: `${formatCredits(consumedCredits)} Credits`, hint: "Used this period" })), (billing === null || billing === void 0 ? void 0 : billing.credits_reset_date) && (jsx(Stat, { label: "Resets on", value: formatRenewalDate(billing.credits_reset_date), hint: "Next reset date" }))] }) }), !isFreePlan && !isTrialPlan && hasPaymentMethod && (jsx(Section, { title: "Auto Recharge", testId: "billing-auto-recharge-section", description: "Top up your balance automatically when credits run low.", action: jsxs("div", { className: "flex items-center gap-3", children: [jsx("span", { "data-testid": "billing-auto-recharge-status", className: "rounded-full px-2.5 py-0.5 text-[12px] font-medium", style: {
|
|
163352
|
+
backgroundColor: isAutoRechargeEnabled ? '#f5f8ff' : '#f3f4f6',
|
|
163353
|
+
color: isAutoRechargeEnabled ? '#155dfc' : '#6a7282',
|
|
163354
|
+
border: `1px solid ${isAutoRechargeEnabled ? '#d0e0ff' : '#e5e7eb'}`,
|
|
163355
|
+
}, children: isAutoRechargeEnabled ? 'Enabled' : 'Disabled' }), jsx(Button$1, { variant: "outline", onClick: () => setIsAutoRechargeModalOpen(true), className: "h-9 px-4 text-[14px] font-medium", children: "Manage Usage" })] }), children: isAutoRechargeEnabled ? (jsxs("div", { className: "grid grid-cols-1 gap-4 sm:grid-cols-3", children: [jsx(Stat, { label: "Threshold", value: formatUsd(billing === null || billing === void 0 ? void 0 : billing.auto_recharge_threshold_usd) }), jsx(Stat, { label: "Recharge amount", value: formatUsd(billing === null || billing === void 0 ? void 0 : billing.auto_recharge_amount_usd) }), jsx(Stat, { label: "Spending limit", value: isUnlimitedSpendingLimit ? 'Unlimited' : formatUsd(spendingLimitRaw) })] })) : (jsx("p", { className: "text-[14px] font-normal leading-5 text-[#4a5565] dark:text-gray-400", children: "Auto recharge is currently disabled. Enable it to keep your balance topped up without interruption." })) }))] }), jsx(AutoRechargeModal, { tenant: tenant, isOpen: isAutoRechargeModalOpen, onClose: () => setIsAutoRechargeModalOpen(false) }), jsx(AddCreditsModal, { tenant: tenant, isOpen: isAddCreditsModalOpen, onClose: () => setIsAddCreditsModalOpen(false) })] }));
|
|
163282
163356
|
}
|
|
163283
163357
|
|
|
163284
163358
|
const SmtpContent = ({ platformKey }) => {
|
|
@@ -165550,12 +165624,15 @@ function MonetizationTab({ platformKey }) {
|
|
|
165550
165624
|
return (jsxs("div", { className: "container mx-auto max-w-7xl !mt-0 space-y-6", children: [jsx(StripeConnect, { platformKey: platformKey }), jsx(PaywallConfig, { platformKey: platformKey, disabled: !isStripeReady })] }));
|
|
165551
165625
|
}
|
|
165552
165626
|
|
|
165553
|
-
function Account({ tenant, tenants = [], username, onInviteClick,
|
|
165627
|
+
function Account({ tenant, tenants = [], username, onInviteClick, email, mainPlatformKey, userActiveApp = null, showPlatformName = false, isAdmin = false, targetTab = 'basic', currentPlan: _currentPlan = '', currentSPA = '', authURL, onTenantUpdate, currentPlatformBaseDomain = '', enableRbac = false, rbacPermissions = {}, onLoadGroupPermissions, onTabChange, }) {
|
|
165628
|
+
const currentTenant = tenants.find((t) => t.key === tenant);
|
|
165554
165629
|
const TABS = [
|
|
165555
165630
|
{ id: 'organization', label: 'Organization', icon: Briefcase },
|
|
165556
165631
|
{ id: 'management', label: 'Management', icon: Users },
|
|
165557
165632
|
{ id: 'integrations', label: 'Integrations', icon: KeyRound },
|
|
165558
|
-
|
|
165633
|
+
...((currentTenant === null || currentTenant === void 0 ? void 0 : currentTenant.show_paywall)
|
|
165634
|
+
? [{ id: 'monetization', label: 'Monetization', icon: Coins }]
|
|
165635
|
+
: []),
|
|
165559
165636
|
{ id: 'advanced', label: 'Advanced', icon: Settings },
|
|
165560
165637
|
];
|
|
165561
165638
|
const [activeTab, setActiveTab] = useState(targetTab);
|
|
@@ -165603,7 +165680,7 @@ function Account({ tenant, tenants = [], username, onInviteClick, billingURL = '
|
|
|
165603
165680
|
}
|
|
165604
165681
|
}, className: `w-full justify-start px-4 py-3 text-left rounded-lg transition-all flex items-center text-base ${activeTab === tab.id
|
|
165605
165682
|
? 'bg-blue-50 text-blue-700 font-medium'
|
|
165606
|
-
: 'hover:bg-gray-50 text-gray-700 dark:text-gray-300 hover:text-gray-900 dark:hover:text-gray-100'}`, children: [jsx(tab.icon, { className: "h-5 w-5 mr-3 flex-shrink-0" }), jsx("span", { className: "truncate", children: tab.label })] }, tab.id))), (
|
|
165683
|
+
: 'hover:bg-gray-50 text-gray-700 dark:text-gray-300 hover:text-gray-900 dark:hover:text-gray-100'}`, children: [jsx(tab.icon, { className: "h-5 w-5 mr-3 flex-shrink-0" }), jsx("span", { className: "truncate", children: tab.label })] }, tab.id))), (currentTenant === null || currentTenant === void 0 ? void 0 : currentTenant.show_paywall) && (jsxs("button", { onClick: () => {
|
|
165607
165684
|
setActiveTab('billing');
|
|
165608
165685
|
// Set URL param for billing tab
|
|
165609
165686
|
onTabChange === null || onTabChange === void 0 ? void 0 : onTabChange('billing');
|
|
@@ -165629,7 +165706,7 @@ function Account({ tenant, tenants = [], username, onInviteClick, billingURL = '
|
|
|
165629
165706
|
}
|
|
165630
165707
|
}, className: `flex items-center gap-2 px-3 py-2 rounded-lg whitespace-nowrap text-sm transition-all ${activeTab === tab.id
|
|
165631
165708
|
? 'bg-blue-50 text-blue-600 font-medium'
|
|
165632
|
-
: 'text-gray-600 hover:bg-gray-50'}`, children: [jsx(tab.icon, { className: "h-4 w-4" }), jsx("span", { className: "hidden sm:inline", children: tab.label }), jsx("span", { className: "sm:hidden", children: tab.label })] }, tab.id))), (
|
|
165709
|
+
: 'text-gray-600 hover:bg-gray-50'}`, children: [jsx(tab.icon, { className: "h-4 w-4" }), jsx("span", { className: "hidden sm:inline", children: tab.label }), jsx("span", { className: "sm:hidden", children: tab.label })] }, tab.id))), (currentTenant === null || currentTenant === void 0 ? void 0 : currentTenant.show_paywall) && (jsxs("button", { onClick: () => {
|
|
165633
165710
|
setActiveTab('billing');
|
|
165634
165711
|
// Set URL param for billing tab
|
|
165635
165712
|
onTabChange === null || onTabChange === void 0 ? void 0 : onTabChange('billing');
|
|
@@ -165638,10 +165715,10 @@ function Account({ tenant, tenants = [], username, onInviteClick, billingURL = '
|
|
|
165638
165715
|
: 'text-gray-600 hover:bg-gray-50'}`, children: [jsx(CreditCard, { className: "h-4 w-4" }), jsx("span", { className: "hidden sm:inline", children: "Billing" }), jsx("span", { className: "sm:hidden", children: "Billing" })] }, 'billing'))] }) }) }), jsxs("div", { className: "flex-1 flex flex-col overflow-hidden", style: { height: '100%' }, children: [jsxs("div", { className: "hidden lg:block flex-shrink-0 p-6 border-b border-gray-200 bg-white dark:bg-gray-900", children: [jsx("h3", { className: "text-lg font-medium text-gray-900 dark:text-gray-100 mb-2 capitalize", children: activeTab }), jsxs("p", { className: "text-gray-600 dark:text-gray-400 text-sm", children: [activeTab === 'management' && 'Manage users and their permissions in the system.', activeTab === 'organization' && 'Manage your organization settings.', activeTab === 'integrations' && 'Manage your integrations with other services.', activeTab === 'billing' && 'Manage your billing and subscription.', activeTab === 'monetization' && 'Configure paywalls, pricing, and revenue.', activeTab === 'advanced' && 'Configure advanced organization settings.'] })] }), jsxs("div", { className: "flex-1 p-6 space-y-6", style: {
|
|
165639
165716
|
overflowY: 'auto',
|
|
165640
165717
|
overflowX: 'hidden',
|
|
165641
|
-
}, children: [jsxs("div", { className: "lg:hidden mb-6", children: [jsx("h3", { className: "text-lg font-medium text-gray-900 dark:text-gray-100 mb-2 capitalize", children: activeTab }), jsxs("p", { className: "text-gray-600 dark:text-gray-400 text-sm", children: [activeTab === 'basic' && 'Manage your basic account information and preferences.', activeTab === 'social' && 'Connect and manage your social media accounts.', activeTab === 'security' && 'Update your security settings and password.', activeTab === 'management' && 'Manage users and their permissions in the system.', activeTab === 'organization' && 'Manage your organization settings.', activeTab === 'monetization' && 'Configure paywalls, pricing, and revenue.', activeTab === 'advanced' && 'Configure advanced organization settings.'] })] }), activeTab === 'management' && hasManagementPermissions && (jsx(Admin, { onInviteClick: onInviteClick, tenant: tenant, hasUserTabPermission: hasUserTabPermission, hasGroupsTabPermission: hasGroupsTabPermission, hasPoliciesTabPermission: hasPoliciesTabPermission, hasRolesTabPermission: hasRolesTabPermission, hasTeamsTabPermission: hasTeamsTabPermission, hasInviteUserPermission: hasInviteUserPermission, hasCreateTeamPermission: hasCreateTeamPermission, onLoadGroupPermissions: onLoadGroupPermissions, rbacPermissions: rbacPermissions, enableRbac: enableRbac })), activeTab === 'organization' && (jsx(OrganizationTab, { platformKey: tenant, tenant: tenants.find((t) => t.key === tenant), onTenantUpdate: onTenantUpdate, setOrganizationLogoFromOutside: setOrganizationLogo })), activeTab === 'integrations' && (jsx(IntegrationsTab, { tenantKey: tenant, username: username })), activeTab === 'billing' && (jsx(BillingTab, { tenant: tenant,
|
|
165718
|
+
}, children: [jsxs("div", { className: "lg:hidden mb-6", children: [jsx("h3", { className: "text-lg font-medium text-gray-900 dark:text-gray-100 mb-2 capitalize", children: activeTab }), jsxs("p", { className: "text-gray-600 dark:text-gray-400 text-sm", children: [activeTab === 'basic' && 'Manage your basic account information and preferences.', activeTab === 'social' && 'Connect and manage your social media accounts.', activeTab === 'security' && 'Update your security settings and password.', activeTab === 'management' && 'Manage users and their permissions in the system.', activeTab === 'organization' && 'Manage your organization settings.', activeTab === 'monetization' && 'Configure paywalls, pricing, and revenue.', activeTab === 'advanced' && 'Configure advanced organization settings.'] })] }), activeTab === 'management' && hasManagementPermissions && (jsx(Admin, { onInviteClick: onInviteClick, tenant: tenant, hasUserTabPermission: hasUserTabPermission, hasGroupsTabPermission: hasGroupsTabPermission, hasPoliciesTabPermission: hasPoliciesTabPermission, hasRolesTabPermission: hasRolesTabPermission, hasTeamsTabPermission: hasTeamsTabPermission, hasInviteUserPermission: hasInviteUserPermission, hasCreateTeamPermission: hasCreateTeamPermission, onLoadGroupPermissions: onLoadGroupPermissions, rbacPermissions: rbacPermissions, enableRbac: enableRbac })), activeTab === 'organization' && (jsx(OrganizationTab, { platformKey: tenant, tenant: tenants.find((t) => t.key === tenant), onTenantUpdate: onTenantUpdate, setOrganizationLogoFromOutside: setOrganizationLogo })), activeTab === 'integrations' && (jsx(IntegrationsTab, { tenantKey: tenant, username: username })), activeTab === 'billing' && (jsx(BillingTab, { tenant: tenant, userActiveApp: userActiveApp, username: username, currentUserEmail: email, mainPlatformKey: mainPlatformKey })), activeTab === 'monetization' && jsx(MonetizationTab, { platformKey: tenant }), activeTab === 'advanced' && (jsx(AdvancedTab, { platformKey: tenant, currentSPA: currentSPA, username: username, authURL: authURL, currentPlatformBaseDomain: currentPlatformBaseDomain }))] })] }), jsx(ToastProvider, {})] }));
|
|
165642
165719
|
}
|
|
165643
165720
|
|
|
165644
|
-
function UserProfileModal({ isOpen, onClose, params,
|
|
165721
|
+
function UserProfileModal({ isOpen, onClose, params, email, mainPlatformKey, showMentorAIDisplayCheckbox = false, showLeaderboardDisplayCheckbox = false, showUsernameField = false, showPlatformName = false, useGravatarPicFallback = true, enableCatalogInvite = false, targetTab = 'basic', currentPlan = '', currentSPA = '', userActiveApp = null, authURL, tenants = [], onTenantUpdate, currentPlatformBaseDomain = '', rbacPermissions = {}, enableRbac = false, onLoadGroupPermissions, onTabChange, onBillingTabRequest, onAccountDeleted, enableMemoryTab = false, localLLMProps, }) {
|
|
165645
165722
|
console.log('[UserProfileModal] localLLMProps received:', {
|
|
165646
165723
|
isAvailable: localLLMProps === null || localLLMProps === void 0 ? void 0 : localLLMProps.isAvailable,
|
|
165647
165724
|
foundryStatus: localLLMProps === null || localLLMProps === void 0 ? void 0 : localLLMProps.foundryStatus,
|
|
@@ -165686,18 +165763,6 @@ function UserProfileModal({ isOpen, onClose, params, billingEnabled = false, bil
|
|
|
165686
165763
|
}
|
|
165687
165764
|
}
|
|
165688
165765
|
}, [isOpen]);
|
|
165689
|
-
const [stripeBillingURL, setStripeBillingURL] = React.useState('');
|
|
165690
|
-
React.useEffect(() => {
|
|
165691
|
-
if (billingURL && billingEnabled) {
|
|
165692
|
-
setStripeBillingURL(billingURL);
|
|
165693
|
-
}
|
|
165694
|
-
}, [billingURL, billingEnabled]);
|
|
165695
|
-
const [stripeTopUpURL, setStripeTopUpURL] = React.useState('');
|
|
165696
|
-
React.useEffect(() => {
|
|
165697
|
-
if (topUpURL && topUpEnabled) {
|
|
165698
|
-
setStripeTopUpURL(topUpURL);
|
|
165699
|
-
}
|
|
165700
|
-
}, [topUpURL, topUpEnabled]);
|
|
165701
165766
|
return (jsx(Fragment$1, { children: jsx(Dialog, { open: isOpen, onOpenChange: () => {
|
|
165702
165767
|
if (!isInviteUserDialogOpen) {
|
|
165703
165768
|
onClose();
|
|
@@ -165711,13 +165776,13 @@ function UserProfileModal({ isOpen, onClose, params, billingEnabled = false, bil
|
|
|
165711
165776
|
'resume',
|
|
165712
165777
|
'memory',
|
|
165713
165778
|
'advanced',
|
|
165714
|
-
].includes(targetTab) && (jsx(Profile, { tenant: params.tenantKey, username: getUserName$1(), customization: {
|
|
165779
|
+
].includes(targetTab) && (jsx(Profile, { tenant: params.tenantKey, tenants: tenants, username: getUserName$1(), customization: {
|
|
165715
165780
|
showMentorAIDisplayCheckbox: showMentorAIDisplayCheckbox,
|
|
165716
165781
|
showLeaderboardDisplayCheckbox: showLeaderboardDisplayCheckbox,
|
|
165717
165782
|
showUsernameField: showUsernameField,
|
|
165718
165783
|
showPlatformName: showPlatformName,
|
|
165719
165784
|
useGravatarPicFallback: useGravatarPicFallback,
|
|
165720
|
-
}, isAdmin: params.isAdmin, targetTab: targetTab, onClose: onClose, onAccountDeleted: onAccountDeleted, enableMemoryTab: enableMemoryTab, localLLMProps: localLLMProps })), ['organization', 'management', 'integrations', 'billing', 'monetization'].includes(targetTab) && (jsxs(Fragment$1, { children: [jsx(Account, { onInviteClick: () => setIsInviteUserDialogOpen(true), tenant: params.tenantKey, tenants: tenants, username: getUserName$1(),
|
|
165785
|
+
}, isAdmin: params.isAdmin, targetTab: targetTab, onClose: onClose, onAccountDeleted: onAccountDeleted, enableMemoryTab: enableMemoryTab, localLLMProps: localLLMProps })), ['organization', 'management', 'integrations', 'billing', 'monetization'].includes(targetTab) && (jsxs(Fragment$1, { children: [jsx(Account, { onInviteClick: () => setIsInviteUserDialogOpen(true), tenant: params.tenantKey, tenants: tenants, username: getUserName$1(), email: email, mainPlatformKey: mainPlatformKey, showUsernameField: showUsernameField, showPlatformName: showPlatformName, useGravatarPicFallback: useGravatarPicFallback, onClose: onClose, isAdmin: params.isAdmin, targetTab: targetTab, currentPlan: currentPlan, currentSPA: currentSPA, userActiveApp: userActiveApp, authURL: authURL, onTenantUpdate: onTenantUpdate, currentPlatformBaseDomain: currentPlatformBaseDomain, rbacPermissions: rbacPermissions, enableRbac: enableRbac, onLoadGroupPermissions: onLoadGroupPermissions, onTabChange: onTabChange }), isInviteUserDialogOpen && (jsx(InviteUserDialog, { tenant: params.tenantKey, onClose: () => setIsInviteUserDialogOpen(false), isOpen: isInviteUserDialogOpen, enableCatalogInvite: enableCatalogInvite, hasManageUsersPermission: hasManageUsersPermission })), isInvitedUsersDialogOpen && (jsx(InvitedUsersDialog, { onClose: () => setIsInvitedUsersDialogOpen(false), tenant: params.tenantKey }))] }))] }) }) }));
|
|
165721
165786
|
}
|
|
165722
165787
|
|
|
165723
165788
|
// Tauri types for model download functionality
|
|
@@ -166240,7 +166305,7 @@ function useModelDownload() {
|
|
|
166240
166305
|
};
|
|
166241
166306
|
}
|
|
166242
166307
|
|
|
166243
|
-
function UserProfileDropdown({
|
|
166308
|
+
function UserProfileDropdown({ email, mainPlatformKey,
|
|
166244
166309
|
// User data
|
|
166245
166310
|
username, userIsAdmin = false, userIsStudent = false, userIsVisiting = false,
|
|
166246
166311
|
// Tenant data
|
|
@@ -166250,9 +166315,9 @@ showProfileTab = true, showAccountTab = false, showTenantSwitcher = true, showHe
|
|
|
166250
166315
|
// Customization
|
|
166251
166316
|
helpCenterUrl = '', enableGravatarOnProfilePic = true,
|
|
166252
166317
|
// Callbacks
|
|
166253
|
-
onProfileClick, onTabChange,
|
|
166318
|
+
onProfileClick, onTabChange, onBillingTabRequest, onLogout, onTenantChange, onHelpClick,
|
|
166254
166319
|
// Modal props
|
|
166255
|
-
|
|
166320
|
+
currentPlan = '', userActiveApp = null,
|
|
166256
166321
|
// Custom components
|
|
166257
166322
|
LearnerModeSwitchComponent, CustomProfileModal,
|
|
166258
166323
|
// Styling
|
|
@@ -166422,11 +166487,9 @@ isModalOpen, onModalOpenChange, defaultActiveTab, onAccountDeleted, enableMemory
|
|
|
166422
166487
|
mentorId: mentorId || '',
|
|
166423
166488
|
isAdmin: userIsAdmin,
|
|
166424
166489
|
},
|
|
166425
|
-
billingEnabled: !!billingURL,
|
|
166426
|
-
billingURL,
|
|
166427
166490
|
userActiveApp,
|
|
166428
|
-
|
|
166429
|
-
|
|
166491
|
+
email,
|
|
166492
|
+
mainPlatformKey,
|
|
166430
166493
|
useGravatarPicFallback: enableGravatarOnProfilePic,
|
|
166431
166494
|
targetTab: activeTab,
|
|
166432
166495
|
currentPlan,
|
|
@@ -166444,7 +166507,6 @@ isModalOpen, onModalOpenChange, defaultActiveTab, onAccountDeleted, enableMemory
|
|
|
166444
166507
|
enableRbac,
|
|
166445
166508
|
onLoadGroupPermissions,
|
|
166446
166509
|
onTabChange,
|
|
166447
|
-
onUpgradeClick,
|
|
166448
166510
|
onBillingTabRequest,
|
|
166449
166511
|
localLLMProps: {
|
|
166450
166512
|
isAvailable: isLocalLLMAvailable,
|