♻️ Extract sub-components in overview tab

This commit is contained in:
Philipp Stracker 2025-01-24 13:07:32 +01:00
parent f7845c72f6
commit a3d95f23c2
No known key found for this signature in database

View file

@ -22,8 +22,34 @@ import {
} from '../../../ReusableComponents/Icons';
const TabOverview = () => {
const [ isRefreshing, setIsRefreshing ] = useState( false );
return (
<div className="ppcp-r-tab-overview">
{ todosData.length > 0 && (
<SettingsCard
className="ppcp-r-tab-overview-todo"
title={ __(
'Things to do next',
'woocommerce-paypal-payments'
) }
description={ __(
'Complete these tasks to keep your store updated with the latest products and services.',
'woocommerce-paypal-payments'
) }
>
<TodoSettingsBlock todosData={ todosData } />
</SettingsCard>
) }
<OverviewFeatures />
<OverviewHelp />
</div>
);
};
export default TabOverview;
const OverviewFeatures = () => {
const [ isRefreshing, setIsRefreshing ] = useState( false );
const { merchant, features: merchantFeatures } = useMerchantInfo();
const { refreshFeatureStatuses, setActiveModal } =
useDispatch( STORE_NAME );
@ -49,6 +75,7 @@ const TabOverview = () => {
const refreshHandler = async () => {
setIsRefreshing( true );
try {
const result = await refreshFeatureStatuses();
if ( result && ! result.success ) {
@ -87,23 +114,6 @@ const TabOverview = () => {
};
return (
<div className="ppcp-r-tab-overview">
{ todosData.length > 0 && (
<SettingsCard
className="ppcp-r-tab-overview-todo"
title={ __(
'Things to do next',
'woocommerce-paypal-payments'
) }
description={ __(
'Complete these tasks to keep your store updated with the latest products and services.',
'woocommerce-paypal-payments'
) }
>
<TodoSettingsBlock todosData={ todosData } />
</SettingsCard>
) }
<SettingsCard
className="ppcp-r-tab-overview-features"
title={ __( 'Features', 'woocommerce-paypal-payments' ) }
@ -128,14 +138,8 @@ const TabOverview = () => {
>
<Icon icon={ reusableBlock } size={ 18 } />
{ isRefreshing
? __(
'Refreshing…',
'woocommerce-paypal-payments'
)
: __(
'Refresh',
'woocommerce-paypal-payments'
) }
? __( 'Refreshing…', 'woocommerce-paypal-payments' )
: __( 'Refresh', 'woocommerce-paypal-payments' ) }
</Button>
</>
}
@ -151,8 +155,7 @@ const TabOverview = () => {
( button ) =>
! button.showWhen || // Learn more buttons
( feature.enabled &&
button.showWhen ===
'enabled' ) ||
button.showWhen === 'enabled' ) ||
( ! feature.enabled &&
button.showWhen === 'disabled' )
)
@ -181,7 +184,11 @@ const TabOverview = () => {
);
} ) }
/>
);
};
const OverviewHelp = () => {
return (
<SettingsCard
className="ppcp-r-tab-overview-help"
title={ __( 'Help Center', 'woocommerce-paypal-payments' ) }
@ -235,8 +242,5 @@ const TabOverview = () => {
/>,
] }
/>
</div>
);
};
export default TabOverview;