import { __ } from '@wordpress/i18n'; import React, { useEffect, useState } from 'react'; import { useNavigate } from 'react-router-dom'; import { toast } from 'sonner'; import { Eye } from 'lucide-react'; import Header from '../components/layout/Header'; import PluginPage from '../components/layout/PluginPage'; import Card from '../components/ui/card'; import ProAlert from '../components/ui/pro-alert'; import SettingsButton from '../components/ui/settings-button'; import { getDashboardCountsStats } from '../api'; import { numberFormat } from '../lib/i18n'; /** * Free stub for the Watermark page. Every action opens the pro upsell; pro replaces the whole page * through `thumbpress_component_map` once its licence is active. */ export default function Watermark() { const navigate = useNavigate(); const [totalImages, setTotalImages] = useState(null); const [alertOpen, setAlertOpen] = useState(false); const openAlert = () => setAlertOpen(true); const isProActive = window.THUMBPRESS?.pro_active; // Pro replaces this whole page through `thumbpress_component_map`. A Pro build older than the // watermark replaces nothing, so these actions are reached by someone who already pays, and the // upsell dialog is the wrong answer for them (#575). const handleProAction = () => { if (isProActive) { toast.error(__( 'This version of ThumbPress Pro cannot apply a watermark yet. Update ThumbPress Pro to the latest version.', 'image-sizes' )); return; } openAlert(); }; // Free can count the library; only Pro tracks which images are watermarked, so those stay blank. useEffect(() => { getDashboardCountsStats() .then((res) => { if (res.success) { setTotalImages(Number(res.data.total_images) || 0); } }) .catch(() => undefined); }, []); const detectImageUrl = (window.THUMBPRESS?.assets_url || '') + 'admin/img/no-search-result.png'; const statCard = (value: string, label: string) => (

{value}

{label}

); return ( <>
navigate('/settings?tab=watermark')} />} >

{__( 'Ready to Protect Your Images?', 'image-sizes' )}

{__( 'Choose text or your logo, pick the position, size and opacity, then apply it to your whole library in one run, or to every new upload automatically.', 'image-sizes' )}

{statCard(null === totalImages ? '—' : numberFormat(totalImages), __( 'Total Images', 'image-sizes' ))} {statCard('—', __( 'Watermarked', 'image-sizes' ))} {statCard('—', __( 'Not Yet Watermarked', 'image-sizes' ))}
setAlertOpen(false)} />
); }