From eaaf0b025de1f4e6e16d3f0d11e7daa0cbb954c8 Mon Sep 17 00:00:00 2001 From: Ariunzaya <91462097+ariunzayarin@users.noreply.github.com> Date: Wed, 27 Sep 2023 21:41:01 +0800 Subject: [PATCH] fix(settings): structure (#4647) --- .../settings/main/components/Settings.tsx | 2 +- .../settings/team/components/branch/Form.tsx | 26 ++-- .../team/components/branch/MainList.tsx | 128 ++++++++++-------- .../components/common/SettingsSideBar.tsx | 45 ++++-- .../team/components/department/Form.tsx | 26 ++-- .../team/components/department/MainList.tsx | 125 +++++++++-------- .../team/components/structure/Form.tsx | 12 +- .../team/components/structure/Settings.tsx | 3 +- .../team/components/structure/View.tsx | 27 ++-- .../settings/team/components/unit/Form.tsx | 10 +- .../team/components/unit/MainList.tsx | 98 ++++++++------ .../team/containers/branch/MainList.tsx | 10 +- .../team/containers/common/SettingSideBar.tsx | 80 +++++++++++ .../team/containers/department/MainList.tsx | 1 + .../team/containers/structure/Box.tsx | 9 +- .../settings/team/containers/unit/Form.tsx | 6 +- .../team/containers/unit/MainList.tsx | 10 +- .../src/modules/settings/team/styles.ts | 32 +++-- .../src/components/HeaderDescription.tsx | 2 +- packages/erxes-ui/src/layout/styles.ts | 7 +- 20 files changed, 417 insertions(+), 242 deletions(-) create mode 100644 packages/core-ui/src/modules/settings/team/containers/common/SettingSideBar.tsx diff --git a/packages/core-ui/src/modules/settings/main/components/Settings.tsx b/packages/core-ui/src/modules/settings/main/components/Settings.tsx index 3da156269bb..df566c29595 100644 --- a/packages/core-ui/src/modules/settings/main/components/Settings.tsx +++ b/packages/core-ui/src/modules/settings/main/components/Settings.tsx @@ -145,7 +145,7 @@ class Settings extends React.PureComponent { )} {this.renderBox( 'Structure', - '/images/icons/erxes-23.svg', + '/images/icons/erxes-15.svg', '/settings/structure', 'usersAll', teamPermissions diff --git a/packages/core-ui/src/modules/settings/team/components/branch/Form.tsx b/packages/core-ui/src/modules/settings/team/components/branch/Form.tsx index 5049fc427da..ecb2bda796f 100644 --- a/packages/core-ui/src/modules/settings/team/components/branch/Form.tsx +++ b/packages/core-ui/src/modules/settings/team/components/branch/Form.tsx @@ -9,7 +9,6 @@ import { __ } from 'modules/common/utils'; import { IBranch } from '@erxes/ui/src/team/types'; import SelectTeamMembers from '@erxes/ui/src/team/containers/SelectTeamMembers'; import ContactInfoForm from '../common/ContactInfoForm'; -import SelectBranches from '@erxes/ui/src/team/containers/SelectBranches'; type Props = { renderButton: (props: IButtonMutateProps) => JSX.Element; @@ -19,7 +18,7 @@ type Props = { }; export default function BranchForm(props: Props) { - const { closeModal, renderButton } = props; + const { closeModal, renderButton, branches } = props; const object = props.branch || ({} as IBranch); const [userIds, setUserIds] = useState( @@ -75,6 +74,14 @@ export default function BranchForm(props: Props) { const renderContent = (formProps: IFormProps) => { const { values, isSubmitted } = formProps; + const generateOptions = () => { + return branches.map(branch => ( + + {branch.title} + + )); + }; + return ( <> @@ -120,13 +127,16 @@ export default function BranchForm(props: Props) { {__('Parent')} - + componentClass="select" + defaultValue={parentId || null} + onChange={onChangeParent} + > + + {generateOptions()} + {__('Team Members')} diff --git a/packages/core-ui/src/modules/settings/team/components/branch/MainList.tsx b/packages/core-ui/src/modules/settings/team/components/branch/MainList.tsx index d8cca1e0789..6a4fa2605cf 100644 --- a/packages/core-ui/src/modules/settings/team/components/branch/MainList.tsx +++ b/packages/core-ui/src/modules/settings/team/components/branch/MainList.tsx @@ -2,7 +2,6 @@ import { Button, ModalTrigger, BarItems, - HeaderDescription, FormControl, Table, Wrapper, @@ -13,13 +12,15 @@ import { } from '@erxes/ui/src'; import { BranchesMainQueryResponse, IBranch } from '@erxes/ui/src/team/types'; import React from 'react'; -import SettingsSideBar from '../common/SettingsSideBar'; +import SettingsSideBar from '../../containers/common/SettingSideBar'; import Form from '../../containers/branch/Form'; import { generateTree } from '../../utils'; import { queries } from '@erxes/ui/src/team/graphql'; import { gql } from '@apollo/client'; import { generatePaginationParams } from '@erxes/ui/src/utils/router'; -import { DescriptionContentRow } from '../common/DescriptionContentRow'; +import ActionButtons from '@erxes/ui/src/components/ActionButtons'; +import Tip from '@erxes/ui/src/components/Tip'; +import Icon from '@erxes/ui/src/components/Icon'; type Props = { listQuery: BranchesMainQueryResponse; @@ -55,8 +56,24 @@ class MainList extends React.Component { } ]; + remove = (_id?: string) => { + if (_id) { + this.props.deleteBranches([_id], () => + this.setState({ selectedItems: [] }) + ); + } else { + this.props.deleteBranches(this.state.selectedItems, () => + this.setState({ selectedItems: [] }) + ); + } + }; + renderForm() { - const trigger = {__('Add Branch')}; + const trigger = ( + + {__('Add Branch')} + + ); const content = ({ closeModal }) => ( { const onclick = e => { e.stopPropagation(); }; + const trigger = ( + + + + + + ); + + return ( { {branch?.parent?.title || ''} {__(branch.address.replace(/\n/g, ''))} {branch.userCount} + + + ( + + )} + trigger={trigger} + /> + + this.remove(branch._id)} + icon="times-circle" + /> + + + ); - return ( - ( - - )} - trigger={trigger} - /> - ); } renderContent() { @@ -169,16 +204,6 @@ class MainList extends React.Component { this.setState({ selectedItems: [] }); }; - const generateList = () => { - const list = branches.map(branch => { - if (!branches.find(dep => dep._id === branch.parentId)) { - branch.parentId = null; - } - return branch; - }); - return list; - }; - return ( @@ -195,10 +220,14 @@ class MainList extends React.Component { {__('Parent')} {__('Address')} {__('Team member count')} + {__('Actions')} - {generateTree(generateList(), null, (branch, level) => + {generateTree(branches, null, (branch, level) => + this.renderRow(branch, level) + )} + {generateTree(branches, '', (branch, level) => this.renderRow(branch, level) )} @@ -206,45 +235,31 @@ class MainList extends React.Component { ); } - deleteBranches() { - const {} = this.state; - } - render() { - const { listQuery, deleteBranches } = this.props; + const { listQuery } = this.props; - const { totalCount, totalUsersCount } = listQuery.branchesMain; + const { totalCount } = listQuery.branchesMain; const { selectedItems } = this.state; - const remove = () => { - deleteBranches(selectedItems, () => this.setState({ selectedItems: [] })); - }; - const rightActionBar = ( {this.renderSearch()} - {!!selectedItems.length && ( - - {__(`Remove ${selectedItems.length}`)} - - )} {this.renderForm()} ); - const leftActionBar = ( - + const leftActionBar = selectedItems.length > 0 && ( + this.remove()} + > + Remove + ); + return ( { /> } actionBar={ - + } content={ { } leftSidebar={} footer={} + hasBorder={true} /> ); } diff --git a/packages/core-ui/src/modules/settings/team/components/common/SettingsSideBar.tsx b/packages/core-ui/src/modules/settings/team/components/common/SettingsSideBar.tsx index e0c9893fcab..e946ac74bae 100644 --- a/packages/core-ui/src/modules/settings/team/components/common/SettingsSideBar.tsx +++ b/packages/core-ui/src/modules/settings/team/components/common/SettingsSideBar.tsx @@ -3,30 +3,47 @@ import SidebarHeader from '@erxes/ui-settings/src/common/components/SidebarHeade import LeftSidebar from '@erxes/ui/src/layout/components/Sidebar'; import { SidebarList, __ } from '@erxes/ui/src'; import { Link } from 'react-router-dom'; +import { SidebarCounter, FieldStyle } from '@erxes/ui/src/layout/styles'; -function ListItem(url, text) { +function ListItem(url, text, totalCount?) { return ( - {__(text)} + {__(text)} + {totalCount} ); } -export default function SettingsSideBar() { - return ( - } hasBorder> - {__('Structures')} - - {ListItem('/settings/structure', 'Structure')} - {ListItem('/settings/branches', 'Branches')} - {ListItem('/settings/departments', 'Departments')} - {ListItem('/settings/units', 'Units')} - - - ); +type Props = { + branchTotalCount: number; + unitTotalCount: number; + departmentTotalCount: number; +}; + +export default class SettingsSideBar extends React.Component { + render() { + return ( + } hasBorder={true}> + + {ListItem('/settings/structure', 'Structure')} + {ListItem( + '/settings/branches', + 'Branches', + this.props.branchTotalCount + )} + {ListItem( + '/settings/departments', + 'Departments', + this.props.departmentTotalCount + )} + {ListItem('/settings/units', 'Units', this.props.unitTotalCount)} + + + ); + } } diff --git a/packages/core-ui/src/modules/settings/team/components/department/Form.tsx b/packages/core-ui/src/modules/settings/team/components/department/Form.tsx index bd873cb1ee9..898f27a1289 100644 --- a/packages/core-ui/src/modules/settings/team/components/department/Form.tsx +++ b/packages/core-ui/src/modules/settings/team/components/department/Form.tsx @@ -18,7 +18,7 @@ type Props = { }; export default function DepartmentForm(props: Props) { - const { closeModal, renderButton } = props; + const { closeModal, renderButton, departments } = props; const object = props.department || ({} as any); const [userIds, setUserIds] = useState( @@ -61,6 +61,14 @@ export default function DepartmentForm(props: Props) { const renderContent = (formProps: IFormProps) => { const { values, isSubmitted } = formProps; + const generateOptions = () => { + return departments.map(branch => ( + + {branch.title} + + )); + }; + return ( <> @@ -104,14 +112,16 @@ export default function DepartmentForm(props: Props) { {__('Parent')} - - {/* /> */} + componentClass="select" + defaultValue={parentId || null} + onChange={onChangeParent} + > + + {generateOptions()} + {__('Team Members')} diff --git a/packages/core-ui/src/modules/settings/team/components/department/MainList.tsx b/packages/core-ui/src/modules/settings/team/components/department/MainList.tsx index 4b4ba15e1ff..e3883b4dbde 100644 --- a/packages/core-ui/src/modules/settings/team/components/department/MainList.tsx +++ b/packages/core-ui/src/modules/settings/team/components/department/MainList.tsx @@ -2,7 +2,6 @@ import { Button, ModalTrigger, BarItems, - HeaderDescription, FormControl, DataWithLoader, Wrapper, @@ -17,12 +16,15 @@ import { IDepartment } from '@erxes/ui/src/team/types'; import React from 'react'; -import SettingsSideBar from '../common/SettingsSideBar'; +import SettingsSideBar from '../../containers/common/SettingSideBar'; import Form from '../../containers/department/Form'; import { queries } from '@erxes/ui/src/team/graphql'; import { gql } from '@apollo/client'; import { generatePaginationParams } from '@erxes/ui/src/utils/router'; -import { DescriptionContentRow } from '../common/DescriptionContentRow'; +import Tip from '@erxes/ui/src/components/Tip'; +import Icon from '@erxes/ui/src/components/Icon'; +import ActionButtons from '@erxes/ui/src/components/ActionButtons'; + type Props = { listQuery: DepartmentsMainQueryResponse; queryParams: any; @@ -56,8 +58,24 @@ class MainList extends React.Component { } ]; + remove = (_id?: string) => { + if (_id) { + this.props.deleteDepartments([_id], () => + this.setState({ selectedItems: [] }) + ); + } else { + this.props.deleteDepartments(this.state.selectedItems, () => + this.setState({ selectedItems: [] }) + ); + } + }; + renderForm() { - const trigger = {__('Add Department')}; + const trigger = ( + + {__('Add Department')} + + ); const content = ({ closeModal }) => ( { }; const trigger = ( + + + + + + ); + + return ( { {__(department.title)} {__(department?.supervisor?.email || '-')} {department.userCount} + + + ( + + )} + trigger={trigger} + /> + + this.remove(department._id)} + icon="times-circle" + /> + + + ); - - return ( - ( - - )} - trigger={trigger} - /> - ); } renderContent() { @@ -174,16 +208,6 @@ class MainList extends React.Component { this.setState({ selectedItems: [] }); }; - const generateList = () => { - const list = departments.map(department => { - if (!departments.find(dep => dep._id === department.parentId)) { - department.parentId = null; - } - return department; - }); - return list; - }; - return ( @@ -199,10 +223,14 @@ class MainList extends React.Component { {__('Title')} {__('Supervisor')} {__('Team member count')} + {__('Actions')} - {generateTree(generateList(), null, (department, level) => { + {generateTree(departments, null, (department, level) => { + return this.renderRow(department, level); + })} + {generateTree(departments, '', (department, level) => { return this.renderRow(department, level); })} @@ -211,42 +239,30 @@ class MainList extends React.Component { } render() { - const { listQuery, deleteDepartments } = this.props; + const { listQuery } = this.props; - const { totalCount, totalUsersCount } = listQuery.departmentsMain; + const { totalCount } = listQuery.departmentsMain; const { selectedItems } = this.state; - const remove = () => { - deleteDepartments(selectedItems, () => - this.setState({ selectedItems: [] }) - ); - }; - const rightActionBar = ( {this.renderSearch()} - {!!selectedItems.length && ( - - {__(`Remove ${selectedItems.length}`)} - - )} {this.renderForm()} ); - const leftActionBar = ( - + const leftActionBar = selectedItems.length > 0 && ( + this.remove()} + > + Remove + ); + return ( { } leftSidebar={} footer={} + hasBorder={true} /> ); } diff --git a/packages/core-ui/src/modules/settings/team/components/structure/Form.tsx b/packages/core-ui/src/modules/settings/team/components/structure/Form.tsx index bc9afb664bf..3e61dd5083a 100644 --- a/packages/core-ui/src/modules/settings/team/components/structure/Form.tsx +++ b/packages/core-ui/src/modules/settings/team/components/structure/Form.tsx @@ -11,9 +11,10 @@ import { ModalFooter } from '@erxes/ui/src/styles/main'; import { __ } from 'modules/common/utils'; import { IStructure } from '@erxes/ui/src/team/types'; import SelectTeamMembers from '@erxes/ui/src/team/containers/SelectTeamMembers'; -import Box from '@erxes/ui/src/components/Box'; +import Wrapper from '@erxes/ui/src/layout/components/Wrapper'; import Button from '@erxes/ui/src/components/Button'; import ContactInfoForm from '../common/ContactInfoForm'; +import { Title } from '@erxes/ui-settings/src/styles'; type Props = { renderButton: (props: IButtonMutateProps) => JSX.Element; @@ -136,8 +137,13 @@ export default function StructureForm(props: Props) { }; return ( - + <> + {__('Structure')}} + wideSpacing={true} + /> - + > ); } diff --git a/packages/core-ui/src/modules/settings/team/components/structure/Settings.tsx b/packages/core-ui/src/modules/settings/team/components/structure/Settings.tsx index 3f50a7b2523..dbc0999a63f 100644 --- a/packages/core-ui/src/modules/settings/team/components/structure/Settings.tsx +++ b/packages/core-ui/src/modules/settings/team/components/structure/Settings.tsx @@ -1,7 +1,7 @@ import { Wrapper, __ } from '@erxes/ui/src'; import React from 'react'; import BoxContainer from '../../containers/structure/Box'; -import SettingsSideBar from '../common/SettingsSideBar'; +import SettingsSideBar from '../../containers/common/SettingSideBar'; export default function Structure() { return ( @@ -17,6 +17,7 @@ export default function Structure() { } content={} leftSidebar={} + hasBorder={true} /> ); } diff --git a/packages/core-ui/src/modules/settings/team/components/structure/View.tsx b/packages/core-ui/src/modules/settings/team/components/structure/View.tsx index 945d4d9d636..bf744c67408 100644 --- a/packages/core-ui/src/modules/settings/team/components/structure/View.tsx +++ b/packages/core-ui/src/modules/settings/team/components/structure/View.tsx @@ -3,9 +3,11 @@ import { SidebarCounter } from '@erxes/ui/src/layout/styles'; import { IStructure } from '@erxes/ui/src/team/types'; import { IUser } from '@erxes/ui/src/auth/types'; import { __, readFile } from 'modules/common/utils'; -import Box from '@erxes/ui/src/components/Box'; import Icon from '@erxes/ui/src/components/Icon'; -import { StructureList } from '../../styles'; +import { StructureList, StructureEditButton } from '../../styles'; +import { Title } from '@erxes/ui-settings/src/styles'; +import Wrapper from '@erxes/ui/src/layout/components/Wrapper'; +import _ from 'lodash'; type Props = { structure: IStructure; @@ -14,9 +16,9 @@ type Props = { export default function View({ structure, showEdit }: Props) { const edit = ( - - - + + + ); const renderRow = (name: string, value: any, nowrap?: boolean) => { @@ -38,12 +40,13 @@ export default function View({ structure, showEdit }: Props) { : supervisor.email; return ( - + <> + {__('Structure')}} + right={edit} + wideSpacing={true} + /> {renderRow('Name', title)} {renderRow('Description', description, true)} @@ -63,6 +66,6 @@ export default function View({ structure, showEdit }: Props) { )} - + > ); } diff --git a/packages/core-ui/src/modules/settings/team/components/unit/Form.tsx b/packages/core-ui/src/modules/settings/team/components/unit/Form.tsx index e718f51b229..9bcb3079ce8 100644 --- a/packages/core-ui/src/modules/settings/team/components/unit/Form.tsx +++ b/packages/core-ui/src/modules/settings/team/components/unit/Form.tsx @@ -80,13 +80,17 @@ export default function DepartmentForm(props: Props) { {...formProps} name="description" defaultValue={object.description} - autoFocus={true} componentClass="textarea" /> - {__('Code')} - + {__('Code')} + {__('Supervisor')} diff --git a/packages/core-ui/src/modules/settings/team/components/unit/MainList.tsx b/packages/core-ui/src/modules/settings/team/components/unit/MainList.tsx index 47d0db6f37d..b9a0733feba 100644 --- a/packages/core-ui/src/modules/settings/team/components/unit/MainList.tsx +++ b/packages/core-ui/src/modules/settings/team/components/unit/MainList.tsx @@ -8,14 +8,15 @@ import { Table, Wrapper, __, - ModalTrigger, - HeaderDescription + ModalTrigger } from '@erxes/ui/src'; import { IUnit, UnitsMainQueryResponse } from '@erxes/ui/src/team/types'; import React from 'react'; -import SettingsSideBar from '../common/SettingsSideBar'; +import SettingsSideBar from '../../containers/common/SettingSideBar'; import Form from '../../containers/unit/Form'; -import { DescriptionContentRow } from '../common/DescriptionContentRow'; +import ActionButtons from '@erxes/ui/src/components/ActionButtons'; +import Tip from '@erxes/ui/src/components/Tip'; +import Icon from '@erxes/ui/src/components/Icon'; type Props = { listQuery: UnitsMainQueryResponse; @@ -40,8 +41,22 @@ class MainList extends React.Component { }; } + remove = (_id?: string) => { + if (_id) { + this.props.deleteUnits([_id], () => this.setState({ selectedItems: [] })); + } else { + this.props.deleteUnits(this.state.selectedItems, () => + this.setState({ selectedItems: [] }) + ); + } + }; + renderForm() { - const trigger = {__('Add Unit')}; + const trigger = ( + + {__('Add Unit')} + + ); const content = ({ closeModal }) => ; @@ -104,6 +119,14 @@ class MainList extends React.Component { }; const trigger = ( + + + + + + ); + + return ( { {__(unit?.supervisor?.email)} {__(unit?.department?.title || '')} {unit.userIds?.length || 0} + + + ( + + )} + trigger={trigger} + /> + + this.remove(unit._id)} + icon="times-circle" + /> + + + ); - - return ( - ( - - )} - trigger={trigger} - /> - ); } renderContent() { @@ -164,6 +195,7 @@ class MainList extends React.Component { {__('Supervisor')} {__('Department')} {__('Team member count')} + {__('Actions')} {(units || []).map(unit => this.renderRow(unit))} @@ -171,39 +203,28 @@ class MainList extends React.Component { ); } render() { - const { listQuery, deleteUnits } = this.props; + const { listQuery } = this.props; - const { totalCount, totalUsersCount } = listQuery.unitsMain; + const { totalCount } = listQuery.unitsMain; const { selectedItems } = this.state; - const remove = () => { - deleteUnits(selectedItems, () => this.setState({ selectedItems: [] })); - }; - const rightActionBar = ( {this.renderSearch()} - {!!selectedItems.length && ( - - {__('Remove')} - - )} {this.renderForm()} ); - const leftActionBar = ( - + const leftActionBar = selectedItems.length > 0 && ( + this.remove()} + > + Remove + ); return ( @@ -231,6 +252,7 @@ class MainList extends React.Component { } leftSidebar={} footer={} + hasBorder={true} /> ); } diff --git a/packages/core-ui/src/modules/settings/team/containers/branch/MainList.tsx b/packages/core-ui/src/modules/settings/team/containers/branch/MainList.tsx index 68d90d6e7ba..a72290aecea 100644 --- a/packages/core-ui/src/modules/settings/team/containers/branch/MainList.tsx +++ b/packages/core-ui/src/modules/settings/team/containers/branch/MainList.tsx @@ -44,15 +44,7 @@ class MainList extends React.Component { .mutate({ mutation: gql(mutations.branchesRemove), variables: { ids }, - refetchQueries: [ - { - query: gql(queries.branches), - variables: { - withoutUserFilter: true, - searchValue: undefined - } - } - ] + refetchQueries: ['branchesMain'] }) .then(() => { callback(); diff --git a/packages/core-ui/src/modules/settings/team/containers/common/SettingSideBar.tsx b/packages/core-ui/src/modules/settings/team/containers/common/SettingSideBar.tsx new file mode 100644 index 00000000000..d604848d241 --- /dev/null +++ b/packages/core-ui/src/modules/settings/team/containers/common/SettingSideBar.tsx @@ -0,0 +1,80 @@ +import React from 'react'; +import * as compose from 'lodash.flowright'; +import { withProps } from '@erxes/ui/src/utils/core'; +import { graphql } from '@apollo/client/react/hoc'; +import { gql } from '@apollo/client'; +import { queries } from '@erxes/ui/src/team/graphql'; +import { + BranchesMainQueryResponse, + DepartmentsMainQueryResponse, + UnitsMainQueryResponse +} from '@erxes/ui/src/team/types'; +import { EmptyState, Spinner } from '@erxes/ui/src'; +import SettingsSideBar from '../../components/common/SettingsSideBar'; + +type FinalProps = { + branchListQuery: BranchesMainQueryResponse; + unitListQuery: UnitsMainQueryResponse; + departmentListQuery: DepartmentsMainQueryResponse; +}; + +class SettingsSideBarContainer extends React.Component { + render() { + const { branchListQuery, unitListQuery, departmentListQuery } = this.props; + + if ( + branchListQuery.loading || + unitListQuery.loading || + departmentListQuery.loading + ) { + return ; + } + + if ( + branchListQuery.error || + unitListQuery.error || + departmentListQuery.error + ) { + return ( + + ); + } + + return ( + + ); + } +} + +export default withProps<{}>( + compose( + graphql<{}>(gql(queries.branchesMain), { + name: 'branchListQuery', + options: () => ({ + variables: { + withoutUserFilter: true + } + }) + }), + graphql<{}>(gql(queries.unitsMain), { + name: 'unitListQuery', + options: () => ({ + variables: { + withoutUserFilter: true + } + }) + }), + graphql<{}>(gql(queries.departmentsMain), { + name: 'departmentListQuery', + options: () => ({ + variables: { + withoutUserFilter: true + } + }) + }) + )(SettingsSideBarContainer) +); diff --git a/packages/core-ui/src/modules/settings/team/containers/department/MainList.tsx b/packages/core-ui/src/modules/settings/team/containers/department/MainList.tsx index d7ced59db86..5934f828744 100644 --- a/packages/core-ui/src/modules/settings/team/containers/department/MainList.tsx +++ b/packages/core-ui/src/modules/settings/team/containers/department/MainList.tsx @@ -10,6 +10,7 @@ import MainListCompoenent from '../../components/department/MainList'; import { Alert, confirm } from '@erxes/ui/src/utils'; import client from '@erxes/ui/src/apolloClient'; import { generatePaginationParams } from '@erxes/ui/src/utils/router'; + type Props = { queryParams: any; history: any; diff --git a/packages/core-ui/src/modules/settings/team/containers/structure/Box.tsx b/packages/core-ui/src/modules/settings/team/containers/structure/Box.tsx index dccbcec294f..0de4a47c395 100644 --- a/packages/core-ui/src/modules/settings/team/containers/structure/Box.tsx +++ b/packages/core-ui/src/modules/settings/team/containers/structure/Box.tsx @@ -5,7 +5,6 @@ import { useQuery } from '@apollo/client'; import { queries } from '@erxes/ui/src/team/graphql'; import StructureBox from '../../components/structure/Box'; -import Box from '@erxes/ui/src/components/Box'; import Spinner from '@erxes/ui/src/components/Spinner'; import ErrorMsg from '@erxes/ui/src/components/ErrorMsg'; import { __ } from 'modules/common/utils'; @@ -25,11 +24,9 @@ export default function BoxContainer() { if (error) { return ( - - - {error.message} - - + + {error.message} + ); } diff --git a/packages/core-ui/src/modules/settings/team/containers/unit/Form.tsx b/packages/core-ui/src/modules/settings/team/containers/unit/Form.tsx index 12756aa6399..4b7d9cfb86f 100644 --- a/packages/core-ui/src/modules/settings/team/containers/unit/Form.tsx +++ b/packages/core-ui/src/modules/settings/team/containers/unit/Form.tsx @@ -32,11 +32,7 @@ const FormContainer = (props: Props) => { return ( { .mutate({ mutation: gql(mutations.unitsRemove), variables: { ids }, - refetchQueries: [ - { - query: gql(queries.units), - variables: { - withoutUserFilter: true, - searchValue: undefined - } - } - ] + refetchQueries: ['unitsMain'] }) .then(() => { callback(); diff --git a/packages/core-ui/src/modules/settings/team/styles.ts b/packages/core-ui/src/modules/settings/team/styles.ts index 82fba0a31f7..e2b6493c9dd 100644 --- a/packages/core-ui/src/modules/settings/team/styles.ts +++ b/packages/core-ui/src/modules/settings/team/styles.ts @@ -11,10 +11,8 @@ const ButtonContainer = styled.div` const FlexRow = styled.div` display: flex; - margin-bottom: ${dimensions.unitSpacing}px; - padding: 5px 30px 5px 0; + flex-direction: column; position: relative; - align-items: center; > label { margin: 0; @@ -25,12 +23,6 @@ const FlexRow = styled.div` > *:first-child, input { margin-right: ${dimensions.unitSpacing}px; - flex: 3; - } - - > *:nth-child(2), - > div { - flex: 2; } `; @@ -111,8 +103,25 @@ const StructureList = styled(SidebarList)` } `; -let DescriptionContent = styled.div` +const StructureEditButton = styled.div` + cursor: pointer; + padding: 10px; + color: ${colors.textSecondary}; + + &:hover { + color: ${colors.textPrimary}; + } +`; + +const DescriptionContent = styled.div` text-align: center; + display: flex; + + h4 { + margin-left: 8px; + font-size: 16px; + padding-bottom: 0; + } `; export { @@ -124,5 +133,6 @@ export { FormTable, SideList, StructureList, - DescriptionContent + DescriptionContent, + StructureEditButton }; diff --git a/packages/erxes-ui/src/components/HeaderDescription.tsx b/packages/erxes-ui/src/components/HeaderDescription.tsx index 9233c0bdb03..6243411168b 100644 --- a/packages/erxes-ui/src/components/HeaderDescription.tsx +++ b/packages/erxes-ui/src/components/HeaderDescription.tsx @@ -81,8 +81,8 @@ class HeaderDescription extends React.PureComponent { {__(title)} {this.state.expand && __(description)} + {this.state.expand && renderExtra && renderExtra} - {this.state.expand && renderExtra && renderExtra} ( - styled.div -)` +const HeaderItems = styledTS<{ + rightAligned?: boolean; + hasFlex?: boolean; +}>(styled.div)` align-self: center; flex: ${props => props.hasFlex && 1}; margin-left: ${props => props.rightAligned && 'auto'};