Skip to content

Commit

Permalink
fix: remove AI UI if user doesn't have access to AI (#9856)
Browse files Browse the repository at this point in the history
  • Loading branch information
nickoferrall authored Jun 25, 2024
1 parent 2ab7352 commit 95431b2
Showing 1 changed file with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ interface Props {
meetingRef: WholeMeetingSummary_meeting$key
}

const isServer = typeof window === 'undefined'
const hasAI = isServer
? !!process.env.OPEN_AI_API_KEY
: !!window.__ACTION__ && !!window.__ACTION__.hasOpenAI

const WholeMeetingSummary = (props: Props) => {
const {meetingRef} = props
const meeting = useFragment(
Expand Down Expand Up @@ -44,15 +49,20 @@ const WholeMeetingSummary = (props: Props) => {
const {summary: wholeMeetingSummary, reflectionGroups, organization} = meeting
const reflections = reflectionGroups?.flatMap((group) => group.reflections) // reflectionCount hasn't been calculated yet so check reflections length
const hasMoreThanOneReflection = reflections?.length && reflections.length > 1
if (!hasMoreThanOneReflection || organization.featureFlags.noAISummary) return null
if (!hasMoreThanOneReflection || organization.featureFlags.noAISummary || !hasAI) return null
if (!wholeMeetingSummary) return <WholeMeetingSummaryLoading />
return <WholeMeetingSummaryResult meetingRef={meeting} />
} else if (meeting.__typename === 'TeamPromptMeeting') {
const {summary: wholeMeetingSummary, responses, organization} = meeting
if (!organization.featureFlags.standupAISummary || organization.featureFlags.noAISummary) {
if (
!organization.featureFlags.standupAISummary ||
organization.featureFlags.noAISummary ||
!hasAI ||
!responses ||
responses.length === 0
) {
return null
}
if (!responses || responses.length === 0) return null
if (!wholeMeetingSummary) return <WholeMeetingSummaryLoading />
return <WholeMeetingSummaryResult meetingRef={meeting} />
}
Expand Down

0 comments on commit 95431b2

Please sign in to comment.