diff --git a/app/containers/User/ManageBceidUserTable.tsx b/app/containers/User/ManageBceidUserTable.tsx new file mode 100644 index 0000000000..69c17d6c58 --- /dev/null +++ b/app/containers/User/ManageBceidUserTable.tsx @@ -0,0 +1,81 @@ +import React from "react"; +import { graphql, createFragmentContainer } from "react-relay"; +import { ManageBceidUserTable_query } from "ManageBceidUserTable_query.graphql"; +import ManageBceidUserTableRow from "./ManageBceidUserTableRow"; +import { + TableFilter, + TextFilter, + DisplayOnlyFilter, + NoHeaderFilter, +} from "components/FilterableTable/Filters"; +import FilterableTable from "components/FilterableTable/FilterableTable"; + +interface Props { + query: ManageBceidUserTable_query; +} + +const filters: TableFilter[] = [ + new TextFilter("First Name", "first_name"), + new TextFilter("Last Name", "last_name"), + new TextFilter("Email", "email_address"), + new DisplayOnlyFilter("View Access Requests"), + new NoHeaderFilter(), +]; + +export const ManageBceidUserTableComponent: React.FunctionComponent = ( + props +) => { + const { edges, totalCount } = props.query.allCiipUsers; + + console.log(edges); + + const body = ( + + {edges.map((edge) => ( + + ))} + + ); + return ( + + ); +}; + +export default createFragmentContainer(ManageBceidUserTableComponent, { + query: graphql` + fragment ManageBceidUserTable_query on Query + @argumentDefinitions( + first_name: { type: "String" } + last_name: { type: "String" } + email_address: { type: "String" } + order_by: { type: "[CiipUsersOrderBy!]" } + pageSize: { type: "Int" } + offset: { type: "Int" } + ) { + allCiipUsers( + first: $pageSize + offset: $offset + filter: { + uuid: { notIncludesInsensitive: "idir" } + firstName: { includesInsensitive: $first_name } + lastName: { includesInsensitive: $last_name } + emailAddress: { includesInsensitive: $email_address } + } + orderBy: $order_by + ) { + edges { + node { + id + ...ManageBceidUserTableRow_user + } + } + totalCount + } + } + `, +}); diff --git a/app/containers/User/ManageBceidUserTableRow.tsx b/app/containers/User/ManageBceidUserTableRow.tsx new file mode 100644 index 0000000000..8aa4505e9f --- /dev/null +++ b/app/containers/User/ManageBceidUserTableRow.tsx @@ -0,0 +1,77 @@ +import React from "react"; +import { Button } from "react-bootstrap"; +import { graphql, createFragmentContainer, RelayProp } from "react-relay"; +import { ManageBceidUserTableRow_user } from "ManageBceidUserTableRow_user.graphql"; +import updateUserMutation from "mutations/user/updateUserMutation"; +import Link from "next/link"; + +interface Props { + relay: RelayProp; + user: ManageBceidUserTableRow_user; + key: string; +} +export const ManageBceidUserTableRowComponent: React.FunctionComponent = ( + props +) => { + const { user } = props; + + const handleChange = async () => { + const variables = { + input: { + id: user.id, + ciipUserPatch: { + allowUuidUpdate: !user.allowUuidUpdate, + }, + }, + }; + await updateUserMutation(props.relay.environment, variables); + }; + + const url = `/analyst/organisation-requests?filterArgs=${encodeURIComponent( + `{"user_id":${user.rowId}}` + )}`; + + return ( + + {user.firstName} + {user.lastName} + {user.emailAddress} + + + + Access Requests + + + + + {user.allowUuidUpdate ? ( + + ) : ( + + )} + + + ); +}; + +export default createFragmentContainer(ManageBceidUserTableRowComponent, { + user: graphql` + fragment ManageBceidUserTableRow_user on CiipUser { + id + rowId + firstName + lastName + emailAddress + allowUuidUpdate + } + `, +});