mirror of
https://github.com/StanGirard/quivr.git
synced 2024-12-14 21:21:56 +03:00
20 lines
545 B
TypeScript
20 lines
545 B
TypeScript
|
import { UUID } from "crypto";
|
||
|
import { useParams } from "next/navigation";
|
||
|
|
||
|
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);
|
||
|
|
||
|
return {
|
||
|
brain: correspondingBrain,
|
||
|
brainId,
|
||
|
};
|
||
|
};
|