mirror of
https://github.com/StanGirard/quivr.git
synced 2024-12-13 16:47:43 +03:00
1a5fa8ba0f
Issue: https://github.com/StanGirard/quivr/issues/1627 Demo: <img width="1512" alt="Screenshot 2023-11-15 at 13 09 59" src="https://github.com/StanGirard/quivr/assets/63923024/532c45ce-32d7-4af7-a71f-02eb6099538d">
26 lines
766 B
TypeScript
26 lines
766 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 } = useBrainFetcher({
|
|
brainId: brainId,
|
|
});
|
|
|
|
return {
|
|
brain: correspondingBrain,
|
|
brainId,
|
|
brainDetails,
|
|
};
|
|
};
|