mirror of
https://github.com/rzmk/learnhouse.git
synced 2025-12-19 04:19:25 +00:00
chore: refactor frontend components folder
This commit is contained in:
parent
46f016f661
commit
5a746a946d
106 changed files with 159 additions and 164 deletions
29
apps/web/components/Hooks/useGetAIFeatures.tsx
Normal file
29
apps/web/components/Hooks/useGetAIFeatures.tsx
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
import { useOrg } from '@components/Contexts/OrgContext'
|
||||
import React from 'react'
|
||||
|
||||
interface UseGetAIFeatures {
|
||||
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?.features.ai.enabled
|
||||
|
||||
return config
|
||||
}
|
||||
|
||||
React.useEffect(() => {
|
||||
if (org) {
|
||||
// Check if org is not null or undefined
|
||||
let isEnabledStatus = checkAvailableAIFeaturesOnOrg(props.feature)
|
||||
setisEnabled(isEnabledStatus)
|
||||
}
|
||||
}, [org])
|
||||
|
||||
return isEnabled
|
||||
}
|
||||
|
||||
export default useGetAIFeatures
|
||||
Loading…
Add table
Add a link
Reference in a new issue