From 37bf68f41b3bd80b114c0b089c1adac7eca32f06 Mon Sep 17 00:00:00 2001 From: Davit Date: Sun, 30 Jun 2024 20:03:03 +0400 Subject: [PATCH] org admin in the UI --- .../AddUserToOrganization/index.js | 4 ++- .../AddUserToOrganization/logic.js | 24 +++++++++++++-- src/components/Organizations/Manage/index.js | 29 +++++++++++++------ .../Organizations/Organization/index.js | 16 +++++----- 4 files changed, 51 insertions(+), 22 deletions(-) diff --git a/src/components/Organizations/AddUserToOrganization/index.js b/src/components/Organizations/AddUserToOrganization/index.js index 06b2c859..06bf9ea9 100644 --- a/src/components/Organizations/AddUserToOrganization/index.js +++ b/src/components/Organizations/AddUserToOrganization/index.js @@ -12,7 +12,9 @@ import { NewUser } from './Styles'; export const ADD_USER_MUTATION = gql` mutation AddUserToOrganization($email: String!, $organization: Int!, $owner: Boolean, $admin: Boolean) { - addUserToOrganization(input: { user: { email: $email }, organization: $organization, owner: $owner, admin: $admin }) { + addUserToOrganization( + input: { user: { email: $email }, organization: $organization, owner: $owner, admin: $admin } + ) { id } } diff --git a/src/components/Organizations/AddUserToOrganization/logic.js b/src/components/Organizations/AddUserToOrganization/logic.js index 4fc22e1a..b33dd9d6 100644 --- a/src/components/Organizations/AddUserToOrganization/logic.js +++ b/src/components/Organizations/AddUserToOrganization/logic.js @@ -10,8 +10,8 @@ const withInputHandlers = withHandlers({ setInputValue(event.target.value), }); -const withCheckboxValue = withState('checkboxValueOwner', 'setCheckboxValueOwner', false); -const withCheckboxhandler = withHandlers({ +const withCheckboxValueOwner = withState('checkboxValueOwner', 'setCheckboxValueOwner', false); +const withCheckboxhandlerOwner = withHandlers({ setCheckboxValueOwner: ({ setCheckboxValueOwner }) => event => { @@ -19,6 +19,24 @@ const withCheckboxhandler = withHandlers({ }, }); +const withCheckboxValueAdmin = withState('checkboxValueAdmin', 'setCheckboxValueAdmin', false); + +const withCheckboxHandlerAdmin = withHandlers({ + setCheckboxValueAdmin: + ({ setCheckboxValueAdmin }) => + event => { + setCheckboxValueAdmin(event.target.checked); + }, +}); + const withSelectedRole = withState('selectedRole', 'setSelectedRole', null); -export default compose(withInputValue, withInputHandlers, withCheckboxValue, withCheckboxhandler, withSelectedRole); +export default compose( + withInputValue, + withInputHandlers, + withCheckboxValueOwner, + withCheckboxhandlerOwner, + withCheckboxValueAdmin, + withCheckboxHandlerAdmin, + withSelectedRole +); diff --git a/src/components/Organizations/Manage/index.js b/src/components/Organizations/Manage/index.js index 176a993f..d4b0a744 100644 --- a/src/components/Organizations/Manage/index.js +++ b/src/components/Organizations/Manage/index.js @@ -35,6 +35,7 @@ const Manage = ({ users = [], organization, organizationName, refetch }) => { const [dynamicUsers, setDynamicUsers] = useState(users); const [editModalOpen, setEditModalOpen] = useState(false); const [selectedUserOwner, setSelectedUserOwner] = useState(false); + const [selectedUserAdmin, setSelectedUserAdmin] = useState(false); const closeUserModal = () => { setSelectedUser(''); @@ -101,16 +102,14 @@ const Manage = ({ users = [], organization, organizationName, refetch }) => { ORG OWNER + ) : admin ? ( + + ORG ADMIN + ) : ( - admin ? ( - - ORG ADMIN - - ) : ( - - ORG VIEWER - - ) + + ORG VIEWER + )} ); @@ -129,6 +128,7 @@ const Manage = ({ users = [], organization, organizationName, refetch }) => { setSelectedUser(user?.id); setEditModalOpen(true); setSelectedUserOwner(user.owner); + setSelectedUserAdmin(user.admin); }} > @@ -167,6 +167,16 @@ const Manage = ({ users = [], organization, organizationName, refetch }) => { onChange={() => setSelectedUserOwner(!selectedUserOwner)} /> +