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
VideoViews.js
31 lines
| 1 | const { __ } = wp.i18n; |
| 2 | const { compose } = wp.compose; |
| 3 | const { useEffect } = wp.element; |
| 4 | |
| 5 | import StatCard from "@/admin/ui/StatCard"; |
| 6 | import withStat from "../hocs/withStat"; |
| 7 | import { convertDateTimeToAbsoluteDate } from "../util"; |
| 8 | |
| 9 | export default compose([withStat()])((props) => { |
| 10 | const { video_id, startDate, endDate, stat, fetchData, loading } = props; |
| 11 | |
| 12 | // fetch data when page changes |
| 13 | useEffect(() => { |
| 14 | fetchData({ |
| 15 | endpoint: `/presto-player/v1/analytics/video/${video_id}/views`, |
| 16 | params: { |
| 17 | start: convertDateTimeToAbsoluteDate(startDate), |
| 18 | end: convertDateTimeToAbsoluteDate(endDate), |
| 19 | }, |
| 20 | }); |
| 21 | }, [startDate, endDate]); |
| 22 | |
| 23 | return ( |
| 24 | <StatCard |
| 25 | loading={loading} |
| 26 | value={parseInt(stat)} |
| 27 | title={__("Unique Views", "presto-player")} |
| 28 | /> |
| 29 | ); |
| 30 | }); |
| 31 |