@@ -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,37 @@ 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 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 >
210251 </ div >
211252 < div className = 'md:w-20 grow md:grow-0' >
212253 < ProgressBar
@@ -215,6 +256,14 @@ const Dashboard = () => {
215256 />
216257 </ div >
217258 < 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 >
218267 </ div >
219268 </ div >
220269 </ div >
0 commit comments