mirror of
https://github.com/rzmk/learnhouse.git
synced 2025-12-19 04:19:25 +00:00
feat: format with prettier
This commit is contained in:
parent
03fb09c3d6
commit
a147ad6610
164 changed files with 11257 additions and 8154 deletions
|
|
@ -2,44 +2,43 @@ import { useOrg } from '@components/Contexts/OrgContext'
|
|||
import React from 'react'
|
||||
|
||||
interface UseGetAIFeatures {
|
||||
feature: 'editor' | 'activity_ask' | 'course_ask' | 'global_ai_ask',
|
||||
feature: 'editor' | 'activity_ask' | 'course_ask' | 'global_ai_ask'
|
||||
}
|
||||
|
||||
|
||||
function useGetAIFeatures(props: UseGetAIFeatures) {
|
||||
const org = useOrg() as any
|
||||
const [isEnabled, setisEnabled] = React.useState(false)
|
||||
|
||||
function checkAvailableAIFeaturesOnOrg(feature: string) {
|
||||
const config = org?.config?.config?.AIConfig;
|
||||
const config = org?.config?.config?.AIConfig
|
||||
|
||||
if (!config) {
|
||||
console.log("AI or Organization config is not defined.");
|
||||
return false;
|
||||
console.log('AI or Organization config is not defined.')
|
||||
return false
|
||||
}
|
||||
|
||||
if (!config.enabled) {
|
||||
console.log("AI is not enabled for this Organization.");
|
||||
return false;
|
||||
console.log('AI is not enabled for this Organization.')
|
||||
return false
|
||||
}
|
||||
|
||||
if (!config.features[feature]) {
|
||||
console.log(`Feature ${feature} is not enabled for this Organization.`);
|
||||
return false;
|
||||
console.log(`Feature ${feature} is not enabled for this Organization.`)
|
||||
return false
|
||||
}
|
||||
|
||||
return true;
|
||||
return true
|
||||
}
|
||||
|
||||
React.useEffect(() => {
|
||||
if (org) { // Check if org is not null or undefined
|
||||
if (org) {
|
||||
// Check if org is not null or undefined
|
||||
let isEnabledStatus = checkAvailableAIFeaturesOnOrg(props.feature)
|
||||
setisEnabled(isEnabledStatus)
|
||||
}
|
||||
}, [org])
|
||||
|
||||
return isEnabled
|
||||
|
||||
}
|
||||
|
||||
export default useGetAIFeatures
|
||||
export default useGetAIFeatures
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue