Skip to content

Instantly share code, notes, and snippets.

@Prasanna-Poonacha
Last active November 2, 2020 11:14
Show Gist options
  • Save Prasanna-Poonacha/b038ed8ffe96c58dc95e6784ca654ab2 to your computer and use it in GitHub Desktop.
Save Prasanna-Poonacha/b038ed8ffe96c58dc95e6784ca654ab2 to your computer and use it in GitHub Desktop.
Create a table
/**
* getColumnsHeader only returns columns that user is wanting to see
*/
function getColumnsHeader() {
// async request
return new Promise((resolve, reject) => {
setTimeout(() => {
const headers = [
{
key: 'name.first',
label: 'First name',
},
{
key: 'name.last',
label: 'Last name',
},
{
key: 'tags',
label: 'Tags',
},
{
key: 'balance',
label: 'Balance',
},
];
resolve({
status: 200,
headers,
});
}, 10);
});
}
function getData() {
return new Promise((resolve, reject) => {
setTimeout(() => {
const payload = [
{
_id: '5d3601a6960eda31a0b41843',
index: 0,
isActive: false,
balance: '$1,087.55',
picture: 'http://placehold.it/32x32',
name: {
first: 'Laura',
last: 'Hickman',
},
company: 'Earthpure',
tags: ['officia', 'non', 'ea', 'quis', 'enim'],
favoriteFruit: 'banana',
},
{
_id: '5d3601a60d2262da5fc1cae4',
index: 1,
isActive: true,
balance: '$1,449.62',
picture: 'http://placehold.it/32x32',
name: {
first: 'Deleon',
last: 'Woodard',
},
company: 'Pholio',
tags: ['deserunt', 'cupidatat', 'enim', 'pariatur', 'deserunt'],
favoriteFruit: 'apple',
},
{
_id: '5d3601a63ab9eb833733ed26',
index: 2,
isActive: true,
balance: '$2,806.01',
picture: 'http://placehold.it/32x32',
name: {
first: 'Vicky',
last: 'Macias',
},
company: 'Zillidium',
tags: ['dolor', 'amet', 'culpa', 'incididunt', 'quis'],
favoriteFruit: 'strawberry',
},
{
_id: '5d3601a66d7782b946bb30b2',
index: 3,
isActive: true,
balance: '$3,373.24',
picture: 'http://placehold.it/32x32',
name: {
first: 'Elnora',
last: 'Harding',
},
company: 'Zytrax',
tags: ['non', 'pariatur', 'deserunt', 'officia', 'labore'],
favoriteFruit: 'apple',
},
{
_id: '5d3601a6febc2719cec58b03',
index: 4,
isActive: false,
balance: '$2,812.66',
picture: 'http://placehold.it/32x32',
name: {
first: 'Kristin',
last: 'Wallace',
},
company: 'Hawkster',
tags: ['eu', 'ex', 'velit', 'non', 'nulla'],
favoriteFruit: 'strawberry',
},
{
_id: '5d3601a6d988300f3327e17a',
index: 5,
isActive: true,
balance: '$2,466.11',
picture: 'http://placehold.it/32x32',
name: {
first: 'Johnnie',
last: 'Day',
},
company: 'Zaggles',
tags: ['in', 'aliqua', 'do', 'amet', 'commodo'],
favoriteFruit: 'apple',
},
{
_id: '5d3601a6ff783f6e11158329',
index: 6,
isActive: true,
balance: '$2,754.32',
picture: 'http://placehold.it/32x32',
name: {
first: 'Peterson',
last: 'Levy',
},
company: 'Quinex',
tags: ['ipsum', 'deserunt', 'nostrud', 'duis', 'sit'],
favoriteFruit: 'apple',
},
{
_id: '5d3601a60b25d77a092c13f2',
index: 7,
isActive: true,
balance: '$2,298.04',
picture: 'http://placehold.it/32x32',
name: {
first: 'Odonnell',
last: 'Landry',
},
company: 'Gallaxia',
tags: ['minim', 'non', 'et', 'esse', 'laboris'],
favoriteFruit: 'banana',
},
{
_id: '5d3601a64bdad29dd8e69f1e',
index: 8,
isActive: true,
balance: '$3,921.17',
picture: 'http://placehold.it/32x32',
name: {
first: 'Paulette',
last: 'Meyers',
},
company: 'Zizzle',
tags: ['amet', 'excepteur', 'sunt', 'magna', 'id'],
favoriteFruit: 'banana',
},
{
_id: '5d3601a64b802ecc404874c5',
index: 9,
isActive: false,
balance: '$2,648.13',
picture: 'http://placehold.it/32x32',
name: {
first: 'Navarro',
last: 'Lane',
},
company: 'Cormoran',
tags: ['fugiat', 'nulla', 'exercitation', 'irure', 'proident'],
favoriteFruit: 'strawberry',
},
{
_id: '5d3601a641a220fc9c21eb24',
index: 10,
isActive: false,
balance: '$3,347.11',
picture: 'http://placehold.it/32x32',
name: {
first: 'Jewell',
last: 'Nash',
},
company: 'Photobin',
tags: ['id', 'ut', 'nisi', 'occaecat', 'reprehenderit'],
favoriteFruit: 'apple',
},
{
_id: '5d3601a6c9698bb0afdbefb8',
index: 11,
isActive: false,
balance: '$3,529.20',
picture: 'http://placehold.it/32x32',
name: {
first: 'Casey',
last: 'Figueroa',
},
company: 'Zensus',
tags: ['labore', 'irure', 'ut', 'pariatur', 'veniam'],
favoriteFruit: 'apple',
},
{
_id: '5d3601a6612b7523f2887f78',
index: 12,
isActive: true,
balance: '$3,206.19',
picture: 'http://placehold.it/32x32',
name: {
first: 'Helene',
last: 'Velasquez',
},
company: 'Sonique',
tags: ['excepteur', 'ad', 'incididunt', 'veniam', 'ex'],
favoriteFruit: 'strawberry',
},
{
_id: '5d3601a6628585298ffed8d0',
index: 13,
isActive: true,
balance: '$2,903.01',
picture: 'http://placehold.it/32x32',
name: {
first: 'Lakisha',
last: 'Morrison',
},
company: 'Ginkogene',
tags: ['voluptate', 'et', 'ullamco', 'dolore', 'occaecat'],
favoriteFruit: 'banana',
},
{
_id: '5d3601a6764bcbe549ce4401',
index: 14,
isActive: false,
balance: '$2,898.84',
picture: 'http://placehold.it/32x32',
name: {
first: 'Gloria',
last: 'Armstrong',
},
company: 'Handshake',
tags: ['nulla', 'deserunt', 'eiusmod', 'deserunt', 'ea'],
favoriteFruit: 'apple',
},
{
_id: '5d3601a67e44ce6717568655',
index: 15,
isActive: true,
balance: '$3,160.52',
picture: 'http://placehold.it/32x32',
name: {
first: 'Delores',
last: 'Greer',
},
company: 'Zipak',
tags: ['ullamco', 'culpa', 'in', 'eu', 'sint'],
favoriteFruit: 'strawberry',
},
{
_id: '5d3601a6c881a72232a1d1d8',
index: 16,
isActive: true,
balance: '$3,741.77',
picture: 'http://placehold.it/32x32',
name: {
first: 'Valerie',
last: 'Reilly',
},
company: 'Extrawear',
tags: ['esse', 'in', 'laboris', 'enim', 'consequat'],
favoriteFruit: 'banana',
},
{
_id: '5d3601a66393c7a90d82f6b6',
index: 17,
isActive: true,
balance: '$2,550.35',
picture: 'http://placehold.it/32x32',
name: {
first: 'Rollins',
last: 'Alexander',
},
company: 'Codact',
tags: ['cillum', 'cillum', 'enim', 'qui', 'ea'],
favoriteFruit: 'banana',
},
{
_id: '5d3601a631b302838c437e9b',
index: 18,
isActive: false,
balance: '$3,346.95',
picture: 'http://placehold.it/32x32',
name: {
first: 'Brooks',
last: 'Bass',
},
company: 'Magnina',
tags: ['amet', 'cillum', 'est', 'ad', 'mollit'],
favoriteFruit: 'banana',
},
{
_id: '5d3601a684426608a0bf11bb',
index: 19,
isActive: true,
balance: '$3,863.76',
picture: 'http://placehold.it/32x32',
name: {
first: 'Leonor',
last: 'Rodgers',
},
company: 'Geeky',
tags: ['excepteur', 'elit', 'enim', 'deserunt', 'qui'],
favoriteFruit: 'strawberry',
},
{
_id: '5d3601a6a148d10e08a5ed17',
index: 20,
isActive: true,
balance: '$3,926.29',
picture: 'http://placehold.it/32x32',
name: {
first: 'Mcclain',
last: 'York',
},
company: 'Opticom',
tags: ['tempor', 'anim', 'excepteur', 'commodo', 'laboris'],
favoriteFruit: 'strawberry',
},
{
_id: '5d3601a68bed8bae6ff3ba4b',
index: 21,
isActive: true,
balance: '$3,632.95',
picture: 'http://placehold.it/32x32',
name: {
first: 'Mona',
last: 'Glenn',
},
company: 'Comtest',
tags: ['proident', 'amet', 'deserunt', 'deserunt', 'fugiat'],
favoriteFruit: 'banana',
},
{
_id: '5d3601a62a6ba3d7f8014968',
index: 22,
isActive: true,
balance: '$2,018.91',
picture: 'http://placehold.it/32x32',
name: {
first: 'Fuentes',
last: 'Vincent',
},
company: 'Syntac',
tags: ['velit', 'tempor', 'minim', 'duis', 'tempor'],
favoriteFruit: 'strawberry',
},
{
_id: '5d3601a6c6727b7c6486b2b2',
index: 23,
isActive: false,
balance: '$2,570.05',
picture: 'http://placehold.it/32x32',
name: {
first: 'Lois',
last: 'Quinn',
},
company: 'Qaboos',
tags: ['culpa', 'non', 'labore', 'magna', 'tempor'],
favoriteFruit: 'banana',
},
{
_id: '5d3601a672b51c77f7efc765',
index: 24,
isActive: true,
balance: '$1,228.56',
picture: 'http://placehold.it/32x32',
name: {
first: 'Galloway',
last: 'Burks',
},
company: 'Geostele',
tags: ['nisi', 'cupidatat', 'officia', 'anim', 'voluptate'],
favoriteFruit: 'apple',
},
{
_id: '5d3601a6691010d69d50f2fe',
index: 25,
isActive: false,
balance: '$1,323.17',
picture: 'http://placehold.it/32x32',
name: {
first: 'Jimmie',
last: 'Dejesus',
},
company: 'Synkgen',
tags: ['deserunt', 'tempor', 'sint', 'cillum', 'ex'],
favoriteFruit: 'apple',
},
{
_id: '5d3601a66a0cbd7ba95c354f',
index: 26,
isActive: false,
balance: '$2,725.14',
picture: 'http://placehold.it/32x32',
name: {
first: 'Landry',
last: 'Faulkner',
},
company: 'Geeketron',
tags: ['ad', 'pariatur', 'occaecat', 'cillum', 'officia'],
favoriteFruit: 'strawberry',
},
{
_id: '5d3601a619f6a4bc5a240acc',
index: 27,
isActive: true,
balance: '$1,011.15',
picture: 'http://placehold.it/32x32',
name: {
first: 'Victoria',
last: 'Robles',
},
company: 'Callflex',
tags: ['fugiat', 'ipsum', 'eu', 'in', 'qui'],
favoriteFruit: 'strawberry',
},
{
_id: '5d3601a6c8f230c1320f9d70',
index: 28,
isActive: true,
balance: '$1,989.57',
picture: 'http://placehold.it/32x32',
name: {
first: 'Janna',
last: 'Ferguson',
},
company: 'Techade',
tags: ['nostrud', 'ex', 'est', 'ullamco', 'commodo'],
favoriteFruit: 'banana',
},
{
_id: '5d3601a638f848f2ba576759',
index: 29,
isActive: true,
balance: '$2,852.66',
picture: 'http://placehold.it/32x32',
name: {
first: 'Delacruz',
last: 'Dodson',
},
company: 'Virxo',
tags: ['occaecat', 'sunt', 'velit', 'proident', 'pariatur'],
favoriteFruit: 'apple',
},
];
resolve({
payload,
status: 200,
});
}, 11);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment