Remove Chat Placeholder when chat is hidden (#10209)

This commit is contained in:
Sergei Garin 2024-06-07 14:58:50 +03:00 committed by GitHub
parent ed9651fc2b
commit 7744e8b464
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -18,7 +18,7 @@ import Portal from '#/components/Portal'
/** Props for a {@link Page}. */
export interface PageProps extends Readonly<React.PropsWithChildren> {
readonly hideInfoBar?: true
readonly hideChat?: true
readonly hideChat?: boolean
}
/** A page. */
@ -52,18 +52,21 @@ export default function Page(props: PageProps) {
<InfoBar isHelpChatOpen={isHelpChatOpen} setIsHelpChatOpen={setIsHelpChatOpen} />
</div>
)}
{/* `session.accessToken` MUST be present in order for the `Chat` component to work. */}
{!hideInfoBar &&
!hideChat &&
session?.accessToken != null &&
process.env.ENSO_CLOUD_CHAT_URL != null ? (
<Chat
isOpen={isHelpChatOpen}
doClose={doCloseChat}
endpoint={process.env.ENSO_CLOUD_CHAT_URL}
/>
) : (
<ChatPlaceholder hideLoginButtons isOpen={isHelpChatOpen} doClose={doCloseChat} />
{!hideChat && (
<>
{/* `session.accessToken` MUST be present in order for the `Chat` component to work. */}
{!hideInfoBar &&
session?.accessToken != null &&
process.env.ENSO_CLOUD_CHAT_URL != null ? (
<Chat
isOpen={isHelpChatOpen}
doClose={doCloseChat}
endpoint={process.env.ENSO_CLOUD_CHAT_URL}
/>
) : (
<ChatPlaceholder hideLoginButtons isOpen={isHelpChatOpen} doClose={doCloseChat} />
)}
</>
)}
<Portal>
<div className="select-none text-xs text-primary">