Product Editor: Show correct Publish/Schedule button label when timezone is behind UTC (UTC-1, UTC-4, UTC-9, etc.) (#45848)

* Use useProductScheduled to determine button label

* Changelog
This commit is contained in:
Matt Sherman 2024-03-22 14:18:32 -04:00 committed by GitHub
parent 5352c705b5
commit 37e58a982a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 7 deletions

View File

@ -0,0 +1,4 @@
Significance: patch
Type: fix
Product Editor: Show correct Publish/Schedule button label.

View File

@ -4,7 +4,6 @@
import { MouseEvent } from 'react';
import { Button } from '@wordpress/components';
import { useEntityProp } from '@wordpress/core-data';
import { isInTheFuture } from '@wordpress/date';
import { __ } from '@wordpress/i18n';
import type { Product } from '@woocommerce/data';
@ -12,6 +11,7 @@ import type { Product } from '@woocommerce/data';
* Internal dependencies
*/
import { useProductManager } from '../../../../hooks/use-product-manager';
import { useProductScheduled } from '../../../../hooks/use-product-scheduled';
import type { WPError } from '../../../../utils/get-product-error-message';
import type { PublishButtonProps } from '../../publish-button';
@ -35,11 +35,7 @@ export function usePublish< T = Product >( {
'status'
);
const [ editedDate ] = useEntityProp< string >(
'postType',
productType,
'date_created_gmt'
);
const { isScheduled } = useProductScheduled( productType );
const isBusy = isPublishing || isValidating;
const isDisabled =
@ -61,7 +57,7 @@ export function usePublish< T = Product >( {
function getButtonText() {
if (
window.wcAdminFeatures[ 'product-pre-publish-modal' ] &&
isInTheFuture( editedDate )
isScheduled
) {
return __( 'Schedule', 'woocommerce' );
}