mirror of
https://ghproxy.net/https://github.com/elementor/one-click-accessibility.git
synced 2026-07-22 12:27:13 +08:00
* [APP-1923] change remediation management (#411) * [APP-1988] Add tabs * [APP-1988][APP-1989] add tabs, remove menu item * [APP-1988][APP-1989] add tabs, remove menu item * [APP-1992] add empty state and tab navigation * [APP-1993][APP-1994] Change view for manage AI fixes, change delete confirmation modal * [APP-1996] add view for alt text fixes * [APP-1996] add edit for alt text fixes * [APP-1996] add edit for alt text fixes * [APP-1996] add edit for alt text fixes * [APP-1996] add edit for alt text fixes * [APP-1996] add edit for alt text fixes * [APP-1995] Color contrast form * [APP-2001] add global remediation logic (#415) * [APP-2001] add global remediation logic * [APP-2001] add global remediation logic * [APP-2001] add global remediation logic * [APP-2001] add global remediation logic * [APP-2001] add global remediation logic * [APP-2001] add global remediation logic * [APP-2001] add global remediation logic * [APP-2001] add global remediation logic * [APP-2001] add global remediation logic * [APP-2001] add global remediation logic * [APP-2001] add global remediation logic * [APP-2001] add global remediation logic * [APP-2001] add global remediation logic * [APP-2001] add global remediation logic * [APP-2001] add global remediation logic * [APP-2001] add global remediation logic * [APP-2003] add disable across scans (#418) * [APP-2003] add disable across scans * [APP-2003] add disable across scans * [APP-2003] add disable across scans * [APP-2003] add disable across scans * [APP-2003] add disable across scans * [APP-2003] add disable across scans * [APP-2003] add disable across scans * [APP-2003] add disable across scans * [APP-2003] add disable across scans * [APP-2003] add disable across scans * [APP-2003] add disable across scans * [APP-2003] add disable across scans * [APP-2003] add disable across scans * [APP-2003] add disable across scans * [APP-2003] add disable across scans * [APP-2003] add disable across scans * [APP-2003] add disable across scans * [APP-2003] add disable across scans * add logs * add logs * add logs * remove logs * remove logs * remove logs * remove logs * remove logs * remove logs * remove logs * remove logs * remove logs * remove logs * change to theme value * change to theme value * change to theme value * change to theme value * add edit mode * add edit mode * add edit mode
63 lines
1.8 KiB
JavaScript
63 lines
1.8 KiB
JavaScript
import AlertOctagonFilledIcon from '@elementor/icons/AlertOctagonFilledIcon';
|
||
import AlertTriangleFilledIcon from '@elementor/icons/AlertTriangleFilledIcon';
|
||
import Tooltip from '@elementor/ui/Tooltip';
|
||
import { useSettings } from '@ea11y/hooks';
|
||
import { __ } from '@wordpress/i18n';
|
||
|
||
const QuotaIndicator = () => {
|
||
const { planData, openSidebar } = useSettings();
|
||
|
||
if (!planData?.scannedPages || !planData?.aiCredits) {
|
||
return null; // Return null if data is not available
|
||
}
|
||
|
||
const { scannedPages, aiCredits } = planData;
|
||
|
||
// calculate usage data of each quota
|
||
const scannedPagesUsage = Math.round(
|
||
(scannedPages.used / scannedPages.allowed) * 100,
|
||
);
|
||
const aiCreditsUsage = Math.round((aiCredits.used / aiCredits.allowed) * 100);
|
||
|
||
// check if any of the quota is 100% used
|
||
const isQuotaExceeded = scannedPagesUsage >= 100 || aiCreditsUsage >= 100;
|
||
|
||
// check if any of the quota is 80% but not 100% used
|
||
const isQuotaWarning =
|
||
(scannedPagesUsage >= 80 && scannedPagesUsage < 100) ||
|
||
(aiCreditsUsage >= 80 && aiCreditsUsage < 100);
|
||
|
||
if (isQuotaExceeded) {
|
||
return (
|
||
<Tooltip
|
||
title={__('You’re reached your plan’s limit', 'pojo-accessibility')}
|
||
>
|
||
<AlertOctagonFilledIcon sx={{ color: 'error.dark' }} fontSize="16px" />
|
||
</Tooltip>
|
||
);
|
||
}
|
||
|
||
if (isQuotaWarning) {
|
||
return (
|
||
<Tooltip
|
||
title={__('You’re nearing your plan’s limit', 'pojo-accessibility')}
|
||
>
|
||
<AlertTriangleFilledIcon
|
||
sx={{
|
||
color: 'warning.light',
|
||
justifySelf: !openSidebar ? 'right' : 'auto',
|
||
alignSelf: !openSidebar ? 'start' : 'auto',
|
||
fontSize: !openSidebar ? '16px' : 'inherit',
|
||
position: !openSidebar ? 'absolute' : 'relative',
|
||
top: !openSidebar ? '0' : '0',
|
||
right: !openSidebar ? '10px' : 'auto',
|
||
}}
|
||
/>
|
||
</Tooltip>
|
||
);
|
||
}
|
||
|
||
return null;
|
||
};
|
||
|
||
export default QuotaIndicator;
|