2023-07-18 19:28:44 +03:00
|
|
|
import { UUID } from "crypto";
|
2023-08-07 15:13:41 +03:00
|
|
|
import { useTranslation } from "react-i18next";
|
2023-07-18 19:28:44 +03:00
|
|
|
|
2023-07-19 18:13:02 +03:00
|
|
|
import { BrainUser } from "./components";
|
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 => {
|
2023-08-07 15:13:41 +03:00
|
|
|
const { t } = useTranslation(["translation","config"]);
|
2023-07-19 14:36:23 +03:00
|
|
|
const { brainUsers, fetchBrainUsers, isFetchingBrainUsers } =
|
|
|
|
useBrainUsers(brainId);
|
2023-07-18 19:28:44 +03:00
|
|
|
if (isFetchingBrainUsers) {
|
2023-08-07 15:13:41 +03:00
|
|
|
return <p className="text-gray-500">{t("loading")}</p>;
|
2023-07-18 19:28:44 +03:00
|
|
|
}
|
|
|
|
|
2023-07-19 14:36:23 +03:00
|
|
|
if (brainUsers.length === 0) {
|
2023-08-07 15:13:41 +03:00
|
|
|
return <p className="text-gray-500">{t("noUser",{ns:'config'})}</p>;
|
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}
|
|
|
|
/>
|
|
|
|
))}
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
};
|