2023-07-18 19:28:44 +03:00
|
|
|
import { UUID } from "crypto";
|
|
|
|
|
2024-02-29 03:42:14 +03:00
|
|
|
import { MessageInfoBox } from "@/lib/components/ui/MessageInfoBox/MessageInfoBox";
|
|
|
|
|
|
|
|
import { BrainUser } from "./components/BrainUser/BrainUser";
|
2023-07-19 14:36:23 +03:00
|
|
|
import { useBrainUsers } from "./hooks/useBrainUsers";
|
2023-07-18 19:28:44 +03:00
|
|
|
|
|
|
|
type BrainUsersProps = {
|
|
|
|
brainId: UUID;
|
|
|
|
};
|
2023-07-19 14:36:23 +03:00
|
|
|
export const BrainUsers = ({ brainId }: BrainUsersProps): JSX.Element => {
|
2024-02-29 03:42:14 +03:00
|
|
|
const { brainUsers, fetchBrainUsers } = useBrainUsers(brainId);
|
2023-07-18 19:28:44 +03:00
|
|
|
|
2023-07-19 14:36:23 +03:00
|
|
|
if (brainUsers.length === 0) {
|
2024-02-29 03:42:14 +03:00
|
|
|
return (
|
|
|
|
<MessageInfoBox
|
|
|
|
type="info"
|
|
|
|
content="You're the only user to have access to this brain."
|
|
|
|
/>
|
|
|
|
);
|
2023-07-18 19:28:44 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
2023-07-19 14:36:23 +03:00
|
|
|
{brainUsers.map((subscription) => (
|
2023-07-18 19:28:44 +03:00
|
|
|
<BrainUser
|
|
|
|
key={subscription.email}
|
|
|
|
email={subscription.email}
|
2023-07-20 19:17:55 +03:00
|
|
|
role={subscription.role}
|
2023-07-18 19:28:44 +03:00
|
|
|
brainId={brainId}
|
|
|
|
fetchBrainUsers={fetchBrainUsers}
|
|
|
|
/>
|
|
|
|
))}
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
};
|