Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions src/elements/content-sidebar/BoxAISidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { useIntl } from 'react-intl';

import { ArrowsExpand } from '@box/blueprint-web-assets/icons/Fill';
import { IconButton } from '@box/blueprint-web';
import { BoxAiContentAnswers, type BoxAiContentAnswersProps } from '@box/box-ai-content-answers';
import SidebarContent from './SidebarContent';
import { withAPIContext } from '../common/api-context';
import { withErrorBoundary } from '../common/error-boundary';
Expand All @@ -23,13 +24,24 @@ const MARK_NAME_JS_READY: string = `${ORIGIN_BOXAI_SIDEBAR}_${EVENT_JS_READY}`;

mark(MARK_NAME_JS_READY);

interface ContentAnswersProps extends BoxAiContentAnswersProps {
startSession: () => void;
}

export interface BoxAISidebarProps {
onExpandClick: () => void;
contentAnswersProps: ContentAnswersProps;
}

function BoxAISidebar({ onExpandClick }: BoxAISidebarProps) {
function BoxAISidebar(props: BoxAISidebarProps) {
const { onExpandClick, contentAnswersProps } = props;

const { formatMessage } = useIntl();

const { startSession } = contentAnswersProps ?? {};
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?? is not needed


startSession();

return (
<SidebarContent
actions={
Expand All @@ -44,7 +56,9 @@ function BoxAISidebar({ onExpandClick }: BoxAISidebarProps) {
sidebarView={SIDEBAR_VIEW_BOXAI}
title={formatMessage(messages.sidebarBoxAITitle)}
>
<div className="bcs-BoxAISidebar-content" />
<div className="bcs-BoxAISidebar-content">
{contentAnswersProps && <BoxAiContentAnswers {...contentAnswersProps} />}
</div>
</SidebarContent>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ describe('elements/content-sidebar/BoxAISidebar', () => {
const renderComponent = (props = {}) => {
const defaultProps = {
onExpandClick: mockOnExpandClick,
} satisfies BoxAISidebarProps;
} as unknown as BoxAISidebarProps;

render(<BoxAISidebarComponent {...defaultProps} {...props} />);
};
Expand Down