mirror of
https://github.com/StanGirard/quivr.git
synced 2024-12-20 18:01:39 +03:00
20 lines
474 B
TypeScript
20 lines
474 B
TypeScript
|
import { UUID } from "crypto";
|
||
|
|
||
|
import { MinimalBrainForUser } from "@/lib/context/BrainProvider/types";
|
||
|
|
||
|
type IsUserBrainOwnerProps = {
|
||
|
userAccessibleBrains: MinimalBrainForUser[];
|
||
|
brainId?: UUID;
|
||
|
};
|
||
|
export const isUserBrainOwner = ({
|
||
|
brainId,
|
||
|
userAccessibleBrains,
|
||
|
}: IsUserBrainOwnerProps): boolean => {
|
||
|
const brain = userAccessibleBrains.find(({ id }) => id === brainId);
|
||
|
if (brain === undefined) {
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
return brain.role === "Owner";
|
||
|
};
|