quivr/frontend/app/studio/[brainId]/BrainManagementTabs/components/PeopleTab/PeopleTab.tsx
Antoine Dewez 8fc8c5e3ed
fix(frontend): revamp quivr studio (#2274)
# Description

Please include a summary of the changes and the related issue. Please
also include relevant motivation and context.

## Checklist before requesting a review

Please delete options that are not relevant.

- [ ] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my code
- [ ] I have commented hard-to-understand areas
- [ ] I have ideally added tests that prove my fix is effective or that
my feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] Any dependent changes have been merged

## Screenshots (if appropriate):
2024-02-28 16:42:14 -08:00

71 lines
2.2 KiB
TypeScript

"use client";
import { UUID } from "crypto";
import { BrainUsers } from "@/app/studio/[brainId]/BrainManagementTabs/components/PeopleTab/BrainUsers/BrainUsers";
import { UserToInvite } from "@/app/studio/[brainId]/BrainManagementTabs/components/PeopleTab/BrainUsers/components/UserToInvite/UserToInvite";
import QuivrButton from "@/lib/components/ui/QuivrButton/QuivrButton";
import { useShareBrain } from "@/lib/hooks/useShareBrain";
import styles from "./PeopleTab.module.scss";
type ShareBrainModalProps = {
brainId: UUID;
};
export const PeopleTab = ({ brainId }: ShareBrainModalProps): JSX.Element => {
const {
roleAssignations,
updateRoleAssignation,
removeRoleAssignation,
inviteUsers,
addNewRoleAssignationRole,
sendingInvitation,
canAddNewRow,
} = useShareBrain(brainId);
return (
<div className={styles.people_tab_wrapper}>
<form
onSubmit={(event) => {
event.preventDefault();
void inviteUsers();
}}
>
<div className={styles.section_wrapper}>
<span className={styles.section_title}>Invite new users</span>
{roleAssignations.map((roleAssignation, index) => (
<UserToInvite
key={roleAssignation.id}
onChange={updateRoleAssignation(index)}
removeCurrentInvitation={removeRoleAssignation(index)}
roleAssignation={roleAssignation}
/>
))}
<div className={styles.buttons_wrapper}>
<QuivrButton
onClick={addNewRoleAssignationRole}
disabled={sendingInvitation || !canAddNewRow}
label="Add new user"
color="primary"
iconName="add"
></QuivrButton>
<QuivrButton
isLoading={sendingInvitation}
disabled={roleAssignations.length === 0}
label="Invite"
color="primary"
iconName="share"
onClick={inviteUsers}
></QuivrButton>
</div>
</div>
</form>
<div className={styles.section_wrapper}>
<span className={styles.section_title}>Users with access</span>
<BrainUsers brainId={brainId} />
</div>
</div>
);
};