@@ -8,11 +8,14 @@ import classNames from 'classnames';
88 */
99import {
1010 Button ,
11- Icon
11+ Icon ,
12+ Tooltip
1213} from '@wordpress/components' ;
1314
15+ import { sprintf } from '@wordpress/i18n' ;
16+
1417import { useSelect } from '@wordpress/data' ;
15- import { warning } from '@wordpress/icons' ;
18+ import { warning , help } from '@wordpress/icons' ;
1619
1720import { clearCache } from '../../../utils/api' ;
1821
@@ -30,6 +33,7 @@ import ProgressBar from '../../components/ProgressBar';
3033import DashboardMetricBox from '../../components/DashboardMetricBox' ;
3134
3235import LastImages from './LastImages' ;
36+ import { useMemo } from 'react' ;
3337
3438const cardClasses = 'flex p-6 bg-light-blue border border-blue-300 rounded-md' ;
3539
@@ -138,6 +142,17 @@ const Dashboard = () => {
138142
139143 const visitorsLimitPercent = ( ( userData . visitors / userData . visitors_limit ) * 100 ) . toFixed ( 0 ) ;
140144
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+
141156 const formatMetric = ( type , value ) => {
142157 let formattedValue = 0 ;
143158 let unit = '' ;
@@ -202,11 +217,40 @@ const Dashboard = () => {
202217 { optimoleDashboardApp . strings . dashboard_title }
203218 </ div >
204219 < 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 " >
206221 { optimoleDashboardApp . strings . quota }
207- < span className = "pl-2 text-gray-800 font-bold" >
222+ < span className = "text-gray-800 font-bold" >
208223 { userData . visitors_pretty } / { userData . visitors_limit_pretty }
209224 </ span >
225+ < Tooltip
226+ text = {
227+ < div style = { {
228+ padding : '10px' ,
229+ maxWidth : '320px'
230+ } } >
231+ < div style = { { fontWeight : 'bold' , marginBottom : '8px' } } >
232+ { optimoleDashboardApp . strings . tooltip_visits_title }
233+ </ div >
234+ < div >
235+ {
236+ sprintf (
237+ optimoleDashboardApp . strings . tooltip_visits_description ,
238+ renewalDate
239+ )
240+ }
241+ </ div >
242+ </ div >
243+ }
244+ placement = "bottom"
245+ >
246+ < span className = "inline-flex items-center cursor-help ml-1" >
247+ < Icon
248+ icon = { help }
249+ size = { 18 }
250+ className = "text-gray-400 hover:text-gray-600"
251+ />
252+ </ span >
253+ </ Tooltip >
210254 </ div >
211255 < div className = 'md:w-20 grow md:grow-0' >
212256 < ProgressBar
@@ -215,6 +259,14 @@ const Dashboard = () => {
215259 />
216260 </ div >
217261 < span > { visitorsLimitPercent } %</ span >
262+ < span className = "text-gray-500 text-sm ml-2" >
263+ {
264+ sprintf (
265+ optimoleDashboardApp . strings . renew_date ,
266+ renewalDate
267+ )
268+ }
269+ </ span >
218270 </ div >
219271 </ div >
220272 </ div >
0 commit comments