diff --git a/frontend/app/components/Client/Users/UsersView.tsx b/frontend/app/components/Client/Users/UsersView.tsx index cb57a9ec6..5b207a468 100644 --- a/frontend/app/components/Client/Users/UsersView.tsx +++ b/frontend/app/components/Client/Users/UsersView.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { useEffect } from 'react'; import UserList from './components/UserList'; import { PageTitle } from 'UI'; import { useStore } from 'App/mstore'; @@ -6,8 +6,15 @@ import { useObserver } from 'mobx-react-lite'; import UserSearch from './components/UserSearch'; function UsersView(props) { - const { userStore } = useStore(); + const { userStore, roleStore } = useStore(); const userCount = useObserver(() => userStore.list.length); + const roles = useObserver(() => roleStore.list); + + useEffect(() => { + if (roles.length === 0) { + roleStore.fetchRoles(); + } + }, []); return (
diff --git a/frontend/app/components/Client/Users/components/UserForm/UserForm.tsx b/frontend/app/components/Client/Users/components/UserForm/UserForm.tsx new file mode 100644 index 000000000..b47a38d50 --- /dev/null +++ b/frontend/app/components/Client/Users/components/UserForm/UserForm.tsx @@ -0,0 +1,129 @@ +import React from 'react'; +import { Input, CopyButton, Button, Select } from 'UI' +import cn from 'classnames'; +import { useStore } from 'App/mstore'; +import { useObserver } from 'mobx-react-lite'; +import { useModal } from 'App/components/Modal'; + +interface Props { + isSmtp?: boolean; + isEnterprise?: boolean; +} +function UserForm(props: Props) { + const { isSmtp = false, isEnterprise = false } = props; + const isSaving = false; + const { hideModal } = useModal(); + const { userStore, roleStore } = useStore(); + const user: any = useObserver(() => userStore.instance); + const roles = useObserver(() => roleStore.list.map(r => ({ label: r.name, value: r.roleId }))); + console.log('roles', roles) + + const onChangeCheckbox = (e: any) => { + user.updateKey('isAdmin', !user.isAdmin); + } + + const onSave = () => { + } + + const write = ({ target: { name, value } }) => { + user.updateKey(name, value); + } + return useObserver(() => ( +
+
+

{`${user.exists() ? 'Update' : 'Invite'} User`}

+
+
+
+ + +
+ +
+ + +
+ { !isSmtp && +
+ SMTP is not configured (see here how to set it up). You can still add new users, but you’d have to manually copy then send them the invitation link. +
+ } +
+ +
+ + { !isEnterprise && ( +
+ +