import React from 'react'; import FilterSelection from 'Shared/Filters/FilterSelection/FilterSelection'; import User from './data/User'; import { Input, Table, Button, Dropdown } from 'antd'; import { MoreOutlined } from '@ant-design/icons'; import { useHistory } from 'react-router-dom'; import { useStore } from 'App/mstore'; import { observer } from 'mobx-react-lite'; import { withSiteId, dataManagement } from 'App/routes'; import { Filter, Album } from 'lucide-react'; import { list } from '../Activity/Page'; import OutsideClickDetectingDiv from 'Shared/OutsideClickDetectingDiv'; import ColumnsModal from 'Components/DataManagement/Activity/ColumnsModal'; import FullPagination from 'Shared/FullPagination'; function ListPage({ view }: { view: 'users' | 'events' }) { const { projectsStore } = useStore(); const siteId = projectsStore.activeSiteId; const history = useHistory(); const toUser = (id: string) => history.push(withSiteId(dataManagement.userPage(id), siteId)); const toEvent = (id: string) => history.push(withSiteId(dataManagement.eventPage(id), siteId)); return (
{view}
{view === 'users' ? : }
); } function EventsList({ toEvent }: { toEvent: (id: string) => void }) { const columns = [ { title: 'Event Name', dataIndex: 'name', key: 'name', showSorterTooltip: { target: 'full-header' }, sorter: (a, b) => a.name.localeCompare(b.name), }, { title: 'Display Name', dataIndex: 'displayName', key: 'displayName', showSorterTooltip: { target: 'full-header' }, sorter: (a, b) => a.displayName.localeCompare(b.displayName), }, { title: 'Description', dataIndex: 'description', key: 'description', showSorterTooltip: { target: 'full-header' }, sorter: (a, b) => a.description.localeCompare(b.description), }, { title: '30 Day Volume', dataIndex: 'monthVolume', key: 'monthVolume', showSorterTooltip: { target: 'full-header' }, sorter: (a, b) => a.monthVolume.localeCompare(b.monthVolume), }, { title: '30 Day Queries', dataIndex: 'monthQuery', key: 'monthQuery', showSorterTooltip: { target: 'full-header' }, sorter: (a, b) => a.monthQuery.localeCompare(b.monthQuery), }, ]; const page = 1; const total = 100; const onPageChange = (page: number) => {}; const limit = 10; return (
({ onClick: () => toEvent(record.eventId), })} /> ); } function UsersList({ toUser }: { toUser: (id: string) => void }) { const [editCols, setEditCols] = React.useState(false); const [hiddenCols, setHiddenCols] = React.useState([]); const testUsers = [ new User({ name: 'test123', userId: 'email@id.com', distinctId: ['123123123'], userLocation: 'NY', cohorts: ['test'], properties: { email: 'sad;jsadk', }, updatedAt: Date.now(), }), new User({ name: 'test123', userId: 'email@id.com', distinctId: ['123123123'], userLocation: 'NY', cohorts: ['test'], properties: { email: 'sad;jsadk', }, updatedAt: Date.now(), }), new User({ name: 'test123', userId: 'email@id.com', distinctId: ['123123123123'], userLocation: 'NY', cohorts: ['test'], properties: { email: 'sad;jsadk', }, updatedAt: Date.now(), }), new User({ name: 'test123', userId: 'email@id.com', distinctId: ['1231214143123'], userLocation: 'NY', cohorts: ['test'], properties: { email: 'sad;jsadk', }, updatedAt: Date.now(), }), ]; const dropdownItems = [ { label: 'Show/Hide Columns', key: 'edit-columns', onClick: () => setTimeout(() => setEditCols(true), 1), }, ]; const columns = [ { title: 'Name', dataIndex: 'name', key: 'name', showSorterTooltip: { target: 'full-header' }, sorter: (a, b) => a.name.localeCompare(b.name), }, { title: 'Email', dataIndex: 'userId', key: 'userId', showSorterTooltip: { target: 'full-header' }, sorter: (a, b) => a.userId.localeCompare(b.userId), }, { title: 'Distinct ID', dataIndex: 'distinctId', key: 'distinctId', showSorterTooltip: { target: 'full-header' }, sorter: (a, b) => a.distinctId[0].localeCompare(b.distinctId[0]), }, { title: 'Updated', dataIndex: 'updatedAt', key: 'updatedAt', showSorterTooltip: { target: 'full-header' }, sorter: (a, b) => a.updatedAt.localeCompare(b.updatedAt), }, { title: (
), dataIndex: '$__opts__$', key: '$__opts__$', width: 50, }, ]; const page = 1; const total = 10; const onPageChange = (page: number) => {}; const limit = 10; const list = []; const onAddFilter = () => console.log('add filter'); const excludeFilterKeys = []; const excludeCategory = []; const shownCols = columns.map((col) => ({ ...col, hidden: hiddenCols.includes(col.key), })); const onUpdateVisibleCols = (cols: string[]) => { setHiddenCols((_) => { return columns .map((col) => cols.includes(col.key) || col.key === '$__opts__$' ? null : col.key ) .filter(Boolean); }); setEditCols(false); }; return (
{/* 1.23 -- Show by*/} {/**/}
{editCols ? ( setEditCols(false)}> col.key !== '$__opts__$')} onSelect={onUpdateVisibleCols} hiddenCols={hiddenCols} topOffset={'top-24 -mt-4'} /> ) : null}
({ onClick: () => toUser(record.userId), })} pagination={false} rowClassName={'cursor-pointer'} dataSource={testUsers} columns={shownCols} /> ); } export default observer(ListPage);