PluginProbe ʕ •ᴥ•ʔ
Presto Player / 1.10.0
Presto Player v1.10.0
4.5.0 4.4.1 4.4.0 4.3.3 4.3.2 4.3.1 4.3.0 4.2.4 4.2.3 4.2.2 4.2.0 4.2.1 trunk 1.10.0 1.10.1 1.10.2 1.11.0 1.12.0 1.13.0 1.14.0 1.14.1 1.5.10 1.5.11 1.5.12 1.5.13 1.5.14 1.5.15 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9 1.6.0 1.6.1 1.6.10 1.6.11 1.6.12 1.6.13 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.6.8 1.6.9 1.7.0 1.7.1 1.7.2 1.8.0 1.8.1 1.8.2 1.8.3 1.8.4 1.8.5 1.8.6 1.9.0 1.9.1 1.9.10 1.9.11 1.9.12 1.9.13 1.9.14 1.9.2 1.9.3 1.9.4 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.0.0 2.0.1 2.0.10 2.0.11 2.0.12 2.0.13 2.0.14 2.0.15 2.0.16 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 2.1.0 2.2.0 2.2.1 2.2.2 2.2.3 2.2.3-beta1 2.3.0 2.3.1 2.3.2 2.3.3 3.0.0 3.0.0-beta1 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.1.0 3.1.1 3.1.2 3.1.3 4.0.0 4.0.1 4.0.2 4.0.3 4.0.4 4.0.5 4.0.6 4.0.7 4.0.8 4.1.0 4.1.1 4.1.2 4.1.3 4.1.4
presto-player / src / admin / analytics / pages / User.js
presto-player / src / admin / analytics / pages Last commit date
AnalyticsUpgrade.js 5 years ago Dashboard.js 4 years ago User.js 5 years ago Video.js 4 years ago illustration.js 5 years ago
User.js
172 lines
1 /** @jsx jsx */
2
3 const { __ } = wp.i18n;
4
5 const { Flex, FlexBlock, FlexItem, Spinner, Button } = wp.components;
6
7 import { history } from "@/router/context";
8 import DatePicker from "../components/DatePicker";
9 import TopVideos from "../components/TopVideos";
10 import TotalVideoViewsByUser from "../components/TotalVideoViewsByUser";
11 import VideoAverageWatchTimeByUser from "../components/VideoAverageWatchTimeByUser";
12 import VideoTotalWatchTimeByUser from "../components/VideoTotalWatchTimeByUser";
13
14 const { useEffect, useState } = wp.element;
15 const { apiFetch } = wp;
16
17 import { css, jsx } from "@emotion/core";
18
19 const User = ({ route, startDate, endDate, setStartDate, setEndDate }) => {
20 const [loading, setLoading] = useState(true);
21 const [user, setUser] = useState({});
22 const [error, setError] = useState("");
23
24 const back = () => {
25 history.push(`#/`);
26 };
27
28 const getUser = async () => {
29 setLoading(true);
30 try {
31 let user = await apiFetch({
32 url: `/wp-json/wp/v2/users/${route?.params?.id}?context=edit`,
33 });
34 setUser(user);
35 } catch (e) {
36 if (e.code === "rest_no_route") {
37 setError("User Not Found");
38 }
39 } finally {
40 setLoading(false);
41 }
42 };
43
44 useEffect(() => {
45 getUser();
46 }, []);
47
48 if (error) {
49 return (
50 <div className="presto-flow">
51 <Flex>
52 <FlexBlock>
53 <h2>{error}</h2>
54 </FlexBlock>
55 </Flex>
56 </div>
57 );
58 }
59
60 return (
61 <div className="presto-flow">
62 <Flex>
63 <FlexBlock>
64 <Button isSecondary onClick={back}>
65 &larr; {__("Back to Dashboard", "presto-player")}
66 </Button>
67 </FlexBlock>
68 </Flex>
69 <Flex wrap>
70 <FlexBlock>
71 {loading ? (
72 <Spinner />
73 ) : (
74 <div
75 css={css`
76 display: flex;
77 align-items: center;
78
79 .presto__edit-user-button {
80 opacity: 0;
81 visibility: hidden;
82 transition: opacity 0.3s ease;
83 }
84
85 &:hover {
86 .presto__edit-user-button {
87 opacity: 1;
88 visibility: visible;
89 }
90 }
91 `}
92 >
93 <div>
94 <h1 className="presto-dashboard__title">{user?.name}</h1>
95 <p
96 css={css`
97 margin-top: -10px;
98 opacity: 0.65;
99 `}
100 >
101 {user?.email}
102 </p>
103 </div>
104 {!!user.id && (
105 <div
106 className="presto__edit-user-button"
107 css={css`
108 margin: 0 20px;
109 `}
110 >
111 <Button
112 href={`/wp-admin/user-edit.php?user_id=${user?.id}`}
113 isSecondary
114 isSmall
115 >
116 {__("View Profile", "presto-player")} &rarr;
117 </Button>
118 </div>
119 )}
120 </div>
121 )}
122 </FlexBlock>
123 <FlexItem>
124 <DatePicker
125 startDate={startDate}
126 setStartDate={setStartDate}
127 endDate={endDate}
128 setEndDate={setEndDate}
129 />
130 </FlexItem>
131 </Flex>
132
133 <div className="presto-dashboard presto-flow">
134 <div className="presto-dashboard__row">
135 <div className="presto-dashboard__item">
136 <TotalVideoViewsByUser
137 userId={route?.params?.id}
138 startDate={startDate}
139 endDate={endDate}
140 />
141 </div>
142 <div className="presto-dashboard__item">
143 <VideoAverageWatchTimeByUser
144 userId={route?.params?.id}
145 startDate={startDate}
146 endDate={endDate}
147 />
148 </div>
149 <div className="presto-dashboard__item">
150 <VideoTotalWatchTimeByUser
151 userId={route?.params?.id}
152 startDate={startDate}
153 endDate={endDate}
154 />
155 </div>
156 </div>
157 <div className="presto-dashboard__row">
158 <div className="presto-dashboard__item is-large">
159 <TopVideos
160 startDate={startDate}
161 endDate={endDate}
162 userId={route?.params?.id}
163 />
164 </div>
165 </div>
166 </div>
167 </div>
168 );
169 };
170
171 export default User;
172