feat: add default feed button label (#1892)

Demo: 



https://github.com/StanGirard/quivr/assets/63923024/c25e5892-be59-47ed-b1ea-8ce6bcc50214
This commit is contained in:
Mamadou DICKO 2023-12-14 11:33:59 +01:00 committed by GitHub
parent bc2b012e47
commit cb4148fc50
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,4 +1,5 @@
import { Fragment } from "react"; import { useTranslation } from "react-i18next";
import { LuFilePlus } from "react-icons/lu";
import { useBrainContext } from "@/lib/context/BrainProvider/hooks/useBrainContext"; import { useBrainContext } from "@/lib/context/BrainProvider/hooks/useBrainContext";
@ -6,15 +7,21 @@ import { useFeedCardTriggerUtils } from "./useFeedCardTriggerUtils";
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
export const useFeedCardTrigger = () => { export const useFeedCardTrigger = () => {
const { t } = useTranslation(["chat", "brain"]);
const feedCardButtonDefaultLabel = t("chat:add_document");
const feedCardButtonDefaultIcon = LuFilePlus;
const { brainTypeToIcon, brainTypeToLabel } = useFeedCardTriggerUtils(); const { brainTypeToIcon, brainTypeToLabel } = useFeedCardTriggerUtils();
const { currentBrain } = useBrainContext(); const { currentBrain } = useBrainContext();
const isBrainTypeDefined = currentBrain?.brain_type !== undefined; const isBrainTypeDefined = currentBrain?.brain_type !== undefined;
return { return {
label: isBrainTypeDefined ? brainTypeToLabel[currentBrain.brain_type] : "", label: isBrainTypeDefined
? brainTypeToLabel[currentBrain.brain_type]
: feedCardButtonDefaultLabel,
Icon: isBrainTypeDefined Icon: isBrainTypeDefined
? brainTypeToIcon[currentBrain.brain_type] ? brainTypeToIcon[currentBrain.brain_type]
: Fragment, : feedCardButtonDefaultIcon,
}; };
}; };