Uniformize folder structure (#693)
* Uniformize folder structure * Fix icons * Fix icons * Fix tests * Fix tests
This commit is contained in:
@ -2,8 +2,8 @@ import { useEffect, useState } from 'react';
|
||||
import { useRecoilValue } from 'recoil';
|
||||
|
||||
import { peopleCityFamilyState } from '@/people/states/peopleCityFamilyState';
|
||||
import { EditableCellPhone } from '@/ui/components/editable-cell/types/EditableCellPhone';
|
||||
import { useCurrentRowEntityId } from '@/ui/tables/hooks/useCurrentEntityId';
|
||||
import { EditableCellPhone } from '@/ui/table/editable-cell/types/EditableCellPhone';
|
||||
import { useCurrentRowEntityId } from '@/ui/table/hooks/useCurrentEntityId';
|
||||
import { useUpdatePeopleMutation } from '~/generated/graphql';
|
||||
|
||||
export function EditablePeopleCityCell() {
|
||||
|
||||
@ -2,7 +2,7 @@ import { useRecoilValue } from 'recoil';
|
||||
|
||||
import { PeopleCompanyCell } from '@/people/components/PeopleCompanyCell';
|
||||
import { peopleCompanyFamilyState } from '@/people/states/peopleCompanyFamilyState';
|
||||
import { useCurrentRowEntityId } from '@/ui/tables/hooks/useCurrentEntityId';
|
||||
import { useCurrentRowEntityId } from '@/ui/table/hooks/useCurrentEntityId';
|
||||
|
||||
export function EditablePeopleCompanyCell() {
|
||||
const currentRowEntityId = useCurrentRowEntityId();
|
||||
|
||||
@ -2,8 +2,8 @@ import { DateTime } from 'luxon';
|
||||
import { useRecoilValue } from 'recoil';
|
||||
|
||||
import { peopleCreatedAtFamilyState } from '@/people/states/peopleCreatedAtFamilyState';
|
||||
import { EditableCellDate } from '@/ui/components/editable-cell/types/EditableCellDate';
|
||||
import { useCurrentRowEntityId } from '@/ui/tables/hooks/useCurrentEntityId';
|
||||
import { EditableCellDate } from '@/ui/table/editable-cell/types/EditableCellDate';
|
||||
import { useCurrentRowEntityId } from '@/ui/table/hooks/useCurrentEntityId';
|
||||
import { useUpdatePeopleMutation } from '~/generated/graphql';
|
||||
|
||||
export function EditablePeopleCreatedAtCell() {
|
||||
|
||||
@ -2,8 +2,8 @@ import { useEffect, useState } from 'react';
|
||||
import { useRecoilValue } from 'recoil';
|
||||
|
||||
import { peopleEmailFamilyState } from '@/people/states/peopleEmailFamilyState';
|
||||
import { EditableCellText } from '@/ui/components/editable-cell/types/EditableCellText';
|
||||
import { useCurrentRowEntityId } from '@/ui/tables/hooks/useCurrentEntityId';
|
||||
import { EditableCellText } from '@/ui/table/editable-cell/types/EditableCellText';
|
||||
import { useCurrentRowEntityId } from '@/ui/table/hooks/useCurrentEntityId';
|
||||
import { useUpdatePeopleMutation } from '~/generated/graphql';
|
||||
|
||||
export function EditablePeopleEmailCell() {
|
||||
|
||||
@ -3,7 +3,7 @@ import { useRecoilValue } from 'recoil';
|
||||
|
||||
import { EditablePeopleFullName } from '@/people/components/EditablePeopleFullName';
|
||||
import { peopleNameCellFamilyState } from '@/people/states/peopleNamesFamilyState';
|
||||
import { useCurrentRowEntityId } from '@/ui/tables/hooks/useCurrentEntityId';
|
||||
import { useCurrentRowEntityId } from '@/ui/table/hooks/useCurrentEntityId';
|
||||
import { useUpdatePeopleMutation } from '~/generated/graphql';
|
||||
|
||||
export function EditablePeopleFullNameCell() {
|
||||
|
||||
@ -2,8 +2,8 @@ import { useEffect, useState } from 'react';
|
||||
import { useRecoilValue } from 'recoil';
|
||||
|
||||
import { peoplePhoneFamilyState } from '@/people/states/peoplePhoneFamilyState';
|
||||
import { EditableCellPhone } from '@/ui/components/editable-cell/types/EditableCellPhone';
|
||||
import { useCurrentRowEntityId } from '@/ui/tables/hooks/useCurrentEntityId';
|
||||
import { EditableCellPhone } from '@/ui/table/editable-cell/types/EditableCellPhone';
|
||||
import { useCurrentRowEntityId } from '@/ui/table/hooks/useCurrentEntityId';
|
||||
import { useUpdatePeopleMutation } from '~/generated/graphql';
|
||||
|
||||
export function EditablePeoplePhoneCell() {
|
||||
|
||||
49
front/src/modules/people/table/components/PeopleTable.tsx
Normal file
49
front/src/modules/people/table/components/PeopleTable.tsx
Normal file
@ -0,0 +1,49 @@
|
||||
import { useCallback, useMemo, useState } from 'react';
|
||||
|
||||
import { defaultOrderBy } from '@/companies/queries';
|
||||
import { PeopleEntityTableData } from '@/people/components/PeopleEntityTableData';
|
||||
import { PeopleSelectedSortType } from '@/people/queries';
|
||||
import { peopleColumns } from '@/people/table/components/peopleColumns';
|
||||
import { reduceSortsToOrderBy } from '@/ui/filter-n-sort/helpers';
|
||||
import { filtersScopedState } from '@/ui/filter-n-sort/states/filtersScopedState';
|
||||
import { turnFilterIntoWhereClause } from '@/ui/filter-n-sort/utils/turnFilterIntoWhereClause';
|
||||
import { IconList } from '@/ui/icon';
|
||||
import { useRecoilScopedValue } from '@/ui/recoil-scope/hooks/useRecoilScopedValue';
|
||||
import { EntityTable } from '@/ui/table/components/EntityTable';
|
||||
import { HooksEntityTable } from '@/ui/table/components/HooksEntityTable';
|
||||
import { TableContext } from '@/ui/table/states/TableContext';
|
||||
import { PersonOrderByWithRelationInput } from '~/generated/graphql';
|
||||
import { peopleFilters } from '~/pages/people/people-filters';
|
||||
import { availableSorts } from '~/pages/people/people-sorts';
|
||||
|
||||
export function PeopleTable() {
|
||||
const [orderBy, setOrderBy] =
|
||||
useState<PersonOrderByWithRelationInput[]>(defaultOrderBy);
|
||||
|
||||
const updateSorts = useCallback((sorts: Array<PeopleSelectedSortType>) => {
|
||||
setOrderBy(sorts.length ? reduceSortsToOrderBy(sorts) : defaultOrderBy);
|
||||
}, []);
|
||||
|
||||
const filters = useRecoilScopedValue(filtersScopedState, TableContext);
|
||||
|
||||
const whereFilters = useMemo(() => {
|
||||
return { AND: filters.map(turnFilterIntoWhereClause) };
|
||||
}, [filters]) as any;
|
||||
|
||||
return (
|
||||
<>
|
||||
<PeopleEntityTableData orderBy={orderBy} whereFilters={whereFilters} />
|
||||
<HooksEntityTable
|
||||
numberOfColumns={peopleColumns.length}
|
||||
availableFilters={peopleFilters}
|
||||
/>
|
||||
<EntityTable
|
||||
columns={peopleColumns}
|
||||
viewName="All People"
|
||||
viewIcon={<IconList size={16} />}
|
||||
availableSorts={availableSorts}
|
||||
onSortsUpdate={updateSorts}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
import { useOpenCreateCommentThreadDrawerForSelectedRowIds } from '@/activities/hooks/useOpenCreateCommentDrawerForSelectedRowIds';
|
||||
import { TableActionBarButtonToggleComments } from '@/ui/table/action-bar/components/TableActionBarButtonOpenComments';
|
||||
import { CommentableType } from '~/generated/graphql';
|
||||
|
||||
export function TableActionBarButtonCreateCommentThreadPeople() {
|
||||
const openCreateCommentThreadRightDrawer =
|
||||
useOpenCreateCommentThreadDrawerForSelectedRowIds();
|
||||
|
||||
async function handleButtonClick() {
|
||||
openCreateCommentThreadRightDrawer(CommentableType.Person);
|
||||
}
|
||||
|
||||
return <TableActionBarButtonToggleComments onClick={handleButtonClick} />;
|
||||
}
|
||||
@ -0,0 +1,40 @@
|
||||
import { getOperationName } from '@apollo/client/utilities';
|
||||
import { useRecoilValue } from 'recoil';
|
||||
|
||||
import { GET_PEOPLE } from '@/people/queries';
|
||||
import { IconTrash } from '@/ui/icon/index';
|
||||
import { EntityTableActionBarButton } from '@/ui/table/action-bar/components/EntityTableActionBarButton';
|
||||
import { useResetTableRowSelection } from '@/ui/table/hooks/useResetTableRowSelection';
|
||||
import { selectedRowIdsSelector } from '@/ui/table/states/selectedRowIdsSelector';
|
||||
import { useDeletePeopleMutation } from '~/generated/graphql';
|
||||
|
||||
export function TableActionBarButtonDeletePeople() {
|
||||
const selectedRowIds = useRecoilValue(selectedRowIdsSelector);
|
||||
|
||||
const resetRowSelection = useResetTableRowSelection();
|
||||
|
||||
const [deletePeople] = useDeletePeopleMutation({
|
||||
refetchQueries: [getOperationName(GET_PEOPLE) ?? ''],
|
||||
});
|
||||
|
||||
async function handleDeleteClick() {
|
||||
const rowIdsToDelete = selectedRowIds;
|
||||
|
||||
resetRowSelection();
|
||||
|
||||
await deletePeople({
|
||||
variables: {
|
||||
ids: rowIdsToDelete,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
return (
|
||||
<EntityTableActionBarButton
|
||||
label="Delete"
|
||||
icon={<IconTrash size={16} />}
|
||||
type="warning"
|
||||
onClick={handleDeleteClick}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@ -5,7 +5,7 @@ import {
|
||||
IconMap,
|
||||
IconPhone,
|
||||
IconUser,
|
||||
} from '@/ui/icons/index';
|
||||
} from '@/ui/icon/index';
|
||||
|
||||
import { EditablePeopleCityCell } from './EditablePeopleCityCell';
|
||||
import { EditablePeopleCompanyCell } from './EditablePeopleCompanyCell';
|
||||
|
||||
Reference in New Issue
Block a user