@@ -8,11 +8,14 @@ import classNames from 'classnames';
8
8
*/
9
9
import {
10
10
Button ,
11
- Icon
11
+ Icon ,
12
+ Tooltip
12
13
} from '@wordpress/components' ;
13
14
15
+ import { sprintf } from '@wordpress/i18n' ;
16
+
14
17
import { useSelect } from '@wordpress/data' ;
15
- import { warning } from '@wordpress/icons' ;
18
+ import { warning , help } from '@wordpress/icons' ;
16
19
17
20
import { clearCache } from '../../../utils/api' ;
18
21
@@ -30,6 +33,7 @@ import ProgressBar from '../../components/ProgressBar';
30
33
import DashboardMetricBox from '../../components/DashboardMetricBox' ;
31
34
32
35
import LastImages from './LastImages' ;
36
+ import { useMemo } from 'react' ;
33
37
34
38
const cardClasses = 'flex p-6 bg-light-blue border border-blue-300 rounded-md' ;
35
39
@@ -138,6 +142,17 @@ const Dashboard = () => {
138
142
139
143
const visitorsLimitPercent = ( ( userData . visitors / userData . visitors_limit ) * 100 ) . toFixed ( 0 ) ;
140
144
145
+ const renewalDate = useMemo ( ( ) => {
146
+ const timestamp = userData . renews_on ;
147
+
148
+ if ( ! timestamp ) {
149
+ return 'N/A' ;
150
+ }
151
+
152
+ const date = new Date ( timestamp * 1000 ) ;
153
+ return date . toLocaleDateString ( undefined , { year : 'numeric' , month : 'short' , day : 'numeric' } ) ;
154
+ } , [ userData . renews_on ] ) ;
155
+
141
156
const formatMetric = ( type , value ) => {
142
157
let formattedValue = 0 ;
143
158
let unit = '' ;
@@ -202,11 +217,37 @@ const Dashboard = () => {
202
217
{ optimoleDashboardApp . strings . dashboard_title }
203
218
</ div >
204
219
< div className = "flex items-center gap-2" >
205
- < div className = "text-gray-600 text-base" >
220
+ < div className = "text-gray-600 text-base flex items-center gap-1 " >
206
221
{ optimoleDashboardApp . strings . quota }
207
- < span className = "pl-2 text-gray-800 font-bold" >
222
+ < span className = "text-gray-800 font-bold" >
208
223
{ userData . visitors_pretty } / { userData . visitors_limit_pretty }
209
224
</ span >
225
+ < Tooltip
226
+ text = {
227
+ < div className = "p-2.5 max-w-[320px]" >
228
+ < div className = "font-bold mb-2" >
229
+ { optimoleDashboardApp . strings . tooltip_visits_title }
230
+ </ div >
231
+ < div >
232
+ {
233
+ sprintf (
234
+ optimoleDashboardApp . strings . tooltip_visits_description ,
235
+ renewalDate
236
+ )
237
+ }
238
+ </ div >
239
+ </ div >
240
+ }
241
+ placement = "bottom"
242
+ >
243
+ < span className = "inline-flex items-center cursor-help ml-1" >
244
+ < Icon
245
+ icon = { help }
246
+ size = { 18 }
247
+ className = "text-gray-400 hover:text-gray-600"
248
+ />
249
+ </ span >
250
+ </ Tooltip >
210
251
</ div >
211
252
< div className = 'md:w-20 grow md:grow-0' >
212
253
< ProgressBar
@@ -215,6 +256,14 @@ const Dashboard = () => {
215
256
/>
216
257
</ div >
217
258
< span > { visitorsLimitPercent } %</ span >
259
+ < span className = "text-gray-500 text-sm ml-2" >
260
+ {
261
+ sprintf (
262
+ optimoleDashboardApp . strings . renew_date ,
263
+ renewalDate
264
+ )
265
+ }
266
+ </ span >
218
267
</ div >
219
268
</ div >
220
269
</ div >
0 commit comments