-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: add grouped table * fix: fix types * fix: revert table default story & fix typing * fix: delete flow fixme comment
- Loading branch information
ShtykovAlexander
authored
Mar 28, 2022
1 parent
b752cfd
commit d3462be
Showing
3 changed files
with
136 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -283,6 +283,81 @@ const TABLE_DATA = [ | |
}, | ||
]; | ||
|
||
const GROUPED_TABLE_DATA = [ | ||
{ | ||
id: '1', | ||
group: 'First', | ||
createdAt: '2018-09-03T09:59:43.000Z', | ||
updatedAt: '2018-09-03T09:59:43.000Z', | ||
firstName: 'Cecily', | ||
lastName: 'Oen', | ||
email: '[email protected]', | ||
}, | ||
{ | ||
id: '2', | ||
group: 'First', | ||
createdAt: '2018-09-03T10:34:15.000Z', | ||
updatedAt: '2018-09-03T10:34:15.000Z', | ||
firstName: 'Larry', | ||
lastName: 'Marwick', | ||
email: '[email protected]', | ||
}, | ||
{ | ||
id: '3', | ||
group: 'First', | ||
createdAt: '2018-09-03T09:59:46.000Z', | ||
updatedAt: '2018-09-03T09:59:46.000Z', | ||
firstName: 'Evangelina', | ||
lastName: 'Korner', | ||
email: '[email protected]', | ||
}, | ||
{ | ||
id: '4', | ||
group: 'Second', | ||
createdAt: '2018-09-03T09:59:43.000Z', | ||
updatedAt: '2018-09-03T09:59:43.000Z', | ||
firstName: 'Dian', | ||
lastName: 'Wegge', | ||
email: '[email protected]', | ||
}, | ||
{ | ||
id: '5', | ||
group: 'Second', | ||
createdAt: '2018-09-03T09:59:45.000Z', | ||
updatedAt: '2018-09-03T09:59:45.000Z', | ||
firstName: 'Chas', | ||
lastName: 'Dalrymple', | ||
email: '[email protected]', | ||
}, | ||
{ | ||
id: '6', | ||
group: 'Third', | ||
createdAt: '2018-09-03T09:59:43.000Z', | ||
updatedAt: '2018-09-03T09:59:43.000Z', | ||
firstName: 'Preston', | ||
lastName: 'Bonini', | ||
email: '[email protected]', | ||
}, | ||
{ | ||
id: '7', | ||
group: 'Third', | ||
createdAt: '2018-09-03T09:59:45.000Z', | ||
updatedAt: '2018-09-03T09:59:45.000Z', | ||
firstName: 'Chas', | ||
lastName: 'Dalrymple', | ||
email: '[email protected]', | ||
}, | ||
{ | ||
id: '8', | ||
group: 'First', | ||
createdAt: '2018-09-03T09:59:45.000Z', | ||
updatedAt: '2018-09-03T09:59:45.000Z', | ||
firstName: 'Chas', | ||
lastName: 'Dalrymple', | ||
email: '[email protected]', | ||
}, | ||
]; | ||
|
||
const fetchData = async (page, pageSize) => { | ||
await (() => new Promise(resolve => setTimeout(resolve, 5000)))(); | ||
|
||
|
@@ -418,6 +493,28 @@ defaultStory.story = { | |
name: 'default', | ||
}; | ||
|
||
export const grouped = () => ( | ||
<div style={{ display: 'flex', height: '600px' }}> | ||
<TableBuilder | ||
columns={ TABLE_COLUMNS } | ||
data={ GROUPED_TABLE_DATA } | ||
groupBy={ (data) => | ||
data.reduce( | ||
(acc, item) => { | ||
if (!acc[item.group]) { | ||
return { ...acc, [item.group]: [item] }; | ||
} | ||
acc[item.group] = [...acc[item.group], item]; | ||
return acc; | ||
}, {}) } | ||
/> | ||
</div> | ||
); | ||
|
||
grouped.story = { | ||
name: 'grouped', | ||
}; | ||
|
||
export const withLoader = () => ( | ||
<div style={{ display: 'flex', height: '600px' }}> | ||
<Table> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters