PluginProbe ʕ •ᴥ•ʔ
Presto Player / 2.2.2
Presto Player v2.2.2
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 3 years ago Video.js 3 years ago illustration.js 5 years ago
User.js
173 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 const { search } = history.location;
26 history.push(`${search}#/`);
27 };
28
29 const getUser = async () => {
30 setLoading(true);
31 try {
32 let user = await apiFetch({
33 url: `/wp-json/wp/v2/users/${route?.params?.id}?context=edit`,
34 });
35 setUser(user);
36 } catch (e) {
37 if (e.code === "rest_no_route") {
38 setError("User Not Found");
39 }
40 } finally {
41 setLoading(false);
42 }
43 };
44
45 useEffect(() => {
46 getUser();
47 }, []);
48
49 if (error) {
50 return (
51 <div className="presto-flow">
52 <Flex>
53 <FlexBlock>
54 <h2>{error}</h2>
55 </FlexBlock>
56 </Flex>
57 </div>
58 );
59 }
60
61 return (
62 <div className="presto-flow">
63 <Flex>
64 <FlexBlock>
65 <Button isSecondary onClick={back}>
66 &larr; {__("Back to Dashboard", "presto-player")}
67 </Button>
68 </FlexBlock>
69 </Flex>
70 <Flex wrap>
71 <FlexBlock>
72 {loading ? (
73 <Spinner />
74 ) : (
75 <div
76 css={css`
77 display: flex;
78 align-items: center;
79
80 .presto__edit-user-button {
81 opacity: 0;
82 visibility: hidden;
83 transition: opacity 0.3s ease;
84 }
85
86 &:hover {
87 .presto__edit-user-button {
88 opacity: 1;
89 visibility: visible;
90 }
91 }
92 `}
93 >
94 <div>
95 <h1 className="presto-dashboard__title">{user?.name}</h1>
96 <p
97 css={css`
98 margin-top: -10px;
99 opacity: 0.65;
100 `}
101 >
102 {user?.email}
103 </p>
104 </div>
105 {!!user.id && (
106 <div
107 className="presto__edit-user-button"
108 css={css`
109 margin: 0 20px;
110 `}
111 >
112 <Button
113 href={`/wp-admin/user-edit.php?user_id=${user?.id}`}
114 isSecondary
115 isSmall
116 >
117 {__("View Profile", "presto-player")} &rarr;
118 </Button>
119 </div>
120 )}
121 </div>
122 )}
123 </FlexBlock>
124 <FlexItem>
125 <DatePicker
126 startDate={startDate}
127 setStartDate={setStartDate}
128 endDate={endDate}
129 setEndDate={setEndDate}
130 />
131 </FlexItem>
132 </Flex>
133
134 <div className="presto-dashboard presto-flow">
135 <div className="presto-dashboard__row">
136 <div className="presto-dashboard__item">
137 <TotalVideoViewsByUser
138 userId={route?.params?.id}
139 startDate={startDate}
140 endDate={endDate}
141 />
142 </div>
143 <div className="presto-dashboard__item">
144 <VideoAverageWatchTimeByUser
145 userId={route?.params?.id}
146 startDate={startDate}
147 endDate={endDate}
148 />
149 </div>
150 <div className="presto-dashboard__item">
151 <VideoTotalWatchTimeByUser
152 userId={route?.params?.id}
153 startDate={startDate}
154 endDate={endDate}
155 />
156 </div>
157 </div>
158 <div className="presto-dashboard__row">
159 <div className="presto-dashboard__item is-large">
160 <TopVideos
161 startDate={startDate}
162 endDate={endDate}
163 userId={route?.params?.id}
164 />
165 </div>
166 </div>
167 </div>
168 </div>
169 );
170 };
171
172 export default User;
173