DataTable.js
5 years ago
DatePicker.js
5 years ago
OverviewPanel.js
5 years ago
TopUsers.js
3 years ago
TopVideos.js
3 years ago
TotalVideoViewsByUser.js
4 years ago
TotalViewsGraph.js
4 years ago
TotalWatchGraph.js
4 years ago
VideoAverageWatchTime.js
4 years ago
VideoAverageWatchTimeByUser.js
4 years ago
VideoTimeline.js
4 years ago
VideoTotalWatchTimeByUser.js
4 years ago
VideoViews.js
5 years ago
DataTable.js
63 lines
| 1 | const { __ } = wp.i18n; |
| 2 | const { useEffect, useState } = wp.element; |
| 3 | const { Card, CardBody } = wp.components; |
| 4 | import Loading from "@/admin/settings/components/Loading"; |
| 5 | import Pagination from "@/admin/ui/Pagination"; |
| 6 | import Table from "@/admin/ui/Table"; |
| 7 | |
| 8 | export default ({ |
| 9 | perPage = 10, |
| 10 | title, |
| 11 | page, |
| 12 | setPage, |
| 13 | loading, |
| 14 | total, |
| 15 | totalPages, |
| 16 | columns, |
| 17 | data, |
| 18 | onSelect, |
| 19 | }) => { |
| 20 | if (loading) { |
| 21 | return ( |
| 22 | <Card> |
| 23 | <Loading /> |
| 24 | </Card> |
| 25 | ); |
| 26 | } |
| 27 | |
| 28 | if (!data?.length) { |
| 29 | return ( |
| 30 | <Card size="large" className="presto-card"> |
| 31 | <CardBody className="presto-flow"> |
| 32 | <div className="presto-card__title">{title}</div> |
| 33 | <div style={{ opacity: 0.65 }}> |
| 34 | {__("No data available.", "presto-player")} |
| 35 | </div> |
| 36 | </CardBody> |
| 37 | </Card> |
| 38 | ); |
| 39 | } |
| 40 | |
| 41 | return ( |
| 42 | <div className="datatable"> |
| 43 | <Table |
| 44 | data={data} |
| 45 | columns={columns} |
| 46 | perPage={perPage} |
| 47 | onRowClick={onSelect} |
| 48 | title={title} |
| 49 | /> |
| 50 | |
| 51 | {!!total && ( |
| 52 | <Pagination |
| 53 | page={page} |
| 54 | setPage={setPage} |
| 55 | perPage={perPage} |
| 56 | total={total} |
| 57 | totalPages={totalPages} |
| 58 | /> |
| 59 | )} |
| 60 | </div> |
| 61 | ); |
| 62 | }; |
| 63 |