mirror of
https://github.com/QuivrHQ/quivr.git
synced 2025-01-07 08:07:44 +03:00
d7d1a0155b
# Description Please include a summary of the changes and the related issue. Please also include relevant motivation and context. ## Checklist before requesting a review Please delete options that are not relevant. - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my code - [ ] I have commented hard-to-understand areas - [ ] I have ideally added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] Any dependent changes have been merged ## Screenshots (if appropriate):
61 lines
1.7 KiB
TypeScript
61 lines
1.7 KiB
TypeScript
import Image from "next/image";
|
|
|
|
import { useBrainContext } from "@/lib/context/BrainProvider/hooks/useBrainContext";
|
|
import { useUserSettingsContext } from "@/lib/context/UserSettingsProvider/hooks/useUserSettingsContext";
|
|
|
|
import styles from "./CurrentBrain.module.scss";
|
|
|
|
import { Icon } from "../ui/Icon/Icon";
|
|
|
|
interface CurrentBrainProps {
|
|
allowingRemoveBrain: boolean;
|
|
}
|
|
|
|
export const CurrentBrain = ({
|
|
allowingRemoveBrain,
|
|
}: CurrentBrainProps): JSX.Element => {
|
|
const { currentBrain, setCurrentBrainId } = useBrainContext();
|
|
const { isDarkMode } = useUserSettingsContext();
|
|
const removeCurrentBrain = (): void => {
|
|
setCurrentBrainId(null);
|
|
};
|
|
|
|
if (!currentBrain) {
|
|
return <></>;
|
|
}
|
|
|
|
return (
|
|
<div className={styles.current_brain_wrapper}>
|
|
<div className={styles.brain_infos}>
|
|
<div className={styles.left}>
|
|
<span className={styles.title}>Talking to</span>
|
|
<div className={styles.brain_name_wrapper}>
|
|
<Image
|
|
className={isDarkMode ? styles.dark_image : ""}
|
|
src={
|
|
currentBrain.integration_logo_url
|
|
? currentBrain.integration_logo_url
|
|
: "/default_brain_image.png"
|
|
}
|
|
alt="logo_image"
|
|
width={18}
|
|
height={18}
|
|
/>
|
|
<span className={styles.brain_name}>{currentBrain.name}</span>
|
|
</div>
|
|
</div>
|
|
{allowingRemoveBrain && (
|
|
<div
|
|
onClick={(event) => {
|
|
event.nativeEvent.stopImmediatePropagation();
|
|
removeCurrentBrain();
|
|
}}
|
|
>
|
|
<Icon size="normal" name="close" color="black" handleHover={true} />
|
|
</div>
|
|
)}
|
|
</div>
|
|
</div>
|
|
);
|
|
};
|