Просмотр исходного кода

Move isLearnablePageLimitReached to utils

Shun Miyazawa 1 год назад
Родитель
Сommit
f23d3437d2

+ 2 - 1
apps/app/src/features/openai/client/components/AiAssistant/AiAssistantManagementModal/AiAssistantManagementHome.tsx

@@ -11,6 +11,7 @@ import { useCurrentUser } from '~/stores-universal/context';
 
 import type { SelectedPage } from '../../../../interfaces/selected-page';
 import { determineShareScope } from '../../../../utils/determine-share-scope';
+import { isLearnablePageLimitReached } from '../../../../utils/is-learnable-page-limit-reached';
 import { useAiAssistantManagementModal, AiAssistantManagementModalPageMode } from '../../../stores/ai-assistant';
 
 import { ShareScopeWarningModal } from './ShareScopeWarningModal';
@@ -69,7 +70,7 @@ export const AiAssistantManagementHome = (props: Props): JSX.Element => {
       : t(baseLabel);
   }, [currentUser?.username, t]);
 
-  const canUpsert = name !== '' && selectedPages.length !== 0 && totalSelectedPageCount <= LIMIT_LEARNABLE_PAGE_COUNT;
+  const canUpsert = name !== '' && selectedPages.length !== 0 && !isLearnablePageLimitReached(totalSelectedPageCount);
 
   const upsertAiAssistantHandler = useCallback(async() => {
     const shouldWarning = () => {

+ 5 - 0
apps/app/src/features/openai/utils/is-learnable-page-limit-reached.ts

@@ -0,0 +1,5 @@
+import { LIMIT_LEARNABLE_PAGE_COUNT } from '../interfaces/ai-assistant';
+
+export const isLearnablePageLimitReached = (totalPageCount: number): boolean => {
+  return totalPageCount > LIMIT_LEARNABLE_PAGE_COUNT;
+};