mirror of
https://github.com/StanGirard/quivr.git
synced 2024-12-25 04:12:44 +03:00
2f68b445db
Issue https://github.com/StanGirard/quivr/issues/1908 Demo: https://github.com/StanGirard/quivr/assets/63923024/3be5d58c-4052-4c06-8434-920d4db0365e
33 lines
840 B
TypeScript
33 lines
840 B
TypeScript
import { UUID } from "crypto";
|
|
import { useParams } from "next/navigation";
|
|
|
|
import { useBrainFetcher } from "@/app/brains-management/[brainId]/components/BrainManagementTabs/hooks/useBrainFetcher";
|
|
|
|
import { useBrainContext } from "../context/BrainProvider/hooks/useBrainContext";
|
|
|
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
export const useUrlBrain = () => {
|
|
const { allBrains } = useBrainContext();
|
|
|
|
const params = useParams();
|
|
|
|
const brainId = params?.brainId as UUID | undefined;
|
|
const correspondingBrain = allBrains.find((brain) => brain.id === brainId);
|
|
|
|
const {
|
|
brain: brainDetails,
|
|
refetchBrain,
|
|
isLoading,
|
|
} = useBrainFetcher({
|
|
brainId: brainId,
|
|
});
|
|
|
|
return {
|
|
brain: correspondingBrain,
|
|
brainId,
|
|
brainDetails,
|
|
refetchBrain,
|
|
isLoading,
|
|
};
|
|
};
|