import { ASSETS_URL } from '../../../consts/common'; import type { DataGridProps } from '../types'; import type { DataGridMockProps } from './index'; const mockData: DataGridProps['tableData'] = { page: 1, totalPages: 12, totalRecords: 125, data: [ { _id: 'Tum57QnqOl', disabled: false, idProviders: 'Database (2FA), G Suite', groups: 'Design Team, Product, Administrators, Managers', role: 'User', userEmail: 'antonio.banderas@mock.com', userName: 'Antonio Banderas', emailVerified: true, createdDate: '2018-12-18T06:40:16.906Z', lastVPNSuccessLoginAt: '2018-12-18T06:40:16.906Z', country: 'GB', actions: 'dropdown' }, { _id: 'trUmp1Null', disabled: true, idProviders: 'G Suite (2FA)', groups: 'Administrators', role: 'User', userEmail: 'tyler.guerro@mock.com', userName: 'Tyler Guerro', emailVerified: true, createdDate: '2021-04-01T06:40:16.906Z', lastVPNSuccessLoginAt: '2021-04-01T06:40:16.906Z', country: 'SE', actions: 'dropdown' }, { _id: 'Pros4Zer0u', disabled: false, idProviders: 'G Suite (2FA)', initials: 'KC', initialsColor: '#C2185B', groups: 'Administrators', role: 'Owner', userEmail: 'keanu@mock.com', userName: 'Keanu Cook', emailVerified: true, createdDate: '2021-04-22T12:40:56.007Z', lastVPNSuccessLoginAt: '2021-04-22T08:12:00.187Z', country: 'AT', actions: 'dropdown' }, { _id: 'Jose1Cunni', disabled: false, idProviders: 'G Suite (2FA)', initials: 'JC', initialsColor: '#F1CA3A', groups: 'Administrators', role: 'Manager', userEmail: 'joe.cunningham@mock.com', userName: 'Jose Cunningham', emailVerified: true, createdDate: '2021-03-23T09:40:30.510Z', lastVPNSuccessLoginAt: '2021-03-23T09:40:30.510Z', country: 'IE', actions: 'dropdown' }, { _id: 'JonathanM6', disabled: false, idProviders: 'G Suite (2FA)', initialsColor: '#109618', groups: 'Managers', role: 'Manager', userEmail: 'jonatahan_m_perimeter81@mock.com', userName: 'Jonathan Marshall', emailVerified: true, createdDate: '2018-12-18T06:12:43.051Z', lastVPNSuccessLoginAt: '2018-12-18T06:12:43.051Z', country: 'BR', actions: 'dropdown' }, { _id: 'Beat3Wade8', disabled: false, idProviders: 'Database (2FA), G Suite', groups: 'Sales', role: 'Manager', userEmail: 'wadeB@mock.com', userName: 'Beatrice Wade', emailVerified: true, createdDate: '2021-04-01T06:40:17.333Z', lastVPNSuccessLoginAt: '2021-04-01T12:40:16.777Z', country: 'DE', actions: 'dropdown' }, { _id: 'kyles7Sher', disabled: false, idProviders: 'SAML 2.0', groups: 'Administrators', role: 'User', userEmail: 'kyle.schneider@mock.com', userName: 'Kyle Schneider', emailVerified: true, createdDate: '2021-04-01T06:40:16.906Z', lastVPNSuccessLoginAt: '2021-04-01T06:40:16.906Z', country: 'NL', actions: 'dropdown' }, { _id: 'fuKhHQnq1l', disabled: false, idProviders: 'SAML 2.0', groups: 'All Users', role: 'Admin', userEmail: 'andrej.serotin@mock.com', userName: 'Andrej Serotin', emailVerified: true, createdDate: '2021-12-22T10:49:56.356Z', lastVPNSuccessLoginAt: '2022-01-06T15:03:51.007Z', country: 'SK', actions: 'dropdown' }, { _id: 'wbEm9DHPV9', disabled: true, idProviders: 'Database (2FA)', initials: 'DS', initialsColor: '#F3CF3A', groups: 'All Users', role: 'User', userEmail: 'david.shortstock@fake.com', userName: 'David Shortstock', emailVerified: false, createdDate: '2021-12-21T13:11:03.404Z', lastVPNSuccessLoginAt: '2021-12-28T12:21:13.500Z', country: 'IR', actions: 'dropdown' }, { _id: 'xZLOVj8m8K', disabled: false, idProviders: 'Database (2FA)', groups: 'All Users', role: 'Admin', userEmail: 'johnson.torsini@mock.com', userName: 'GiuseppeTorsini', emailVerified: true, createdDate: '2021-12-21T11:35:24.579Z', lastVPNSuccessLoginAt: '2021-12-21T14:05:14.911Z', country: 'IT', actions: 'dropdown' }, { _id: 'Fuh7GfWhB6', disabled: false, idProviders: 'G Suite (2FA)', groups: 'All Users', role: 'Admin', userEmail: 'anderson.thomas@mock.com', userName: 'Anderson Thomas', emailVerified: true, createdDate: '2021-12-21T11:35:24.362Z', lastVPNSuccessLoginAt: '2021-12-09T11:11:11.111Z', country: 'BE', status: 'Online', actions: 'dropdown' }, { _id: '84TqmyqJmA', disabled: false, idProviders: 'Database (2FA)', groups: 'All Users', role: 'Manager', userEmail: 'brandon.prust@mock.com', userName: 'Brandon Prust', emailVerified: true, createdDate: '2021-12-20T15:15:33.331Z', actions: 'dropdown' }, { _id: 'kyrBd4tDoS', disabled: false, idProviders: 'SAML 2.0', groups: 'All Users', role: 'Admin', userEmail: 'emile.smith@mock.com', userName: 'Emile Smith', emailVerified: true, createdDate: '2021-12-19T09:03:34.269Z', lastVPNSuccessLoginAt: '2022-01-04T16:04:02.703Z', country: 'GB', actions: 'dropdown' }, { _id: 'bbXfTZq352', disabled: false, idProviders: 'Database (2FA), G Suite', groups: 'All Users', role: 'Manager', userEmail: 'olivia.wilde@mock.com', userName: 'Olivia Wilde', emailVerified: true, createdDate: '2021-12-08T14:32:17.175Z', lastVPNSuccessLoginAt: '2022-01-04T15:34:12.307Z', country: 'US', iconSrc: 'https://upload.wikimedia.org/wikipedia/commons/thumb/3/37/OliviaWildeRestSDCCJuly10.jpg/198px-OliviaWildeRestSDCCJuly10.jpg', actions: 'dropdown' }, { _id: 'D66aS4uHv3', disabled: false, idProviders: 'G Suite (2FA)', groups: 'Design Team', role: 'Manager', userEmail: 'rod.hernandez@mock.com', userName: 'RodriguezHernandez', emailVerified: true, createdDate: '2021-11-29T17:52:42.338Z', actions: 'dropdown' }, { _id: '1R0hGAXCdX', disabled: false, idProviders: 'Database (2FA), G Suite', groups: 'Sales, Production, Manager', role: 'Manager', userEmail: 'joe.brown@mock.com', userName: 'Joe Brown', emailVerified: true, createdDate: '2021-11-29T15:52:22.687Z', lastVPNSuccessLoginAt: '2021-12-05T10:14:52.577Z', country: 'GB', status: 'Online', actions: 'dropdown' }, { _id: 'K6jeBNchDe', disabled: true, idProviders: 'Database (2FA)', groups: 'Production', role: 'User', userEmail: 'williams@test.com', userName: 'Williams English', emailVerified: false, createdDate: '2021-11-29T14:43:21.966Z', actions: 'dropdown' }, { _id: 'S5IB0aq0zZ', disabled: false, idProviders: 'Database (2FA)', groups: 'Administrators, BI Group', role: 'Manager', userEmail: 'bi.manager@test.com', userName: 'BI Manager', emailVerified: true, createdDate: '2021-11-25T11:21:23.527Z', lastVPNSuccessLoginAt: '2021-12-20T07:29:18.403Z', country: 'AT', status: 'Online', actions: 'dropdown' }, { _id: 'abLiDwrYOV', disabled: false, idProviders: 'Database (2FA)', groups: 'Administrators, CS Group', role: 'Manager', userEmail: 'cs.manager@test.com', userName: 'CS Manager', emailVerified: true, createdDate: '2021-11-25T11:21:23.527Z', lastVPNSuccessLoginAt: '2021-12-26T12:47:01.119Z', country: 'AT', actions: 'dropdown' }, { _id: '3V7XH8LRBg', disabled: false, idProviders: 'G Suite (2FA)', groups: 'Administrators, Sales', role: 'Manager', userEmail: 'anthony.davidoff@test.com', userName: 'Anthony Davidoff', emailVerified: true, createdDate: '2021-11-29T14:43:21.966Z', actions: 'dropdown' }, { _id: '9C1GH8ZEJy', disabled: false, idProviders: 'G Suite (2FA)', groups: 'Demo Admin', role: 'User', userEmail: 'b.p.herbert@fake.com', userName: 'Herbert, Brian Patrick', emailVerified: true, createdDate: '2021-11-19T11:35:01.041Z', lastVPNSuccessLoginAt: '2021-11-26T16:40:32.932Z', actions: 'dropdown' }, { _id: 'L3RSjYM8ER', disabled: true, idProviders: 'G Suite (2FA)', groups: 'Managers', role: 'User', userEmail: 'jwo.lennon@fake.com', userName: 'John Lennon', emailVerified: true, createdDate: '2021-10-19T10:44:37.785Z', iconSrc: 'https://upload.wikimedia.org/wikipedia/commons/a/a0/John_Lennon_passport_photo_%28cropped%29.jpg', actions: 'dropdown' }, { _id: 'Z3EL1MYC8G', disabled: true, role: 'User', userEmail: 'no.name+1@fake.com', userName: 'No Name I', emailVerified: true, createdDate: '2022-01-09T11:11:11.111Z', iconSrc: 'https://cdn.iconscout.com/icon/free/png-256/avatar-366-456318.png', actions: 'dropdown' }, { _id: 'ST8M4EKCOX', disabled: true, role: 'User', userEmail: 'no.name+2@fake.com', userName: 'No Name II', emailVerified: true, createdDate: '2022-01-10T11:11:11.111Z', iconSrc: 'https://cdn.iconscout.com/icon/free/png-256/avatar-366-456318.png', actions: 'dropdown' }, { _id: '6NRCQJW59K', disabled: true, role: 'User', userEmail: 'no.name+3@fake.com', userName: 'No Name III', emailVerified: true, createdDate: '2022-01-11T11:11:11.111Z', iconSrc: 'https://cdn.iconscout.com/icon/free/png-256/avatar-366-456318.png', actions: 'dropdown' }, { _id: 'CGIV610PER', disabled: true, role: 'User', userEmail: 'no.name+4@fake.com', userName: 'No Name IV', emailVerified: true, createdDate: '2022-01-12T11:11:11.111Z', iconSrc: 'https://cdn.iconscout.com/icon/free/png-256/avatar-366-456318.png', actions: 'dropdown' } ] }; const mockTableConfig: DataGridProps['tableConfig'] = [ { cellEmptyState: ' ', isSortable: true, pinnable: false, field: 'userName', title: 'Member', show: true, width: 240, fieldsToExport: ['userName'], withEmailIcon: false, withUserIcon: true }, { isSortable: true, field: 'idProviders', title: 'Identity Provider', show: true, width: 192, fieldsToExport: ['idProviders'] }, { cellEmptyState: 'User', isSortable: true, field: 'role', title: 'Role', show: true, width: 108, fieldsToExport: ['role'] }, { isSortable: true, field: 'groups', title: 'Groups', show: true, width: 180, fieldsToExport: ['groups'] }, { cellEmptyState: 'N/A', isSortable: true, field: 'lastVPNSuccessLoginAt', title: 'Last Login', fromToGroup: true, show: true, width: 176, fieldsToExport: ['lastVPNSuccessLoginAt'] }, { cellEmptyState: 'N/A', isSortable: true, field: 'createdDate', title: 'Created At', fromToGroup: true, show: true, width: 160, fieldsToExport: ['createdDate'], customTimeFunc: time => { const oneHour = 3600000; const oneMin = 60000; // Convert both dates to milliseconds const then = new Date(time).getTime(); const now = new Date().getTime(); // Calculate the difference in milliseconds const difference = Math.abs(now - then); const differenceInMins = Math.round(difference / oneMin); if (difference < oneHour) { return `${differenceInMins} min ago`; } else { return false; } } }, { isSortable: false, field: 'actions', title: '', show: true, width: 120, align: 'right', fieldsToExport: [], actions: [ { iconSrc: `${ASSETS_URL}/icons2/icon_trash.svg`, value: 'delete', onClick: value => () => { alert('Delete click'); } }, { iconSrc: `${ASSETS_URL}/icons2/icon_edit.svg`, value: 'edit', onClick: value => () => { alert('Edit click'); } }, { iconSrc: `${ASSETS_URL}/icons2/icon_view.svg`, value: 'view', onClick: value => () => { alert('View click'); } } ] } ]; const mockMembers: DataGridMockProps = { title1: 'Members', tableConfig: mockTableConfig, tableData: mockData }; export { mockMembers };